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

Reply via email to