summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-07-10 06:38:16 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-07-10 06:38:16 +0200
commit5c9155f903e9bf321ec99187d7652e64f30e4d1f (patch)
treed15608960994db569c2697c42a689da25d83bae1
parent6135655fd9cb97d61ed03c65b3130eac9d7ccc11 (diff)
cmake/msvc: fix flags duplicating themselves
-rw-r--r--cmake/msvc.cmake76
1 files changed, 46 insertions, 30 deletions
diff --git a/cmake/msvc.cmake b/cmake/msvc.cmake
index def8b7dc..dfc6b59c 100644
--- a/cmake/msvc.cmake
+++ b/cmake/msvc.cmake
@@ -14,24 +14,11 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(cc "")
# oldest CPU supported here is Northwood-based Pentium 4. -sh 20150811
set(cc "${cc} -O2 -O2it -Oy- -Ob2 -fp:fast -GS- -GF -GL -Gw -Gy -Gm -Gs9999999")
-set(cc "${cc} -Zo -FS -arch:SSE2 -D_HAS_EXCEPTIONS=0")
-set(cc "${cc} -bigobj -cgthreads1")
-set(cc "${cc} -Zc:inline -Zc:rvalueCast")
+set(cc "${cc} -FS -arch:SSE2 -D_HAS_EXCEPTIONS=0")
#set(cc "${cc} -Qvec-report:1")
set(warns_ "")
-
-set(warns-disable 4530 4577 4789 4244 4702 4530 4244 4127 4458 4456 4251 4100)
-
-foreach(i ${warns-disable})
- set(warns_ "${warns_} -wd${i}")
-endforeach()
-
-foreach(k CMP0020 CMP0022 CMP0058 CMP0028 CMP0042 CMP0063 CMP0053 CMP0011 CMP0054 CMP0012)
- if(POLICY ${k})
- cmake_policy(SET ${k} NEW)
- endif()
-endforeach()
+set(warns-disable 4530 4577 4789 4244 4702 4530 4244 4127 4458 4456 4251 4100 4702)
if(CMAKE_PROJECT_NAME STREQUAL "opentrack")
include("${CMAKE_CURRENT_LIST_DIR}/opentrack-policy.cmake" NO_POLICY_SCOPE)
@@ -42,9 +29,19 @@ if(CMAKE_PROJECT_NAME STREQUAL "opentrack")
#C4266 - no override available for virtual member function from base type, function is hidden
#C4928 - illegal copy-initialization, more than one user-defined conversion has been implicitly applied
+ foreach(k CMP0020 CMP0022 CMP0058 CMP0028 CMP0042 CMP0063 CMP0053 CMP0011 CMP0054 CMP0012)
+ if(POLICY ${k})
+ cmake_policy(SET ${k} NEW)
+ endif()
+ endforeach()
+
set(warns 4265)
set(warns-noerr)
+ foreach(i ${warns-disable})
+ set(warns_ "${warns_} -wd${i}")
+ endforeach()
+
foreach(i ${warns})
set(warns_ "${warns_} -w1${i} -we${i}")
endforeach()
@@ -52,12 +49,14 @@ if(CMAKE_PROJECT_NAME STREQUAL "opentrack")
foreach(i ${warns-noerr})
set(warns_ "${warns_} -w1${i}")
endforeach()
+
set(cc "${cc} -GR-")
+ set(cc "${cc} -EHs-c-")
set(CMAKE_RC_FLAGS "/nologo /DWIN32")
endif()
-set(base-cflags "${warns_} -MT -Zi -W4")
+set(base-cflags "-MT -Zi -W4 -Zf -Zo -bigobj -cgthreads1 ${warns_}")
#set(base-cflags "${base-cflags} -d2cgsummary")
set(_CFLAGS "${base-cflags}")
@@ -67,15 +66,15 @@ set(_CFLAGS_DEBUG "-GS -sdl -Gs -guard:cf")
set(_CXXFLAGS_RELEASE "${cc}")
set(_CXXFLAGS_DEBUG "${_CFLAGS_DEBUG}")
-set(_LDFLAGS "-machine:X86 -DEBUG")
+set(_LDFLAGS "-cgthreads:1 -DEBUG")
#set(_ltcg "-LTCG")
set(_ltcg "-LTCG:INCREMENTAL")
-set(_LDFLAGS_RELEASE "-OPT:REF,ICF=4 -cgthreads:1 ${_ltcg}")
+set(_LDFLAGS_RELEASE "-OPT:REF,ICF=4 ${_ltcg}")
set(_LDFLAGS_DEBUG "")
-set(_LDFLAGS_STATIC "-machine:X86 -WX")
+set(_LDFLAGS_STATIC "-WX")
set(_LDFLAGS_STATIC_RELEASE "${_ltcg}")
set(_LDFLAGS_STATIC_DEBUG "")
@@ -83,24 +82,41 @@ set(_LDFLAGS_STATIC_DEBUG "")
#set(_CXXFLAGS "${_CXXFLAGS} -Bt+")
#set(_LDFLAGS "${_LDFLAGS} -time")
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "RELEASE" CACHE STRING "" FORCE)
- set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")
+if(NOT CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE STRING "" FORCE)
endif()
-set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} ${_LDFLAGS_STATIC}")
-set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} ${_LDFLAGS_STATIC_RELEASE}")
-set(CMAKE_STATIC_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} ${_LDFLAGS_STATIC_DEBUG}")
+string(TOUPPER "${CMAKE_BUILD_TYPE}" __build_type)
+if(NOT __build_type STREQUAL CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "${__build_type}" CACHE STRING "" FORCE)
+endif()
-foreach(j C CXX)
- foreach(i "" _DEBUG _RELEASE)
- set(CMAKE_${j}_FLAGS${i} "${CMAKE_${j}_FLAGS${i}} ${_${j}FLAGS${i}}")
- endforeach()
+if((NOT CMAKE_BUILD_TYPE STREQUAL "DEBUG") AND (NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE"))
+ set(CMAKE_BUILD_TYPE "RELEASE" CACHE STRING "" FORCE)
+endif()
+set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS RELEASE DEBUG)
+
+foreach(k "" "_${CMAKE_BUILD_TYPE}")
+ set("FLAGS_CXX${k}" "" CACHE STRING "More CMAKE_CXX_FLAGS${k}")
+ #set("FLAGS_C${k}" "" CACHE STRING "More CMAKE_C_FLAGS${k} (almost never used)")
+ set("FLAGS_LD${k}" "" CACHE STRING "More CMAKE_(SHARED|EXE|MODULE)_LINKER_FLAGS${k}")
+ set("FLAGS_ARCHIVE${k}" "" CACHE STRING "More CMAKE_STATIC_LINKER_FLAGS${k}")
endforeach()
+foreach(k "" _DEBUG _RELEASE)
+ #set(CMAKE_STATIC_LINKER_FLAGS${k} "${CMAKE_STATIC_LINKER_FLAGS${k}} ${_LDFLAGS_STATIC${k}}")
+ set(CMAKE_STATIC_LINKER_FLAGS${k} "${_LDFLAGS_STATIC${k}} ${FLAGS_ARCHIVE${k}}")
+endforeach()
foreach(j "" _DEBUG _RELEASE)
foreach(i MODULE EXE SHARED)
- set(CMAKE_${i}_LINKER_FLAGS${j} "${CMAKE_${i}_LINKER_FLAGS${j}} ${_LDFLAGS${j}}")
+ #set(CMAKE_${i}_LINKER_FLAGS${j} "${CMAKE_${i}_LINKER_FLAGS${j}} ${_LDFLAGS${j}}")
+ set(CMAKE_${i}_LINKER_FLAGS${j} "${_LDFLAGS${j}} ${FLAGS_LD${j}}")
endforeach()
endforeach()
+foreach(j C CXX)
+ foreach(i "" _DEBUG _RELEASE)
+ #set(CMAKE_${j}_FLAGS${i} "${CMAKE_${j}_FLAGS${i}} ${_${j}FLAGS${i}}")
+ set(CMAKE_${j}_FLAGS${i} "${_${j}FLAGS${i}} ${FLAGS_${j}${i}}")
+ endforeach()
+endforeach()