diff options
| author | 2019-03-23 13:46:53 -0400 | |
|---|---|---|
| committer | 2019-03-23 13:46:53 -0400 | |
| commit | f08db7295a7df905767129bf0cfcfa4aac65bbfe (patch) | |
| tree | 1ceeec826506f07e354552f378cbc415ebea8197 | |
| parent | Merge pull request #2280 from lioncash/nso (diff) | |
| parent | CMakeLists: Move off of modifying CMAKE_*-related flags (diff) | |
| download | yuzu-f08db7295a7df905767129bf0cfcfa4aac65bbfe.tar.gz yuzu-f08db7295a7df905767129bf0cfcfa4aac65bbfe.tar.xz yuzu-f08db7295a7df905767129bf0cfcfa4aac65bbfe.zip | |
Merge pull request #2253 from lioncash/flags
Migrate off directly modifying CMAKE_* compilation-related flags directly
Diffstat (limited to '')
| -rw-r--r-- | CMakeLists.txt | 88 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 61 |
2 files changed, 70 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. |
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f69d00a2b..6c99dd5e2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt | |||
| @@ -1,18 +1,79 @@ | |||
| 1 | # Enable modules to include each other's files | 1 | # Enable modules to include each other's files |
| 2 | include_directories(.) | 2 | include_directories(.) |
| 3 | 3 | ||
| 4 | # CMake seems to only define _DEBUG on Windows | ||
| 5 | set_property(DIRECTORY APPEND PROPERTY | ||
| 6 | COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>) | ||
| 7 | |||
| 8 | # Set compilation flags | ||
| 9 | if (MSVC) | ||
| 10 | set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE) | ||
| 11 | |||
| 12 | # Silence "deprecation" warnings | ||
| 13 | add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS) | ||
| 14 | |||
| 15 | # Avoid windows.h junk | ||
| 16 | add_definitions(-DNOMINMAX) | ||
| 17 | |||
| 18 | # Avoid windows.h from including some usually unused libs like winsocks.h, since this might cause some redefinition errors. | ||
| 19 | add_definitions(-DWIN32_LEAN_AND_MEAN) | ||
| 20 | |||
| 21 | # /W3 - Level 3 warnings | ||
| 22 | # /MP - Multi-threaded compilation | ||
| 23 | # /Zi - Output debugging information | ||
| 24 | # /Zo - enhanced debug info for optimized builds | ||
| 25 | # /permissive- - enables stricter C++ standards conformance checks | ||
| 26 | # /EHsc - C++-only exception handling semantics | ||
| 27 | # /Zc:throwingNew - let codegen assume `operator new` will never return null | ||
| 28 | # /Zc:inline - let codegen omit inline functions in object files | ||
| 29 | add_compile_options(/W3 /MP /Zi /Zo /permissive- /EHsc /std:c++latest /Zc:throwingNew,inline) | ||
| 30 | |||
| 31 | # /GS- - No stack buffer overflow checks | ||
| 32 | add_compile_options("$<$<CONFIG:Release>:/GS->") | ||
| 33 | |||
| 34 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE) | ||
| 35 | set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) | ||
| 36 | else() | ||
| 37 | add_compile_options("-Wno-attributes") | ||
| 38 | |||
| 39 | if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) | ||
| 40 | add_compile_options("-stdlib=libc++") | ||
| 41 | endif() | ||
| 42 | |||
| 43 | # Set file offset size to 64 bits. | ||
| 44 | # | ||
| 45 | # On modern Unixes, this is typically already the case. The lone exception is | ||
| 46 | # glibc, which may default to 32 bits. glibc allows this to be configured | ||
| 47 | # by setting _FILE_OFFSET_BITS. | ||
| 48 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW) | ||
| 49 | add_definitions(-D_FILE_OFFSET_BITS=64) | ||
| 50 | endif() | ||
| 51 | |||
| 52 | if (MINGW) | ||
| 53 | add_definitions(-DMINGW_HAS_SECURE_API) | ||
| 54 | |||
| 55 | if (MINGW_STATIC_BUILD) | ||
| 56 | add_definitions(-DQT_STATICPLUGIN) | ||
| 57 | add_compile_options("-static") | ||
| 58 | endif() | ||
| 59 | endif() | ||
| 60 | endif() | ||
| 61 | |||
| 4 | add_subdirectory(common) | 62 | add_subdirectory(common) |
| 5 | add_subdirectory(core) | 63 | add_subdirectory(core) |
| 6 | add_subdirectory(audio_core) | 64 | add_subdirectory(audio_core) |
| 7 | add_subdirectory(video_core) | 65 | add_subdirectory(video_core) |
| 8 | add_subdirectory(input_common) | 66 | add_subdirectory(input_common) |
| 9 | add_subdirectory(tests) | 67 | add_subdirectory(tests) |
| 68 | |||
| 10 | if (ENABLE_SDL2) | 69 | if (ENABLE_SDL2) |
| 11 | add_subdirectory(yuzu_cmd) | 70 | add_subdirectory(yuzu_cmd) |
| 12 | endif() | 71 | endif() |
| 72 | |||
| 13 | if (ENABLE_QT) | 73 | if (ENABLE_QT) |
| 14 | add_subdirectory(yuzu) | 74 | add_subdirectory(yuzu) |
| 15 | endif() | 75 | endif() |
| 76 | |||
| 16 | if (ENABLE_WEB_SERVICE) | 77 | if (ENABLE_WEB_SERVICE) |
| 17 | add_subdirectory(web_service) | 78 | add_subdirectory(web_service) |
| 18 | endif() | 79 | endif() |