-
Notifications
You must be signed in to change notification settings - Fork 31
/
CMakeLists.txt
208 lines (182 loc) · 6.77 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Pingus - A free Lemmings clone
# Copyright (C) 2015 Ingo Ruhnke <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.15)
project(pingus VERSION 0.8.0)
include(mk/cmake/TinyCMMC.cmake)
find_package(PkgConfig REQUIRED)
set(OpenGL_GL_PREFERENCE "LEGACY")
find_package(OpenGL REQUIRED)
pkg_search_module(SDL2 REQUIRED sdl2 IMPORTED_TARGET)
pkg_search_module(SDL2IMAGE REQUIRED SDL2_image>=2.0.0 IMPORTED_TARGET)
pkg_search_module(PNG REQUIRED libpng IMPORTED_TARGET)
pkg_search_module(SIGCXX REQUIRED sigc++-2.0 IMPORTED_TARGET)
find_package(fmt REQUIRED)
find_package(glm REQUIRED)
if (BUILD_TESTS)
# add 'make test' target, use 'make test ARGS="-V"' or 'ctest -V' for verbose
enable_testing()
endif(BUILD_TESTS)
file(GLOB PINGUS_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
src/editor/*.cpp
src/engine/display/*.cpp
src/engine/display/delta/*.cpp
src/engine/display/opengl/*.cpp
src/engine/gui/*.cpp
src/engine/input/*.cpp
src/engine/resource/*.cpp
src/engine/screen/*.cpp
src/engine/sound/*.cpp
src/engine/system/*.cpp
src/math/*.cpp
src/pingus/*.cpp
src/pingus/actions/*.cpp
src/pingus/colliders/*.cpp
src/pingus/components/*.cpp
src/pingus/movers/*.cpp
src/pingus/particles/*.cpp
src/pingus/screens/*.cpp
src/pingus/worldmap/*.cpp
src/pingus/worldobjs/*.cpp
src/util/*.cpp
)
function(build_dependencies)
set(BUILD_TESTS OFF)
set(TINYGETTEXT_WITH_SDL ON)
tinycmmc_find_dependency(uitest)
tinycmmc_find_dependency(tinygettext)
tinycmmc_find_dependency(argpp)
tinycmmc_find_dependency(geom)
tinycmmc_find_dependency(logmich)
tinycmmc_find_dependency(prio)
tinycmmc_find_dependency(strut)
tinycmmc_find_dependency(wstsound)
if(WIN32)
add_library(xdgcpp INTERFACE)
else()
tinycmmc_find_dependency(xdgcpp)
endif()
endfunction()
build_dependencies()
# Build Pingus
add_library(libpingus STATIC ${PINGUS_SOURCES_CXX})
set_target_properties(libpingus PROPERTIES OUTPUT_NAME pingus)
target_include_directories(libpingus PUBLIC src/)
target_compile_options(libpingus PRIVATE ${TINYCMMC_WARNINGS_CXX_FLAGS})
target_compile_definitions(libpingus PUBLIC
-DPROJECT_VERSION="${PROJECT_VERSION}"
-DPROJECT_NAME="${PROJECT_NAME}")
target_link_libraries(libpingus PUBLIC
argpp::argpp
geom::geom
logmich::logmich
prio::prio
tinygettext
strut::strut
xdgcpp
wstsound::wstsound
fmt::fmt
glm::glm
PkgConfig::SDL2
PkgConfig::SDL2IMAGE
PkgConfig::PNG
PkgConfig::SIGCXX
OpenGL::GL)
set(PINGUS_MAIN_SOURCES_CXX src/main.cpp)
if(WIN32)
list(APPEND PINGUS_MAIN_SOURCES_CXX
src/win32/console.cpp
src/win32/pingus.rc)
endif()
add_executable(pingus ${PINGUS_MAIN_SOURCES_CXX})
set_target_properties(libpingus PROPERTIES OUTPUT_NAME pingus)
target_compile_options(pingus PRIVATE ${TINYCMMC_WARNINGS_CXX_FLAGS})
target_link_libraries(pingus libpingus)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
if(BUILD_EXTRA)
file(GLOB PINGUS_EXTRA_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
extra/*.cpp)
foreach(EXTRA_SOURCE ${PINGUS_EXTRA_SOURCES_CXX})
string(REGEX REPLACE ".*/\([^/]*\).cpp" "\\1" EXTRA_EXE ${EXTRA_SOURCE})
add_executable(${EXTRA_EXE} ${EXTRA_SOURCE})
set_target_properties(${EXTRA_EXE} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "extra/")
target_compile_options(${EXTRA_EXE} PRIVATE ${TINYCMMC_WARNINGS_CXX_FLAGS})
target_link_libraries(${EXTRA_EXE} libpingus)
endforeach(EXTRA_SOURCE)
endif()
if(BUILD_TESTS)
find_package(GTest REQUIRED)
# build interactive tests
file(GLOB UITEST_PINGUS_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} uitest/*_test.cpp)
add_executable(uitest_pingus ${UITEST_PINGUS_SOURCES})
target_link_libraries(uitest_pingus libpingus uitest uitest_main)
file(GLOB PINGUS_TEST_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
test/*_test.cpp)
foreach(TEST_SOURCE ${PINGUS_TEST_SOURCES_CXX})
string(REGEX REPLACE ".*/\([^/]*\).cpp" "\\1" TEST_EXE ${TEST_SOURCE})
add_executable(${TEST_EXE} ${TEST_SOURCE})
set_target_properties(${TEST_EXE} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "test/")
target_compile_options(${TEST_EXE} PRIVATE ${TINYCMMC_WARNINGS_CXX_FLAGS})
target_link_libraries(${TEST_EXE} libpingus)
endforeach(TEST_SOURCE)
file(GLOB PINGUS_UTIL_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
test/*_util.cpp)
foreach(UTIL_SOURCE ${PINGUS_UTIL_SOURCES_CXX})
string(REGEX REPLACE ".*/\([^/]*\).cpp" "\\1" UTIL_EXE ${UTIL_SOURCE})
add_executable(${UTIL_EXE} ${UTIL_SOURCE})
set_target_properties(${UTIL_EXE} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "test/")
target_compile_options(${UTIL_EXE} PRIVATE ${TINYCMMC_WARNINGS_CXX_FLAGS})
target_link_libraries(${UTIL_EXE} libpingus)
endforeach(UTIL_SOURCE)
file(GLOB TEST_PINGUS_SOURCES_CXX RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
tests/*_test.cpp)
add_executable(test_pingus ${TEST_PINGUS_SOURCES_CXX})
target_include_directories(test_pingus PUBLIC src/ tests/)
target_link_libraries(test_pingus libpingus GTest::GTest GTest::Main ${CMAKE_THREAD_LIBS_INIT})
target_compile_options(test_pingus PRIVATE ${TINYCMMC_WARNINGS_CXX_FLAGS})
add_test(NAME test_pingus
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND test_pingus)
add_test(NAME test_pingus_desktop
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND desktop-file-validate pingus.desktop)
endif(BUILD_TESTS)
if(WIN32)
install(TARGETS pingus
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
else()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/pingus.sh.in
${CMAKE_BINARY_DIR}/pingus.sh)
install(TARGETS pingus
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
install(FILES
${CMAKE_BINARY_DIR}/pingus.sh
RENAME pingus
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(DIRECTORY data/ DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
PATTERN "*~" EXCLUDE)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/doc/man/pingus.6
DESTINATION ${CMAKE_INSTALL_MANDIR}/man6)
install(FILES
pingus.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
install(DIRECTORY data/icons/
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons)
# EOF #