-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
140 lines (116 loc) · 4.05 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
128
129
130
131
132
133
134
135
136
137
138
139
140
cmake_minimum_required(VERSION 3.25)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(ConfigureDefaultOutputDirectories)
include(ConfigureResourceRc)
include(ConfigureVersionFromGit)
configure_version_from_git()
project(
RED3ext
VERSION "${GIT_VERSION_MAJOR}.${GIT_VERSION_MINOR}.${GIT_VERSION_PATCH}"
LANGUAGES CXX
)
# -----------------------------------------------------------------------------
# General configuration / options / variables
# -----------------------------------------------------------------------------
configure_default_output_directories()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(RED3EXT_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake")
set(RED3EXT_CMAKE_TEMPLATES_DIR "${RED3EXT_CMAKE_DIR}/templates")
option(RED3EXT_CI_RELEASE "When ON version metadata will not be appended to GIT_VERSION." OFF)
mark_as_advanced(RED3EXT_CI_RELEASE)
# -----------------------------------------------------------------------------
# Compiler options for all projects
# -----------------------------------------------------------------------------
add_compile_definitions(
# Support Windows 7 and above.
WINVER=0x0601
_WIN32_WINNT=0x0601
# Exclude unnecessary APIs.
WIN32_LEAN_AND_MEAN
# Use Unicode charset.
UNICODE
_UNICODE
)
add_compile_options(
# Enable correct reporting of C++ version, see https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus.
$<$<BOOL:MSVC>:/Zc:__cplusplus>
)
add_link_options(
# Generate debugging information (PDB) file.
$<$<BOOL:MSVC>:/DEBUG:FULL>
)
# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------
include(deps/ConfigureAndIncludeDetours)
include(deps/ConfigureAndIncludeFmt)
include(deps/ConfigureAndIncludeSpdlog)
include(deps/ConfigureAndIncludeToml11)
include(deps/ConfigureAndIncludeTslOrderedMap)
include(deps/ConfigureAndIncludeWil)
# -----------------------------------------------------------------------------
# Options / configuration related only to this project
# -----------------------------------------------------------------------------
option(RED3EXT_EXTRA_WARNINGS "Enable extra warnings." ON)
if(RED3EXT_EXTRA_WARNINGS)
if(MSVC)
add_compile_options(/W4)
else()
message(
FATAL_ERROR
"The compiler options to enable extra warnings is not known for \
'${CMAKE_CXX_COMPILER_ID}'"
)
endif()
endif()
option(RED3EXT_TREAT_WARNINGS_AS_ERRORS "Treat compiler warnings as errors." OFF)
if(RED3EXT_TREAT_WARNINGS_AS_ERRORS)
if(MSVC)
add_compile_options(/WX)
else()
message(
FATAL_ERROR
"The compiler option to treat warnings as errors is not known for \
'${CMAKE_CXX_COMPILER_ID}'"
)
endif()
endif()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
# -----------------------------------------------------------------------------
# Main projects
# -----------------------------------------------------------------------------
add_subdirectory(src)
# -----------------------------------------------------------------------------
# Install
# -----------------------------------------------------------------------------
if(NOT CMAKE_SKIP_INSTALL_RULES)
option(RED3EXT_INSTALL "Generate the install target." ON)
if(RED3EXT_INSTALL)
set(RED3EXT_INSTALL_X64_DIR bin/x64)
set(RED3EXT_INSTALL_BIN_DIR red3ext)
install(
TARGETS RED3ext.Loader
RUNTIME DESTINATION "${RED3EXT_INSTALL_X64_DIR}"
)
install(
FILES $<TARGET_PDB_FILE:RED3ext.Loader>
DESTINATION "${RED3EXT_INSTALL_X64_DIR}"
)
install(
TARGETS RED3ext.Dll
RUNTIME DESTINATION "${RED3EXT_INSTALL_BIN_DIR}"
)
install(
FILES $<TARGET_PDB_FILE:RED3ext.Dll>
DESTINATION "${RED3EXT_INSTALL_BIN_DIR}"
)
install(
FILES "${PROJECT_SOURCE_DIR}/LICENSE.md"
DESTINATION "${RED3EXT_INSTALL_BIN_DIR}"
RENAME LICENSE.txt
)
endif()
endif()