This question is related to Have Cmake use CXX and CXXFLAGS while driving links? In the first question, we are trying to tell CMake to use CXXFLAGS when it invokes the linker.
add_compile_options
We found that the following code
if (CMAKE_VERSION VERSION_LESS 2.8.12) add_definitions(-foo) else() add_compile_options(-foo) endif() message(STATUS, "CXXFLAGS: ${CMAKE_CXX_FLAGS}")
outputs a conclusion
CXXFLAGS:
SET CMAKE_CXX_FLAGS
We found that the following code
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -foo" ) message(STATUS, "CXXFLAGS: ${CMAKE_CXX_FLAGS}")
outputs a conclusion
CXXFLAGS: -foo
Questions
We found that CMake will create object files using -foo in both cases. So, -foo definitely CXXFLAGS into CXXFLAGS .
What is the difference between the first set of CMake code and the second set of CMake code?
Why is CMAKE_CXX_FLAGS canceled in one instance and installed in another instance?
cmake compiler-options
jww
source share