forked from dsp56300/gearmulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.cmake
95 lines (82 loc) · 3.43 KB
/
base.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(MSVC)
# https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html#variable:CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221")
# /O2 Full Optimization (Favor Speed)
# /GS- disable security checks
# /fp:fast
# /Oy omit frame pointers
# /GT enable fiber-safe optimizations
# /GL Whole Program Optimization
# /Zi Generate Debug Info PDB
# /Oi Enable Intrinsic Functions
# /Ot Favor Fast Code
# /permissive- Standards Conformance
# /MP Multiprocessor Compilation
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /O2 /GS- /fp:fast /Oy /GT /GL /Zi /Oi /Ot")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /GS- /fp:fast /Oy /GT /GL /Zi /Oi /Ot")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive- /MP")
set(ARCHITECTURE ${CMAKE_VS_PLATFORM_NAME})
if(NOT ${CMAKE_VS_PLATFORM_NAME} STREQUAL "x64")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:SSE2")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG /DEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /DEBUG")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /SAFESEH:NO")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
elseif(APPLE)
# set(ARCHITECTURE ${CMAKE_OSX_ARCHITECTURES})
set(ARCHITECTURE "MacOS")
set(OS_LINK_LIBRARIES
"-framework Accelerate"
"-framework ApplicationServices"
"-framework AudioUnit"
"-framework AudioToolbox"
"-framework Carbon"
"-framework CoreAudio"
"-framework CoreAudioKit"
"-framework CoreServices"
"-framework CoreText"
"-framework Cocoa"
"-framework CoreFoundation"
"-framework OpenGL"
"-framework QuartzCore"
)
string(APPEND CMAKE_C_FLAGS_RELEASE " -funroll-loops -Ofast -flto")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -funroll-loops -Ofast -flto -fno-stack-protector")
else()
message("CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR})
message("CMAKE_HOST_SYSTEM_PROCESSOR: " ${CMAKE_HOST_SYSTEM_PROCESSOR})
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES arm AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES aarch64)
string(APPEND CMAKE_CXX_FLAGS " -msse")
endif()
string(APPEND CMAKE_C_FLAGS_RELEASE " -Ofast")
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -Ofast -fno-stack-protector")
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -rdynamic")
execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE)
endif()
message( STATUS "Architecture: ${ARCHITECTURE}" )
message( STATUS "Compiler Arguments: ${CMAKE_CXX_FLAGS}" )
message( STATUS "Compiler Arguments (Release): ${CMAKE_CXX_FLAGS_RELEASE}" )
message( STATUS "Compiler Arguments (Debug): ${CMAKE_CXX_FLAGS_DEBUG}" )
message( STATUS "Build Configration: ${CMAKE_BUILD_TYPE}" )
# VST3 SDK needs these
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(/D_DEBUG)
else()
add_definitions(/DRELEASE)
endif()
# we need C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(UNIX AND NOT APPLE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
set(PA_DISABLE_INSTALL ON)
set(PA_BUILD_SHARED OFF)