diff options
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 88 |
1 files changed, 9 insertions, 79 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a4914f37d..ab18275d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -104,78 +104,12 @@ endif() | |||
| 104 | message(STATUS "Target architecture: ${ARCHITECTURE}") | 104 | message(STATUS "Target architecture: ${ARCHITECTURE}") |
| 105 | 105 | ||
| 106 | 106 | ||
| 107 | # Configure compilation flags | 107 | # Configure C++ standard |
| 108 | # =========================== | 108 | # =========================== |
| 109 | 109 | ||
| 110 | set(CMAKE_CXX_STANDARD 17) | 110 | set(CMAKE_CXX_STANDARD 17) |
| 111 | set(CMAKE_CXX_STANDARD_REQUIRED ON) | 111 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 112 | 112 | ||
| 113 | if (NOT MSVC) | ||
| 114 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes") | ||
| 115 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") | ||
| 116 | |||
| 117 | if (MINGW) | ||
| 118 | add_definitions(-DMINGW_HAS_SECURE_API) | ||
| 119 | |||
| 120 | if (MINGW_STATIC_BUILD) | ||
| 121 | add_definitions(-DQT_STATICPLUGIN) | ||
| 122 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") | ||
| 123 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") | ||
| 124 | endif() | ||
| 125 | endif() | ||
| 126 | else() | ||
| 127 | # Silence "deprecation" warnings | ||
| 128 | add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D_SCL_SECURE_NO_WARNINGS) | ||
| 129 | # Avoid windows.h junk | ||
| 130 | add_definitions(/DNOMINMAX) | ||
| 131 | # Avoid windows.h from including some usually unused libs like winsocks.h, since this might cause some redefinition errors. | ||
| 132 | add_definitions(/DWIN32_LEAN_AND_MEAN) | ||
| 133 | |||
| 134 | set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE) | ||
| 135 | |||
| 136 | # Tweak optimization settings | ||
| 137 | # As far as I can tell, there's no way to override the CMake defaults while leaving user | ||
| 138 | # changes intact, so we'll just clobber everything and say sorry. | ||
| 139 | message(STATUS "Cache compiler flags ignored, please edit CMakeLists.txt to change the flags.") | ||
| 140 | |||
| 141 | # /W3 - Level 3 warnings | ||
| 142 | # /MP - Multi-threaded compilation | ||
| 143 | # /Zi - Output debugging information | ||
| 144 | # /Zo - enhanced debug info for optimized builds | ||
| 145 | # /permissive- - enables stricter C++ standards conformance checks | ||
| 146 | set(CMAKE_C_FLAGS "/W3 /MP /Zi /Zo /permissive-" CACHE STRING "" FORCE) | ||
| 147 | # /EHsc - C++-only exception handling semantics | ||
| 148 | # /Zc:throwingNew - let codegen assume `operator new` will never return null | ||
| 149 | # /Zc:inline - let codegen omit inline functions in object files | ||
| 150 | set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /EHsc /std:c++latest /Zc:throwingNew,inline" CACHE STRING "" FORCE) | ||
| 151 | |||
| 152 | # /MDd - Multi-threaded Debug Runtime DLL | ||
| 153 | set(CMAKE_C_FLAGS_DEBUG "/Od /MDd" CACHE STRING "" FORCE) | ||
| 154 | set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "" FORCE) | ||
| 155 | |||
| 156 | # /O2 - Optimization level 2 | ||
| 157 | # /GS- - No stack buffer overflow checks | ||
| 158 | # /MD - Multi-threaded runtime DLL | ||
| 159 | set(CMAKE_C_FLAGS_RELEASE "/O2 /GS- /MD" CACHE STRING "" FORCE) | ||
| 160 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "" FORCE) | ||
| 161 | |||
| 162 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE) | ||
| 163 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) | ||
| 164 | endif() | ||
| 165 | |||
| 166 | # Set file offset size to 64 bits. | ||
| 167 | # | ||
| 168 | # On modern Unixes, this is typically already the case. The lone exception is | ||
| 169 | # glibc, which may default to 32 bits. glibc allows this to be configured | ||
| 170 | # by setting _FILE_OFFSET_BITS. | ||
| 171 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW) | ||
| 172 | add_definitions(-D_FILE_OFFSET_BITS=64) | ||
| 173 | endif() | ||
| 174 | |||
| 175 | # CMake seems to only define _DEBUG on Windows | ||
| 176 | set_property(DIRECTORY APPEND PROPERTY | ||
| 177 | COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>) | ||
| 178 | |||
| 179 | # System imported libraries | 113 | # System imported libraries |
| 180 | # ====================== | 114 | # ====================== |
| 181 | 115 | ||
| @@ -326,25 +260,21 @@ endif() | |||
| 326 | # Platform-specific library requirements | 260 | # Platform-specific library requirements |
| 327 | # ====================================== | 261 | # ====================================== |
| 328 | 262 | ||
| 329 | IF (APPLE) | 263 | if (APPLE) |
| 330 | find_library(COCOA_LIBRARY Cocoa) # Umbrella framework for everything GUI-related | 264 | # Umbrella framework for everything GUI-related |
| 265 | find_library(COCOA_LIBRARY Cocoa) | ||
| 331 | set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY}) | 266 | set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY}) |
| 332 | 267 | elseif (WIN32) | |
| 333 | if (CMAKE_CXX_COMPILER_ID STREQUAL Clang) | ||
| 334 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") | ||
| 335 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") | ||
| 336 | endif() | ||
| 337 | ELSEIF (WIN32) | ||
| 338 | # WSAPoll and SHGetKnownFolderPath (AppData/Roaming) didn't exist before WinNT 6.x (Vista) | 268 | # WSAPoll and SHGetKnownFolderPath (AppData/Roaming) didn't exist before WinNT 6.x (Vista) |
| 339 | add_definitions(-D_WIN32_WINNT=0x0600 -DWINVER=0x0600) | 269 | add_definitions(-D_WIN32_WINNT=0x0600 -DWINVER=0x0600) |
| 340 | set(PLATFORM_LIBRARIES winmm ws2_32) | 270 | set(PLATFORM_LIBRARIES winmm ws2_32) |
| 341 | IF (MINGW) | 271 | if (MINGW) |
| 342 | # PSAPI is the Process Status API | 272 | # PSAPI is the Process Status API |
| 343 | set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} psapi imm32 version) | 273 | set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} psapi imm32 version) |
| 344 | ENDIF (MINGW) | 274 | endif() |
| 345 | ELSEIF (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$") | 275 | elseif (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$") |
| 346 | set(PLATFORM_LIBRARIES rt) | 276 | set(PLATFORM_LIBRARIES rt) |
| 347 | ENDIF (APPLE) | 277 | endif() |
| 348 | 278 | ||
| 349 | # Setup a custom clang-format target (if clang-format can be found) that will run | 279 | # Setup a custom clang-format target (if clang-format can be found) that will run |
| 350 | # against all the src files. This should be used before making a pull request. | 280 | # against all the src files. This should be used before making a pull request. |