forked from ohc192/chameleonEmulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.cmake
89 lines (75 loc) · 2.63 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
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
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /GS- /fp:fast /Oy /GT /GL /Zi /Oi /Ot")
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_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")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /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"
)
else()
message("CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR})
message("CMAKE_HOST_SYSTEM_PROCESSOR: " ${CMAKE_HOST_SYSTEM_PROCESSOR})
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES arm)
if(NOT EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
endif()
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if(EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL=2 -s ALLOW_MEMORY_GROWTH=1")
#-g4
endif()
execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE)
endif()
message( STATUS "Architecture: ${ARCHITECTURE}" )
# VST3 SDK needs these
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(/D_DEBUG)
else()
add_definitions(/DRELEASE)
endif()
# we need C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(UNIX AND NOT APPLE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
if(DEFINED K1VHEADLESS)
add_definitions(/DK1VHEADLESS)
endif()