-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathCMakeLists.txt
127 lines (109 loc) · 5.72 KB
/
CMakeLists.txt
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# ROOT CMakeLists.txt
cmake_minimum_required(VERSION 3.15.0)
# Policies
cmake_policy(SET CMP0076 NEW) # Tell cmake to convert target_sources input from relative path to absolute path
cmake_policy(SET CMP0077 NEW) # Tell cmake to allow variables set through "set" and "option" to be compatible with each other
cmake_policy(SET CMP0048 NEW) # Tell cmake to use VERSION parameter in project() for all PROJECT_VERSION_* variables
cmake_policy(SET CMP0092 NEW) # Tell cmake not to include warning parameters by default in CMAKE_<LANG>_FLAGS variables
## Default Policies
set(CMAKE_POLICY_DEFAULT_CMP0048 NEW) # Tell CMake to use the new policy for CMP0048. (Due to zlib not defining it)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) # Tell CMake to use the new policy for CMP0077. (Due to fftw not defining it)
# Options
## We statically link the CRT by default. If you would like to dynamically
## link the CRT, you can append "DLL" to the end of the variable below.
## More Info: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# PROJECT WIDE SETUP
project(Etterna
VERSION 0.71.0
HOMEPAGE_URL https://github.com/etternagame/etterna/
LANGUAGES C CXX ASM)
## CMake and Compiler Setup
set(CMAKE_CXX_STANDARD 17) # Minimum C++ Version
set(CMAKE_CXX_EXTENSIONS OFF) # True if compiler extensions are necessary. (Changes -std flag)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # True to require minimum C++ version to compile
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10) # Tell xcodebuild to target an older osx platform
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Export compile commands for clang-tidy
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake/Modules) # Tell CMake where to access FindXXX.cmake files
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Enable folders/filters within IDEs
# Project Build Targets
add_executable(Etterna)
## Setting Target Properties
### Set a different name for each output binary depending on what build configuration is.
### Usually it is separated by directory, but since we have the same directory for every
### binary, we need to rename the binary
set_target_properties(Etterna PROPERTIES
RUNTIME_OUTPUT_NAME_DEBUG "Etterna-debug"
RUNTIME_OUTPUT_NAME_RELEASE "Etterna"
RUNTIME_OUTPUT_NAME_MINSIZEREL "Etterna-MinSizeRelease"
RUNTIME_OUTPUT_NAME_RELWITHDEBINFO "Etterna-RelWithDebInfo")
### macOS and Linux place binary in root directory
if(NOT WIN32)
set_target_properties(Etterna PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<1:${PROJECT_SOURCE_DIR}>")
endif()
## Includes
target_include_directories(Etterna PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated) # Add gen files include search dirs
target_include_directories(Etterna PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) # Add src/ to include search dirs
## Package Includes
### OpenSSL is not used directly by our program, but we have to use OpenSSL first
### in order to statically link. Once find_package is run once, it's results are cached
set(OPENSSL_USE_STATIC_LIBS ON CACHE BOOL "" FORCE)
set(OPENSSL_MSVC_STATIC_RT ON CACHE BOOL "" FORCE)
find_package(OpenSSL REQUIRED)
find_package(Threads REQUIRED)
target_link_libraries(Etterna PRIVATE Threads::Threads)
target_link_libraries(Etterna PRIVATE OpenSSL::SSL)
if(WIN32)
# These libraries are all included as the openssl instructions state they are needed for static linking.
# The source code does include some of these through "#pragma comment(lib, LIB)" though to keep it linking
# throughout the changes it may receive, we will include it here as-well.
target_link_libraries(Etterna PRIVATE CRYPT32.LIB)
target_link_libraries(Etterna PRIVATE WS2_32.LIB)
target_link_libraries(Etterna PRIVATE GDI32.LIB)
target_link_libraries(Etterna PRIVATE ADVAPI32.LIB)
target_link_libraries(Etterna PRIVATE USER32.LIB)
endif()
# Load external libraries
add_subdirectory(extern EXCLUDE_FROM_ALL) # EXCLUDE_FROM_ALL to exclude from cpack binary
## Linking
target_link_libraries(Etterna PRIVATE SQLiteCpp sqlite3)
target_link_libraries(Etterna PRIVATE zlib)
target_link_libraries(Etterna PRIVATE rapidjson)
target_link_libraries(Etterna PRIVATE websocketpp)
target_link_libraries(Etterna PRIVATE luajit)
target_link_libraries(Etterna PRIVATE discord-rpc)
target_link_libraries(Etterna PRIVATE muFFT)
target_link_libraries(Etterna PRIVATE glfw)
target_link_libraries(Etterna PRIVATE ogg)
target_link_libraries(Etterna PRIVATE vorbis)
target_link_libraries(Etterna PRIVATE pcre)
target_link_libraries(Etterna PRIVATE libmad)
target_link_libraries(Etterna PRIVATE stb)
target_link_libraries(Etterna PRIVATE libcurl)
target_link_libraries(Etterna PRIVATE picosha2)
target_link_libraries(Etterna PRIVATE fmt::fmt)
target_link_libraries(Etterna PRIVATE plog::plog)
# OS Specific Initialization
if(WIN32)
include(CMake/Helpers/CMakeWindows.cmake)
elseif(APPLE)
include(CMake/Helpers/SetupFFMPEG.cmake)
include(CMake/Helpers/CMakeMacOS.cmake)
elseif(UNIX)
include(CMake/Helpers/CMakeLinux.cmake)
endif()
## Source - Add source to the Etterna target
add_subdirectory(src/Etterna)
add_subdirectory(src/arch)
add_subdirectory(src/archutils)
add_subdirectory(src/RageUtil)
## The source_group line creates the full visual studio filter layout
get_target_property(sources Etterna SOURCES)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Etterna" FILES ${sources})
# Static Analysis
include(CMake/Helpers/StaticAnalysis.cmake)
# Documentation
include(CMake/Helpers/DocumentationTools.cmake)
# CPack Initialization
include(CMake/Helpers/CPackSetup.cmake)
include(CPack)