summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cmake/mingw-w64.cmake55
1 files changed, 29 insertions, 26 deletions
diff --git a/cmake/mingw-w64.cmake b/cmake/mingw-w64.cmake
index 0bdd8e3e..01bf9209 100644
--- a/cmake/mingw-w64.cmake
+++ b/cmake/mingw-w64.cmake
@@ -6,14 +6,21 @@
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_VERSION 1)
+set(CMAKE_BUILD_TYPE_INIT RELEASE)
+# for nmake/jom build directories
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "RELEASE" CACHE STRING "" FORCE)
+endif()
+
unset(c)
unset(e)
# specify the cross compiler
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
- set(p C:/msys64/mingw64/bin/)
+ set(p C:/msys64/mingw32/bin/)
set(e .exe)
endif()
-set(c ${p}i686-w64-mingw32-)
+#set(c ${p}i686-w64-mingw32-)
+set(c "${p}")
#set(CMAKE_MAKE_PROGRAM ${p}/mingw32-make.exe CACHE FILEPATH "" FORCE)
SET(CMAKE_C_COMPILER ${c}gcc${e})
@@ -37,20 +44,30 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# oldest CPU supported here is Northwood-based Pentium 4. -sh 20150811
set(fpu "-ffast-math -mfpmath=both -mstackrealign -falign-functions=16 -falign-loops=16")
-set(cpu "-O3 -march=pentium4 -mtune=corei7-avx -msse -msse2 -mno-sse3 -mno-avx -frename-registers")
-set(lto "-flto -fuse-linker-plugin -flto-compression-level=9 -flto-partition=none -fipa-icf -fipa-pta -flto-odr-type-merging")
-set(bloat "-fno-exceptions -fno-rtti")
+set(cpu "-O3 -march=pentium4 -mtune=skylake -msse -msse2 -mno-sse3 -mno-avx -frename-registers")
+set(lto "-flto -fuse-linker-plugin -flto-compression-level=9 -flto-partition=balanced -fipa-pta -flto-odr-type-merging")
+set(bloat "")
set(sections "-ffunction-sections -fdata-sections")
+set(cc "-fdump-statistics-details -fdump-ipa-cgraph -floop-nest-optimize")
+
+set(_CXX_WARNS "")
+set(_C_WARNS "")
+if(WARNINGS_ENABLE)
+ set(usual-warns "-Wdelete-non-virtual-dtor -Wno-suggest-override -Wno-odr -Wno-attributes -Wcast-align")
+ set(_C_WARNS "-Wall -Wextra -Wpedantic -Wcast-align")
+ set(_CXX_WARNS "${_C_WARNS} ${usual-warns} ${clang-warns} ${noisy-warns} ${missing-override}")
+endif()
+
set(ccflags-common "-fvisibility=hidden -pipe")
-set(_CXXFLAGS "${bloat} ${ccflags-common}")
-set(_CFLAGS "${ccflags-common} -std=c11")
-set(_CFLAGS_RELEASE "-s ${cpu} ${fpu} ${lto} ${sections}")
+set(_CXXFLAGS "${bloat} ${ccflags-common} ${_CXX_WARNS}")
+set(_CFLAGS "${ccflags-common} -std=c11 ${_C_WARNS}")
+set(_CFLAGS_RELEASE "-s ${cpu} ${fpu} ${lto} ${sections} ${cc}")
set(_CFLAGS_DEBUG "-g -O0 -fstack-protector-strong")
-set(_CXXFLAGS_RELEASE "${_CFLAGS_RELEASE}")
+set(_CXXFLAGS_RELEASE "${_CFLAGS_RELEASE} -std=c++14 ${cc}")
set(_CXXFLAGS_DEBUG "${_CFLAGS_DEBUG}")
-set(_LDFLAGS "-Wl,--dynamicbase,--no-seh,--nxcompat,--as-needed")
+set(_LDFLAGS "-Wl,--dynamicbase,--no-seh,--nxcompat,--as-needed,--pic-executable")
set(_LDFLAGS_RELEASE "-Wl,--gc-sections,--exclude-libs,ALL -ffunction-sections")
set(_LDFLAGS_DEBUG "")
@@ -86,29 +103,15 @@ set(clang-warns "")
if(CMAKE_COMPILER_IS_CLANG)
set(clang-warns "-Wweak-vtables")
endif()
-set(_CXX_WARNS "")
-set(_C_WARNS "")
-if(WARNINGS_ENABLE)
- set(usual-warns "-Wall -Wextra -pedantic -Wdelete-non-virtual-dtor -Wno-suggest-override -Wno-odr -Wno-attributes -Wcast-align -Wc++14-compat")
- set(_CXX_WARNS "${usual-warns} ${clang-warns} ${noisy-warns} ${missing-override}")
- set(_C_WARNS "-Wall -Wextra -pedantic -Wcast-align")
-endif()
foreach(j C CXX)
foreach(i "" _DEBUG _RELEASE)
- set(OVERRIDE_${j}_FLAGS${i} "" CACHE STRING "")
- set(CMAKE_${j}_FLAGS${i} "${_${j}FLAGS${i}} ${OVERRIDE_${j}_FLAGS${i}}" CACHE STRING "" FORCE)
+ set(CMAKE_${j}_FLAGS${i} "${_${j}FLAGS${i}} ${CMAKE_${j}_FLAGS${j}}")
endforeach()
- set(CMAKE_${j}_FLAGS "${_${j}FLAGS} ${_${j}_WARNS} ${OVERRIDE_${j}_FLAGS}" CACHE STRING "" FORCE)
endforeach()
foreach(j "" _DEBUG _RELEASE)
foreach(i MODULE EXE SHARED)
- set(OVERRIDE_LDFLAGS${j} "" CACHE STRING "")
- set(CMAKE_${i}_LINKER_FLAGS${j} "${_LDFLAGS${j}} ${OVERRIDE_LDFLAGS${j}}" CACHE STRING "" FORCE)
+ set(CMAKE_${i}_LINKER_FLAGS${j} "${_LDFLAGS${j}} ${CMAKE_${i}_LINKER_FLAGS${j}}")
endforeach()
endforeach()
-
-set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "" FORCE)
-set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "" FORCE)
-