[CMake] This has to have been asked before...
David Cole
david.cole at kitware.com
Mon Mar 8 14:33:34 EST 2010
It is presently not possible to iterate over all the targets in
CMakeLists.txt unless you maintain your own list of targets. It would be a
good feature request to provide the full list of CMake targets using:
get_cmake_property(var TARGETS) # for all
targets from top level all the way down
or
get_property(var GLOBAL CMAKE_TARGETS ... # for all targets from
top level all the way down
or
get_property(var DIRECTORY CMAKE_TARGETS ... # for targets just in the
current directory
However, presently, nothing like this is implemented. Wouldn't be too hard,
just hasn't been done yet.
HTH,
David
On Mon, Mar 8, 2010 at 2:11 PM, Oliver Smith <osmith at playnet.com> wrote:
> On 3/6/2010 8:04 PM, J Decker wrote:
>
> there is a foreach() operator...
>
>
> Well, thanks for trying, but what I actually want to know is how to add
> something to all the current targets *automatically* - as in without
> specifying them by hand, and how to get the compiler flags etc of a
> particular target so that I can *generate* a custom command that matches
> the given target.
>
> get_file_component(pchbase ${PrecompiledHeader} NAME_WE)
> get_file_component(pchpath ${PrecompiledHeader} PATH)
>
> * foreach ( target in LISTS CMAKE_TARGET_LIST )*
>
> set(pchname "${CMAKE_BINARY_DIR}/${pchbase}.${target}.h")
>
> get_target_properties(defines ${target} COMPILE_DEFINITIONS)
> get_target_properties(flags ${target} COMPILE_FLAGS)
> set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${flags}
> -include ${pchname} -Winvalid-pch")
>
> add_custom_command(${target} PRE_BUILD COMMAND
> "ln -s ${pchname} ${PrecompiledHeader}"
> "g++ ${defines} ${flags} -o ${pchname}.gch ${pchname}")
> )
> endforeach ()
>
> Marked in bold is the part I'm struggling with.
>
> - Oliver
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100308/6481699b/attachment.htm>
More information about the CMake
mailing list