arapelle / cmtk

This CMake ToolKit (CMTK) provides helping CMake functions to manage simple C++ CMake projects easily.
MIT License
1 stars 0 forks source link

Add find_or_simple_fetch() function. #52

Open arapelle opened 1 year ago

arapelle commented 1 year ago
arapelle commented 12 months ago
function(find_or_simple_fetchpackage version)
    cmake_parse_arguments("M_ARG" "UNINSTALL_SCRIPT" "URL;GIT;GIT_TAG" "" ${ARGN})
    include(FetchContent)
    FetchContent_Declare(
        ${package}
        URL ${URL}
        DOWNLOAD_EXTRACT_TIMESTAMP false
        FIND_PACKAGE_ARGS ${M_ARG_VERSION} CONFIG
    )
    FetchContent_MakeAvailable(${package})
    if(DEFINED M_ARG_UNINSTALL_SCRIPT AND EXISTS ${FETCHCONTENT_BASE_DIR}/${package}-build)
        install_uninstall_script(${package})
    endif()
endfunction()