blob: 5f3d83ce4eafbdd17e2ecd2a7d84c28d1a774492 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
cmake_minimum_required(VERSION 2.8.12)
message(WARNING "add_global_compiler_switch() is deprecated. Use target_compile_options() instead")
# Make macros that can add compiler switches to the entire project. Not just
# to the current cmake folder being built.
macro ( add_global_compiler_switch switch_name )
# If removing the switch would change the flags then it's already present
# and we don't need to do anything.
string(REPLACE "${switch_name}" "" tempstr "${CMAKE_CXX_FLAGS}")
if ("${CMAKE_CXX_FLAGS}" STREQUAL "${tempstr}" )
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${switch_name}"
CACHE STRING "Flags used by the compiler during all C++ builds."
FORCE)
endif ()
endmacro()
macro ( remove_global_compiler_switch switch_name )
string(REPLACE "${switch_name}" "" tempstr "${CMAKE_CXX_FLAGS}")
if (NOT "${CMAKE_CXX_FLAGS}" STREQUAL "${tempstr}" )
set (CMAKE_CXX_FLAGS "${tempstr}"
CACHE STRING "Flags used by the compiler during all C++ builds."
FORCE)
endif ()
endmacro()
macro (add_global_define def_name)
add_global_compiler_switch(-D${def_name})
endmacro()
macro (remove_global_define def_name)
remove_global_compiler_switch(-D${def_name})
endmacro()
|