[cmake-developers] Listing source-tree files encountered
Clifford Yapp
cliffyapp at gmail.com
Sat Jul 18 15:48:08 EDT 2015
With David's patch and the above SOURCE_DIR property, it looks like
the necessary pieces are now present for target + source processing.
A quick test:
get_cmake_property(target_list TARGETS)
list(SORT target_list)
foreach(targ ${target_list})
get_target_property(ttype ${targ} TYPE)
if (NOT "${ttype}" STREQUAL "UTILITY")
message("checking files of ${targ}(${ttype}): ")
get_target_property(tdir ${targ} SOURCE_DIR)
get_target_property(tsrcs ${targ} SOURCES)
foreach(fsrc ${tsrcs})
if(NOT EXISTS ${tdir}/${fsrc})
message("NOT PRESENT: ${tdir}/${fsrc}")
else(NOT EXISTS ${tdir}/${fsrc})
message("found: ${tdir}/${fsrc}")
endif(NOT EXISTS ${tdir}/${fsrc})
endforeach(fsrc ${tsrcs})
endif (NOT "${ttype}" STREQUAL "UTILITY")
endforeach(targ ${target_list})
returns the expected results, finding files that are present in the
source directories and listed in the target definition with a relative
path. Very nice! I believe this combination of abilities will also
allow me to avoid the add_subdirectory wrapping, since the set of
directories from all targets should be pretty close to the set of
directories added via add_subdirectory (warrants a quick test, but
probably close enough.)
CY
More information about the cmake-developers
mailing list