Globbed Source Directory
Now, I know that for big projects, globbing can be a suboptimal technique and can lead to problems. But for small projects which are just starting out, or even for someone experimenting around in a big project, globbing is a good way to experiment with code without the build system getting in the way.
With that objective in mind, I have a proposal for a target_source_directory
command similar to the target_sources
command which is equivalent of the following:
function(target_source_directory TARGETNAME LINK_TYPE DIR_NAME)
file(
GLOB_RECURSE SOURCE_FILE_LIST
LIST_DIRECTORIES false
RELATIVE ${CMAKE_CURRENT_LIST_DIR}
CONFIGURE_DEPENDS
${DIR_NAME}/*
)
foreach(SRC_FILE ${SOURCE_FILE_LIST})
target_sources(${TARGETNAME} ${LINK_TYPE} ${SRC_FILE})
endforeach()
endfunction()
Edited by Jayesh Badwaik