[CMake] generator-expressions + pch -> need new magic

Evgeniy Dushistov dushistov at gmail.com
Sun Oct 5 02:25:48 EDT 2014


Hi,
in my project I used such magic code for precompiled headers support
(gcc,clang only):

#take gcc_flags from
                              ${CMAKE_CXX_FLAGS}
${CMAKE_CXX_FLAGS_${_build_type}}
           get_target_property(... COMPILE_FLAGS)
                         get_directory_property(...
INCLUDE_DIRECTORIES)                               foreach(flag
${MY_INCLUDES})
    list(APPEND gcc_flags  "-I" "${pl_flag}")
                     endforeach()

get_directory_property(... COMPILE_DEFINITIONS)
foreach(flag ${MY_DEFS})
                              list(APPEND gcc_flags  "-D${pl_flag}")
                                              endforeach()

           get_directory_property(...
COMPILE_DEFINITIONS_${_build_type})       add_custom_command(...
${gcc_flags} ...)
All works fine, until cmake-3.0 with cmake-generator-expressions.
     With cmake-3.0 COMPILE_DEFINITIONS return something like this:
$<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>

This is empty string on compilation stage, not on not configuration
stage. So "gcc" is called like this: "gcc -D<empty>" and give error.
So question is it possible to evaluate "generator-expressions" within
CMakeLists.txt? Or may be in cmake 3.x there another is way to extract
compilation
flags without such magic as above?


More information about the CMake mailing list