Add function to automatically find dirs containing cmake configs

This commit is contained in:
Georg Hagen
2024-05-30 10:49:03 +02:00
parent 16f3ed63c5
commit 1f7e8bda43

10
cmake/Utils.cmake Normal file
View File

@@ -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()