How can I determine the list of files matching a pattern in CMake?
How can I define a variable in CMake that contains a list of files that match a pattern? For example test_*.cpp
,?
And how can I define a variable containing a list of files that do NOT match the pattern? For example, test_*.cpp
must match all EXCEPT files to those that were matched above.
+3
source to share
1 answer
You can use a wildcard pattern to match the source files of a specific template.
file(GLOB_RECURSE TEST_FILES
"${PROJECT_SOURCE_DIR}/src/test_*.cpp"
)
I'm not sure how to exclude these specific files, perhaps excluding them from the list of all files such as
file(GLOB_RECURSE SRC_FILES
"${PROJECT_SOURCE_DIR}/src/*.cpp"
)
list(REMOVE_ITEM ${SRC_FILES} ${TEST_FILES})
I meant list REMOVE_ITEM
from this source http://www.cmake.org/cmake/help/v3.0/command/list.html
+5
source to share