c++ - Does set_target_properties in CMake override CMAKE_CXX_FLAGS? -
at beginning of cmake project, i'm setting general compilation flags in variable cmake_cxx_flags, like
set(cmake_cxx_flags "-w -wall ${cmake_cxx_flags}")
later on, need append additional configuration-specific compilation flags (stored in build_flags). can use following command this:
set_target_properties(${target} properties compile_flags ${build_flags})
or have add cmake_cxx_flags manually:
set_target_properties(${target} properties compile_flags "${cmake_cxx_flags} ${build_flags}")
to prevent cmake_cxx_flags being overriden build_flags?
use first one:
set_target_properties(${target} properties compile_flags ${build_flags})
the flags stored in build_flags appended after cmake_cxx_flags when compiling sources of target. documentation hints @ this, i've tried make sure.
compile_flags
additional flags use when compiling target's sources. compile_flags property sets additional compiler flags used build sources within target. use compile_definitions pass additional preprocessor definitions.
the full command line equivalent of:
${cmake_cxx_compiler} ${cmake_cxx_flags} ${compile_flags} -o foo.o -c foo.cc
and ramon said, can check make verbose=1
.
Comments
Post a Comment