summaryrefslogtreecommitdiffhomepage
path: root/cmake/modules/MakeAvailable.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/MakeAvailable.cmake')
-rw-r--r--cmake/modules/MakeAvailable.cmake16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmake/modules/MakeAvailable.cmake b/cmake/modules/MakeAvailable.cmake
new file mode 100644
index 0000000..16e976c
--- /dev/null
+++ b/cmake/modules/MakeAvailable.cmake
@@ -0,0 +1,16 @@
+# Populates all declared FetchContent projects. Use this once after everything is set up:
+#
+# FetchContent_Declare(zlib ...)
+# FetchContent_Declare(libpng ...)
+# make_available(zlib libpng)
+
+function(make_available)
+ foreach(DEPNAME IN LISTS ARGN)
+ string(TOLOWER "${DEPNAME}" DEPNAME)
+ FetchContent_GetProperties(${DEPNAME})
+ if(NOT ${DEPNAME}_POPULATED)
+ FetchContent_Populate(${DEPNAME})
+ add_subdirectory(${${DEPNAME}_SOURCE_DIR} ${${DEPNAME}_BINARY_DIR} EXCLUDE_FROM_ALL)
+ endif()
+ endforeach()
+endfunction()