Reputation: 388
This is my full CMakeLists.txt file:
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow")
set(PROJECT sample)
project(${PROJECT})
set(HEADERS
Main.h
)
set(SOURCES
Main.cpp
)
# Add souce file to project for compile
add_executable (${PROJECT} ${HEADERS} ${SOURCES})
target_link_libraries( ${PROJECT} )
But, in Makefile i don't seek substring "-Wall" and other option from CMAKE_CXX_FLAGS.
Why?
Upvotes: 1
Views: 629
Reputation: 42842
The CMAKE_CXX_FLAGS
variable is initially set with the project()
command. Move the set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ...")
after the project()
command.
From CMake Toolchains - Languages documenation:
Languages are enabled by the
project()
command. Language-specific built-in variables, such asCMAKE_CXX_COMPILER
,CMAKE_CXX_COMPILER_ID
etc are set by invoking theproject()
command. If no project command is in the top-level CMakeLists file, one will be implicitly generated. By default the enabled languages areC
andCXX
.
References
Upvotes: 4