summary refs log tree commit diff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-01-26 18:53:24 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-01-26 18:53:24 +0100
commit6e3e216156ed1b5cee27e03e5a8d29c1fe83b240 (patch)
treecd7279b18c3127f27b7dc362633ee8cdd4bcb4ea /CMakeLists.txt
parentLink bundled cmark dynamically on Windows for now (diff)
downloadnheko-6e3e216156ed1b5cee27e03e5a8d29c1fe83b240.tar.xz
Polyfill fetchcontent_makeAvailable for cmake < 3.14
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt26
1 files changed, 26 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 694b3701..d5faa4a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,6 +46,32 @@ option(USE_BUNDLED_TWEENY "Use the bundled version of tweeny."
 
 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 Qt basic functions