summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/CMakeLists.txt32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index be797d0aa..6c99dd5e2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,19 +7,16 @@ set_property(DIRECTORY APPEND PROPERTY
7 7
8# Set compilation flags 8# Set compilation flags
9if (MSVC) 9if (MSVC)
10 set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE)
11
10 # Silence "deprecation" warnings 12 # Silence "deprecation" warnings
11 add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_WARNINGS) 13 add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
12 # Avoid windows.h junk
13 add_definitions(/DNOMINMAX)
14 # Avoid windows.h from including some usually unused libs like winsocks.h, since this might cause some redefinition errors.
15 add_definitions(/DWIN32_LEAN_AND_MEAN)
16 14
17 set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE) 15 # Avoid windows.h junk
16 add_definitions(-DNOMINMAX)
18 17
19 # Tweak optimization settings 18 # Avoid windows.h from including some usually unused libs like winsocks.h, since this might cause some redefinition errors.
20 # As far as I can tell, there's no way to override the CMake defaults while leaving user 19 add_definitions(-DWIN32_LEAN_AND_MEAN)
21 # changes intact, so we'll just clobber everything and say sorry.
22 message(STATUS "Cache compiler flags ignored, please edit CMakeLists.txt to change the flags.")
23 20
24 # /W3 - Level 3 warnings 21 # /W3 - Level 3 warnings
25 # /MP - Multi-threaded compilation 22 # /MP - Multi-threaded compilation
@@ -29,22 +26,18 @@ if (MSVC)
29 # /EHsc - C++-only exception handling semantics 26 # /EHsc - C++-only exception handling semantics
30 # /Zc:throwingNew - let codegen assume `operator new` will never return null 27 # /Zc:throwingNew - let codegen assume `operator new` will never return null
31 # /Zc:inline - let codegen omit inline functions in object files 28 # /Zc:inline - let codegen omit inline functions in object files
32 set(CMAKE_CXX_FLAGS "/W3 /MP /Zi /Zo /permissive- /EHsc /std:c++latest /Zc:throwingNew,inline" CACHE STRING "" FORCE) 29 add_compile_options(/W3 /MP /Zi /Zo /permissive- /EHsc /std:c++latest /Zc:throwingNew,inline)
33 30
34 # /O2 - Optimization level 2
35 # /GS- - No stack buffer overflow checks 31 # /GS- - No stack buffer overflow checks
36 # /MD - Multi-threaded runtime DLL 32 add_compile_options("$<$<CONFIG:Release>:/GS->")
37 set(CMAKE_C_FLAGS_RELEASE "/O2 /GS- /MD" CACHE STRING "" FORCE)
38 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "" FORCE)
39 33
40 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE) 34 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE)
41 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) 35 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE)
42else() 36else()
43 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") 37 add_compile_options("-Wno-attributes")
44 38
45 if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) 39 if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
46 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") 40 add_compile_options("-stdlib=libc++")
47 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
48 endif() 41 endif()
49 42
50 # Set file offset size to 64 bits. 43 # Set file offset size to 64 bits.
@@ -61,8 +54,7 @@ else()
61 54
62 if (MINGW_STATIC_BUILD) 55 if (MINGW_STATIC_BUILD)
63 add_definitions(-DQT_STATICPLUGIN) 56 add_definitions(-DQT_STATICPLUGIN)
64 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") 57 add_compile_options("-static")
65 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
66 endif() 58 endif()
67 endif() 59 endif()
68endif() 60endif()