a984f3257e
This command is similar to add_definitions, in that it affects the compile options of all targets which follow it. The implementation is similar to the implementation of the include_directories command, in that it is based on populating a COMPILE_OPTIONS directory property and using that to initialize the same property on targets. Unlike the include_directories command however, the add_compile_options command does not affect previously defined targets. That is, in the following code, foo will not be compiled with -Wall, but bar will be: add_library(foo ...) add_compile_options(-Wall) add_library(bar ...)
15 lines
283 B
CMake
15 lines
283 B
CMake
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(add_compile_options)
|
|
|
|
add_compile_options(-DTEST_OPTION)
|
|
|
|
add_executable(add_compile_options main.cpp)
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
target_compile_definitions(add_compile_options
|
|
PRIVATE
|
|
"DO_GNU_TESTS"
|
|
)
|
|
endif()
|