summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2019-03-16 01:45:08 -0400
committerGravatar Lioncash2019-03-17 01:49:09 -0400
commit13bc74e957a9ff62bcd4fc18e2eefa0f0d915a6f (patch)
tree0d0545da5228ea6648930b119c5ea8ceb1ca0397
parentMerge pull request #2251 from bunnei/skip-zero-flush (diff)
downloadyuzu-13bc74e957a9ff62bcd4fc18e2eefa0f0d915a6f.tar.gz
yuzu-13bc74e957a9ff62bcd4fc18e2eefa0f0d915a6f.tar.xz
yuzu-13bc74e957a9ff62bcd4fc18e2eefa0f0d915a6f.zip
CMakeLists: Move compilation flags into the src directory
We generally shouldn't be hijacking CMAKE_CXX_FLAGS, etc as a means to append flags to the targets, since this adds the compilation flags to everything, including our externals, which can result in weird issues and makes the build hierarchy fragile. Instead, we want to just apply these compilation flags to our targets, and let those managing external libraries to properly specify their compilation flags. This also results in us not getting as many warnings, as we don't raise the warning level on every external target.
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt88
-rw-r--r--src/CMakeLists.txt69
2 files changed, 78 insertions, 79 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9cc24cba6..67e249fbb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -104,78 +104,12 @@ endif()
104message(STATUS "Target architecture: ${ARCHITECTURE}") 104message(STATUS "Target architecture: ${ARCHITECTURE}")
105 105
106 106
107# Configure compilation flags 107# Configure C++ standard
108# =========================== 108# ===========================
109 109
110set(CMAKE_CXX_STANDARD 17) 110set(CMAKE_CXX_STANDARD 17)
111set(CMAKE_CXX_STANDARD_REQUIRED ON) 111set(CMAKE_CXX_STANDARD_REQUIRED ON)
112 112
113if (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()
126else()
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)
164endif()
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.
171if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
172 add_definitions(-D_FILE_OFFSET_BITS=64)
173endif()
174
175# CMake seems to only define _DEBUG on Windows
176set_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
329IF (APPLE) 263if (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 267elseif (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()
337ELSEIF (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()
345ELSEIF (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$") 275elseif (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$")
346 set(PLATFORM_LIBRARIES rt) 276 set(PLATFORM_LIBRARIES rt)
347ENDIF (APPLE) 277endif()
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..be797d0aa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,18 +1,87 @@
1# Enable modules to include each other's files 1# Enable modules to include each other's files
2include_directories(.) 2include_directories(.)
3 3
4# CMake seems to only define _DEBUG on Windows
5set_property(DIRECTORY APPEND PROPERTY
6 COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
7
8# Set compilation flags
9if (MSVC)
10 # Silence "deprecation" warnings
11 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
17 set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE)
18
19 # Tweak optimization settings
20 # As far as I can tell, there's no way to override the CMake defaults while leaving user
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
24 # /W3 - Level 3 warnings
25 # /MP - Multi-threaded compilation
26 # /Zi - Output debugging information
27 # /Zo - enhanced debug info for optimized builds
28 # /permissive- - enables stricter C++ standards conformance checks
29 # /EHsc - C++-only exception handling semantics
30 # /Zc:throwingNew - let codegen assume `operator new` will never return null
31 # /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)
33
34 # /O2 - Optimization level 2
35 # /GS- - No stack buffer overflow checks
36 # /MD - Multi-threaded runtime DLL
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
40 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)
42else()
43 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
44
45 if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
46 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
47 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
48 endif()
49
50 # Set file offset size to 64 bits.
51 #
52 # On modern Unixes, this is typically already the case. The lone exception is
53 # glibc, which may default to 32 bits. glibc allows this to be configured
54 # by setting _FILE_OFFSET_BITS.
55 if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
56 add_definitions(-D_FILE_OFFSET_BITS=64)
57 endif()
58
59 if (MINGW)
60 add_definitions(-DMINGW_HAS_SECURE_API)
61
62 if (MINGW_STATIC_BUILD)
63 add_definitions(-DQT_STATICPLUGIN)
64 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
65 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
66 endif()
67 endif()
68endif()
69
4add_subdirectory(common) 70add_subdirectory(common)
5add_subdirectory(core) 71add_subdirectory(core)
6add_subdirectory(audio_core) 72add_subdirectory(audio_core)
7add_subdirectory(video_core) 73add_subdirectory(video_core)
8add_subdirectory(input_common) 74add_subdirectory(input_common)
9add_subdirectory(tests) 75add_subdirectory(tests)
76
10if (ENABLE_SDL2) 77if (ENABLE_SDL2)
11 add_subdirectory(yuzu_cmd) 78 add_subdirectory(yuzu_cmd)
12endif() 79endif()
80
13if (ENABLE_QT) 81if (ENABLE_QT)
14 add_subdirectory(yuzu) 82 add_subdirectory(yuzu)
15endif() 83endif()
84
16if (ENABLE_WEB_SERVICE) 85if (ENABLE_WEB_SERVICE)
17 add_subdirectory(web_service) 86 add_subdirectory(web_service)
18endif() 87endif()