From 87ec56fd4725007dea2875b796b635f722b62c7c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 27 Mar 2017 00:36:31 +0200 Subject: cmake: remove -DNDEBUG from cxxflags automatically User came complain why ndebug-guard.hpp #error'ed out. --- CMakeLists.txt | 4 ++++ cmake/opentrack-platform.cmake | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51d037c7..276a5cae 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,3 +78,7 @@ endforeach() merge_translations() install_sources() + +foreach(k C CXX) + fix_flags(${k} "DNDEBUG" "") +endforeach() diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake index 83784ffc..ce8341b1 100644 --- a/cmake/opentrack-platform.cmake +++ b/cmake/opentrack-platform.cmake @@ -95,6 +95,30 @@ endif() set_property(GLOBAL PROPERTY USE_FOLDERS OFF) +function(fix_flags lang flag replacement) + set(part "-") + set(pfx "-") + if(MSVC) + set(part "[-/]") + set(pfx "/") + endif() + if(".${replacement}" STREQUAL ".") + set(pfx "") + endif() + opentrack_escape_string(flag "${flag}") + foreach(k _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO "") + set(tmp "${CMAKE_${lang}_FLAGS${k}}") + if(NOT ".${replacement}" STREQUAL ".") + string(APPEND replacement " ") + endif() + string(REGEX REPLACE "(^| )${part}${flag}(\$| )" " ${pfx}${replacement}" CMAKE_${lang}_FLAGS${k} "${CMAKE_${lang}_FLAGS${k}}") + if(NOT ".${tmp}" STREQUAL ".${CMAKE_${lang}_FLAGS${k}}") + set(CMAKE_${lang}_FLAGS${k} "${CMAKE_${lang}_FLAGS${k}}" CACHE STRING "" FORCE) + else() + set(CMAKE_${lang}_FLAGS${k} "${CMAKE_${lang}_FLAGS${k}} ${pfx}${replacement}" CACHE STRING "" FORCE) + endif() + endforeach() +endfunction() # nix -rdynamic passed from Linux-GNU.cmake if(CMAKE_COMPILER_IS_GNUCXX) set(__LINUX_COMPILER_GNU 1) -- cgit v1.2.3