From 289abcd7a25610b79591056a125dd54db4b22b42 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Sun, 12 Feb 2017 04:41:57 -0800 Subject: [PATCH] use -fpermissive and -fexceptions with C++ only Add -fpermissive and -fexceptions to CMAKE_CXX_COMPILE_OBJECT so that they only affect C++. -std=gnu++11 was already there from b4ba9d9d, but this is a cleaner method (which is also used for NASM) where we use STRING(REGEX REPLACE ...) to append options after the placeholder in CMAKE_CXX_COMPILE_OBJECT. --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e0edda8..34b64e5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -315,7 +315,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) ENDIF() # common flags - SET(MY_C_FLAGS -pipe -fPIC -Wformat -Wformat-security -fexceptions -D_FORTIFY_SOURCE=2 -feliminate-unused-debug-types) + SET(MY_C_FLAGS -pipe -fPIC -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -feliminate-unused-debug-types) # check if SSP flags are supported INCLUDE(CheckCXXCompilerFlag) @@ -345,10 +345,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) ADD_COMPILE_OPTIONS(${C_COMPILE_FLAG}) ENDFOREACH() - # This one must be set for C++ only, and we can't use generator expressions - # in ADD_COMPILE_OPTIONS because that's a cmake 3.3 feature and we need - # 2.8.12 compat for Ubuntu 14. - SET(CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT} -std=gnu++11") + # These must be set for C++ only, and we can't use generator expressions in + # ADD_COMPILE_OPTIONS because that's a cmake 3.3 feature and we need 2.8.12 + # compat for Ubuntu 14. + STRING(REGEX REPLACE "" " -std=gnu++11 -fpermissive -fexceptions " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT}) # make a string of compile options to add to link flags UNSET(C_COMPILE_FLAGS_STR)