From 1f7e8bda432649a63b6c36f5b6da301ea961978f Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Thu, 30 May 2024 10:49:03 +0200 Subject: [PATCH] Add function to automatically find dirs containing cmake configs --- cmake/Utils.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 cmake/Utils.cmake diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake new file mode 100644 index 0000000..c10f377 --- /dev/null +++ b/cmake/Utils.cmake @@ -0,0 +1,10 @@ +function(FindCmakeConfigDirs BASE_DIR OUTPUT_NAME) + file(GLOB_RECURSE ALL_CONFIGS "${BASE_DIR}/*[Cc]onfig.cmake") + set(PACKAGE_SUB_DIRS "") + foreach(CONF ${ALL_CONFIGS}) + get_filename_component(DIR_NAME "${CONF}" DIRECTORY) + list(APPEND PACKAGE_SUB_DIRS "${DIR_NAME}") + endforeach() + list(REMOVE_DUPLICATES PACKAGE_SUB_DIRS) + set(${OUTPUT_NAME} ${PACKAGE_SUB_DIRS} PARENT_SCOPE) +endfunction() \ No newline at end of file