Polyfill fetchcontent_makeAvailable for cmake < 3.14

This commit is contained in:
Nicolas Werner 2020-01-26 18:53:24 +01:00
parent 498d8d464c
commit 6e3e216156

View file

@ -46,6 +46,32 @@ option(USE_BUNDLED_TWEENY "Use the bundled version of tweeny."
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
message("Adding FetchContent_MakeAvailable")
# from cmakes sources
macro(FetchContent_MakeAvailable)
foreach(contentName IN ITEMS ${ARGV})
string(TOLOWER ${contentName} contentNameLower)
FetchContent_GetProperties(${contentName})
if(NOT ${contentNameLower}_POPULATED)
FetchContent_Populate(${contentName})
# Only try to call add_subdirectory() if the populated content
# can be treated that way. Protecting the call with the check
# allows this function to be used for projects that just want
# to ensure the content exists, such as to provide content at
# a known location.
if(EXISTS ${${contentNameLower}_SOURCE_DIR}/CMakeLists.txt)
add_subdirectory(${${contentNameLower}_SOURCE_DIR}
${${contentNameLower}_BINARY_DIR})
endif()
endif()
endforeach()
endmacro()
endif()
include(GNUInstallDirs) include(GNUInstallDirs)
# Include Qt basic functions # Include Qt basic functions