-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
147 lines (125 loc) · 4.31 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
# Windstille - A Sci-Fi Action-Adventure Game
# Copyright (C) 2015 Ingo Ruhnke <grumbel@gmail.com>
#
# 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(wstgui VERSION 0.3.0)
set(TINYCMMC_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/external/tinycmmc/modules/")
find_package(tinycmmc CONFIG)
message(STATUS "tinycmmc module path: ${TINYCMMC_MODULE_PATH}")
list(APPEND CMAKE_MODULE_PATH ${TINYCMMC_MODULE_PATH})
include(GetProjectVersion)
include(GNUInstallDirs)
include(ClangTidy)
include(MaximumWarnings)
find_package(PkgConfig REQUIRED)
pkg_search_module(SDL2 REQUIRED sdl2 IMPORTED_TARGET)
pkg_search_module(SIGCXX REQUIRED sigc++-2.0 IMPORTED_TARGET)
# Build dependencies
function(build_dependencies)
set(BUILD_TESTS OFF)
set(BUILD_EXTRA OFF)
find_package(sexp QUIET)
if(NOT TARGET sexp::sexp)
add_subdirectory(external/sexpcpp/ EXCLUDE_FROM_ALL)
endif()
find_package(babyxml QUIET)
if(NOT TARGET babyxml::babyxml)
add_subdirectory(external/babyxml/ EXCLUDE_FROM_ALL)
endif()
find_package(logmich QUIET)
if(NOT TARGET logmich::logmich)
add_subdirectory(external/logmich/ EXCLUDE_FROM_ALL)
endif()
find_package(geom QUIET)
if(NOT TARGET geom::geom)
add_subdirectory(external/geomcpp/ EXCLUDE_FROM_ALL)
endif()
find_package(prio QUIET)
if(NOT TARGET prio::prio)
add_subdirectory(external/priocpp/ EXCLUDE_FROM_ALL)
endif()
find_package(surf QUIET)
if(NOT TARGET surf::surf)
add_subdirectory(external/surfcpp/ EXCLUDE_FROM_ALL)
endif()
find_package(wstdisplay QUIET)
if(NOT TARGET wstdisplay::wstdisplay)
add_subdirectory(external/wstdisplay/ EXCLUDE_FROM_ALL)
endif()
find_package(wstinput QUIET)
if(NOT TARGET wstinput::wstinput)
add_subdirectory(external/wstinput/ EXCLUDE_FROM_ALL)
endif()
find_package(wstsound QUIET)
if(NOT TARGET wstsound::wstsound)
add_subdirectory(external/wstsound/ EXCLUDE_FROM_ALL)
endif()
endfunction()
build_dependencies()
file(GLOB WSTGUI_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
include/wstgui/*.hpp)
file(GLOB WSTGUI_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
src/*.cpp)
add_library(wstgui STATIC ${WSTGUI_SOURCES})
set_target_properties(wstgui PROPERTIES PUBLIC_HEADER "${WSTGUI_HEADERS}")
target_compile_options(wstgui PUBLIC ${WARNINGS_CXX_FLAGS})
set_target_properties(wstgui PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
target_include_directories(wstgui SYSTEM PUBLIC ${OPENAL_INCLUDE_DIR})
target_include_directories(wstgui PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_include_directories(wstgui PRIVATE
src/
include/wstgui/
)
target_link_libraries(wstgui PUBLIC
wstinput::wstinput
wstsound::wstsound
geom::geom
prio::prio
PkgConfig::SIGCXX
PkgConfig::SDL2
wstdisplay::wstdisplay
)
if(CWIID_LIBRARY)
target_compile_options(wstgui PUBLIC -DHAVE_CWIID)
target_link_libraries(wstgui ${CWIID_LIBRARY})
endif()
install(TARGETS wstgui
EXPORT wstgui-targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
if(BUILD_EXTRA)
file(GLOB EXTRA_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
extra/*.cpp)
foreach(SRC ${EXTRA_SOURCES})
get_filename_component(SRC_BASENAME ${SRC} NAME_WE)
add_executable("${SRC_BASENAME}_exe" ${SRC})
set_target_properties("${SRC_BASENAME}_exe" PROPERTIES
OUTPUT_NAME "${SRC_BASENAME}"
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
target_link_libraries("${SRC_BASENAME}_exe" wstgui)
install(TARGETS "${SRC_BASENAME}_exe"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endforeach(SRC)
endif()
include(ExportAndInstallLibrary)
# EOF #