Re: [CMake] This has to have been asked before...
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 osm...@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 ___ 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
Re: [CMake] This has to have been asked before...
What I did is define custom functions that wrap add_executable, add_library and target_link_libraries. Works like a charm ;-) Michael On 8. Mar, 2010, at 20:33 , David Cole wrote: 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 osm...@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 ___ 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 ___ 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
Re: [CMake] This has to have been asked before...
Michael Wild said the following on 3/8/2010 1:35 PM: What I did is define custom functions that wrap add_executable, add_library and target_link_libraries. Works like a charm ;-) *DUH!* Thank you :) - 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
[CMake] This has to have been asked before...
I'm probably not using the right keywords on my search. I want to add a target (a gcc precompiled header) as a dependency for every target so it'll get compiled with the flags for that particular target, including altering the resulting file name. I did try looking at the precompiled header CMake include, but that just confused the bejeezus out of me, not helped by the fact that it didn't work :) - 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
Re: [CMake] This has to have been asked before...
On 3/6/2010 6:39 PM, Oliver Smith wrote: I want to add a target (a gcc precompiled header) as a dependency for every target so it'll get compiled with the flags for that particular target, including altering the resulting file name. I should say: /automatically/ add... I don't want to add them by hand :) (Project has a lot of targets =/) - 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