[CMake] generator-expressions + pch -> need new magic
Evgeniy Dushistov
dushistov at gmail.com
Sun Oct 5 11:38:23 EDT 2014
I found workaround for that problem,
I add to this loop:
foreach(flag ${MY_DEFS})
list(APPEND gcc_flags "-D${flag}")
endforeach()
such code:
foreach(flag ${PL_COMP_DEFS})
string(FIND ${flag} "$<" find_res)
if (find_res EQUAL 0)
list(APPEND gcc_flags "$<$<BOOL:${flag}>:-D$<JOIN:${flag}, -D>>")
else ()
list(APPEND gcc_flags "-D${flag}")
endif ()
endforeach()
but may there is better solution?
On Sun, Oct 5, 2014 at 10:25 AM, Evgeniy Dushistov <dushistov at gmail.com> wrote:
> 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