Created
September 18, 2020 10:41
-
-
Save ronald112/77d9d1bbf0710f7b099a481f92063829 to your computer and use it in GitHub Desktop.
CMAKE MACRO and function to include all directories recursively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MACRO to add all directories in result | |
MACRO(SUBDIRLIST result firstdir curdir) | |
file(GLOB ENDF6_SRC_TOP RELATIVE | |
${curdir} ${curdir}/*) | |
file(GLOB_RECURSE ENDF6_SRC_NESTED ${curdir}/*) | |
set(children ${ENDF6_SRC_TOP} ${ENDF6_SRC_NESTED}) | |
SET(dirlist "${firstdir}") | |
FOREACH(child ${children}) | |
IF(IS_DIRECTORY ${curdir}/${child}) | |
LIST(APPEND dirlist ${curdir}/${child}) | |
ENDIF() | |
ENDFOREACH() | |
SET(${result} ${dirlist}) | |
ENDMACRO() | |
function(include_all_files) | |
#argv[0] - result variable, argv[1] - add relative paths, set "" if you don't want it | |
#argv[2] - path to folder with folders | |
SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) | |
FOREACH(subdir ${SUBDIRS}) | |
include_directories(${subdir}) | |
ENDFOREACH() | |
endfunction() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment