Commit 27a4a2c9 authored by Davis King's avatar Davis King
Browse files

Made this macro work for switch strings that have what look like regular

expressions in them to cmake.
parent 914deffc
cmake_minimum_required(VERSION 2.8.4)
# 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 (NOT CMAKE_CXX_FLAGS MATCHES "${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)
......@@ -11,9 +16,9 @@ macro ( add_global_compiler_switch switch_name )
endmacro()
macro ( remove_global_compiler_switch switch_name )
if (CMAKE_CXX_FLAGS MATCHES " ${switch_name}")
string (REGEX REPLACE " ${switch_name}" "" temp_var ${CMAKE_CXX_FLAGS})
set (CMAKE_CXX_FLAGS "${temp_var}"
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 ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment