-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
184 lines (156 loc) · 4.39 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
cmake_minimum_required(VERSION 3.15.0)
cmake_policy(SET CMP0091 NEW)
project(
chopt
VERSION 1.9.2
DESCRIPTION "A program to generate optimal Star Power paths for Clone Hero"
LANGUAGES CXX)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
include(cmake/Sanitisers.cmake)
# Require standard C++20
function(set_cpp_standard target)
set_target_properties(
${target}
PROPERTIES CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
endfunction()
# Set warning flags
function(set_warnings target)
target_compile_options(
${target}
PRIVATE $<$<CXX_COMPILER_ID:Clang,AppleClang,GNU>:
-Wall
-Wextra
-Werror
-Wno-c++98-compat
-Wno-unknown-warning-option>
$<$<CXX_COMPILER_ID:MSVC>:
/W4
/WX>)
endfunction()
find_package(PNG REQUIRED)
find_package(
Qt6 REQUIRED
COMPONENTS Core
OPTIONAL_COMPONENTS Gui Widgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_subdirectory("extern/sightread")
cmake_policy(SET CMP0083 NEW)
include(CheckPIESupported)
check_pie_supported(OUTPUT_VARIABLE output LANGUAGES CXX)
if(NOT CMAKE_CXX_LINK_NO_PIE_SUPPORTED)
message(VERBOSE "No PIE is not supported at link time: ${output}.\n"
"PIE link options will not be passed to linker.")
endif()
add_executable(
chopt
src/main.cpp
src/image.cpp
src/imagebuilder.cpp
src/ini.cpp
src/optimiser.cpp
src/points.cpp
src/processed.cpp
src/settings.cpp
src/songfile.cpp
src/sp.cpp
src/sptimemap.cpp
src/stringutil.cpp
resources/chopt.exe.manifest
resources/resources.qrc
resources/resources.rc)
target_include_directories(
chopt PRIVATE "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/libs" ${PNG_INCLUDE_DIRS})
target_link_libraries(chopt PRIVATE ${PNG_LIBRARIES} Qt6::Core Qt6::Gui sightread)
set_property(TARGET chopt PROPERTY POSITION_INDEPENDENT_CODE FALSE)
set_cpp_standard(chopt)
set_warnings(chopt)
enable_sanitisers(chopt)
option(BUILD_GUI "Build the GUI version" ON)
if(BUILD_GUI)
add_executable(
choptgui WIN32
gui/json_settings.cpp
gui/main.cpp
gui/mainwindow.cpp
gui/mainwindow.ui
src/image.cpp
src/imagebuilder.cpp
src/ini.cpp
src/optimiser.cpp
src/points.cpp
src/processed.cpp
src/settings.cpp
src/songfile.cpp
src/sp.cpp
src/sptimemap.cpp
src/stringutil.cpp
resources/choptgui.exe.manifest
resources/resources.qrc
resources/resources.rc)
target_include_directories(
choptgui PRIVATE "${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/libs" ${PNG_INCLUDE_DIRS})
target_link_libraries(choptgui PRIVATE ${PNG_LIBRARIES} Qt6::Widgets sightread)
set_property(TARGET choptgui PROPERTY POSITION_INDEPENDENT_CODE FALSE)
if(APPLE)
set_property(TARGET choptgui PROPERTY MACOSX_BUNDLE TRUE)
endif()
set_cpp_standard(choptgui)
endif()
include(CTest)
option(PACKAGE_TESTS "Build the tests" ON)
if(PACKAGE_TESTS)
find_package(Boost 1.77 REQUIRED unit_test_framework)
enable_testing()
add_executable(
chopt_tests
tests/test_main.cpp
tests/imagebuilder_unittest.cpp
tests/ini_unittest.cpp
tests/optimiser_unittest.cpp
tests/points_unittest.cpp
tests/processed_unittest.cpp
tests/sp_unittest.cpp
tests/stringutil_unittest.cpp
src/imagebuilder.cpp
src/ini.cpp
src/optimiser.cpp
src/points.cpp
src/processed.cpp
src/settings.cpp
src/sp.cpp
src/sptimemap.cpp
src/stringutil.cpp)
target_include_directories(chopt_tests
PRIVATE "${PROJECT_SOURCE_DIR}/include")
target_link_libraries(chopt_tests PRIVATE Boost::unit_test_framework Qt6::Core sightread)
add_test(NAME chopt_tests COMMAND chopt_tests)
set_cpp_standard(chopt_tests)
set_warnings(chopt_tests)
enable_sanitisers(chopt_tests)
endif()
option(BUILD_FUZZ_TARGETS "Build the fuzzing targets" OFF)
if(BUILD_FUZZ_TARGETS)
add_subdirectory(fuzzing_targets)
endif()
option(ENABLE_LTO "Enable Link Time Optimisation" OFF)
if(ENABLE_LTO)
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(
RESULT supported
OUTPUT output
LANGUAGES CXX)
if(supported)
set_property(TARGET chopt PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
if(BUILD_GUI)
set_property(TARGET choptgui PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
else()
message(WARNING "LTO is not supported: ${output}")
endif()
endif()