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

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 # Make macros that can add compiler switches to the entire project. Not just
# to the current cmake folder being built. # to the current cmake folder being built.
macro ( add_global_compiler_switch switch_name ) 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}" set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${switch_name}"
CACHE STRING "Flags used by the compiler during all C++ builds." CACHE STRING "Flags used by the compiler during all C++ builds."
FORCE) FORCE)
...@@ -11,9 +16,9 @@ macro ( add_global_compiler_switch switch_name ) ...@@ -11,9 +16,9 @@ macro ( add_global_compiler_switch switch_name )
endmacro() endmacro()
macro ( remove_global_compiler_switch switch_name ) macro ( remove_global_compiler_switch switch_name )
if (CMAKE_CXX_FLAGS MATCHES " ${switch_name}") string(REPLACE "${switch_name}" "" tempstr "${CMAKE_CXX_FLAGS}")
string (REGEX REPLACE " ${switch_name}" "" temp_var ${CMAKE_CXX_FLAGS}) if (NOT "${CMAKE_CXX_FLAGS}" STREQUAL "${tempstr}" )
set (CMAKE_CXX_FLAGS "${temp_var}" set (CMAKE_CXX_FLAGS "${tempstr}"
CACHE STRING "Flags used by the compiler during all C++ builds." CACHE STRING "Flags used by the compiler during all C++ builds."
FORCE) FORCE)
endif () 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