From 5e83943831e22a47015ba79f2bd1f96cea0af919 Mon Sep 17 00:00:00 2001 From: Bram de Jong Date: Wed, 7 Dec 2016 23:07:10 +0100 Subject: [PATCH] Simpler c/cxx flags --- Common/c_flag_overrides.cmake | 6 ------ Common/common.cmake | 14 ++++++++++---- Common/cxx_flag_overrides.cmake | 6 ------ 3 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 Common/c_flag_overrides.cmake delete mode 100644 Common/cxx_flag_overrides.cmake diff --git a/Common/c_flag_overrides.cmake b/Common/c_flag_overrides.cmake deleted file mode 100644 index ebd598d..0000000 --- a/Common/c_flag_overrides.cmake +++ /dev/null @@ -1,6 +0,0 @@ -if(MSVC) - set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") - set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG") - set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") - set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") -endif() diff --git a/Common/common.cmake b/Common/common.cmake index 2332083..0cd6750 100644 --- a/Common/common.cmake +++ b/Common/common.cmake @@ -8,11 +8,17 @@ function(pre_build) if (APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" PARENT_SCOPE) set(CMAKE_OSX_ARCHITECTURES "i386" "x86_64" PARENT_SCOPE) + elseif(MSVC) + # static linking + foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif() + if(${flag_var} MATCHES "/MDd") + string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") + endif() + endforeach() endif() - - set(COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../Common) - set(CMAKE_USER_MAKE_RULES_OVERRIDE ${COMMON_DIR}/c_flag_overrides.cmake) - set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${COMMON_DIR}/cxx_flag_overrides.cmake) endfunction(pre_build) #******************************************************************************* diff --git a/Common/cxx_flag_overrides.cmake b/Common/cxx_flag_overrides.cmake deleted file mode 100644 index 603f72f..0000000 --- a/Common/cxx_flag_overrides.cmake +++ /dev/null @@ -1,6 +0,0 @@ -if(MSVC) - set(CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1") - set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG") - set(CMAKE_CXX_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") -endif()