forked from codereader/DarkRadiant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
174 lines (147 loc) · 5.42 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
cmake_minimum_required(VERSION 3.12)
# Project name and version
project(radianteditor VERSION 3.9.0)
# C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# GCC 8 and earlier require explicit linking against stdc++fs
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
link_libraries(stdc++fs)
endif()
# Expose some build options
option(ENABLE_RELOCATION
"Avoid hard-coded absolute paths to libraries or resources"
ON)
# Define GNU-style directory structure by default
include(GNUInstallDirs)
# Set up core build paths
set(CORE_MODULE_LIBRARY "libradiantcore")
set(PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/radianteditor")
set(PKGLIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}/radianteditor")
if (${ENABLE_RELOCATION})
set(RELATIVE_LIBDIR "../${CMAKE_INSTALL_LIBDIR}/radianteditor")
else()
set(HTMLDIR "${CMAKE_INSTALL_FULL_DATADIR}/doc/radianteditor")
endif()
# Build shared libraries by default
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
if (${ENABLE_RELOCATION})
set(CMAKE_INSTALL_RPATH "$ORIGIN/${RELATIVE_LIBDIR}")
else()
set(CMAKE_INSTALL_RPATH "${PKGLIBDIR}")
endif()
# Debug or release mode
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
add_compile_definitions(
$<$<CONFIG:Debug>:_DEBUG>
$<$<CONFIG:Release>:NDEBUG>
)
# Locate system packages
include(FindPkgConfig)
pkg_check_modules(SIGC sigc++-2.0 REQUIRED)
pkg_check_modules(FTGL ftgl REQUIRED)
pkg_check_modules(FREETYPE freetype2 REQUIRED)
pkg_check_modules(GL gl REQUIRED)
pkg_check_modules(GLEW glew REQUIRED)
pkg_check_modules(JPEG libjpeg REQUIRED)
pkg_check_modules(PNG libpng REQUIRED)
pkg_check_modules(AL openal REQUIRED)
pkg_check_modules(OGG ogg REQUIRED)
pkg_check_modules(VORBIS vorbisfile REQUIRED)
pkg_check_modules(X11 x11 REQUIRED)
pkg_check_modules(ZLIB zlib REQUIRED)
pkg_check_modules(GLIB glib-2.0 REQUIRED)
pkg_check_modules(EIGEN eigen3 REQUIRED)
# Locate wxWidgets
find_package(wxWidgets REQUIRED
COMPONENTS base core stc adv gl xrc aui)
include(${wxWidgets_USE_FILE})
# Locate Python
find_package(Python REQUIRED COMPONENTS Development)
# Global includes and flags
include_directories(libs libs/libfmt include)
add_compile_options(${SIGC_CFLAGS})
add_compile_definitions(POSIX
WXINTL_NO_GETTEXT_MACRO
FMT_HEADER_ONLY
HAVE_STD_FILESYSTEM)
add_link_options(LINKER:-z,defs)
# Generate config.h
configure_file(config.h.in config.h)
add_compile_definitions(HAVE_CONFIG_H)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Supporting libraries
add_subdirectory(libs/math)
add_subdirectory(libs/xmlutil)
add_subdirectory(libs/scene)
add_subdirectory(libs/wxutil)
add_subdirectory(libs/module)
# Mandatory modules
add_subdirectory(plugins/script)
add_subdirectory(plugins/sound)
pkg_check_modules(LIBGIT libgit2)
if (${LIBGIT_FOUND})
add_subdirectory(plugins/vcs)
endif()
# Main radiant components
add_subdirectory(radiantcore)
add_subdirectory(radiant)
# Tests
pkg_check_modules(GTEST gtest)
pkg_check_modules(GTEST_MAIN gtest_main)
if (${GTEST_FOUND} AND ${GTEST_MAIN_FOUND})
include(CTest)
add_subdirectory(test)
endif()
# Documentation
find_program(ASCIIDOCTOR asciidoctor)
if (ASCIIDOCTOR)
add_subdirectory(doc)
else()
message(WARNING "asciidoctor not found; documentation will not be generated")
endif()
# Install main targets
install(TARGETS darkradiant math xmlutil scenegraph wxutil
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${PKGLIBDIR})
install(TARGETS radiantcore script sound
LIBRARY DESTINATION ${PKGLIBDIR}/modules)
if (${LIBGIT_FOUND})
install(TARGETS vcs
LIBRARY DESTINATION ${PKGLIBDIR}/plugins)
endif()
# Generate and install the .desktop file
configure_file(install/radianteditor.desktop install/radiant.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/install/radiant.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
# Install resources
file(GLOB XML_FILES "${PROJECT_SOURCE_DIR}/install/*.xml")
install(FILES ${XML_FILES} DESTINATION ${PKGDATADIR})
install(DIRECTORY install/games DESTINATION ${PKGDATADIR})
install(DIRECTORY install/bitmaps DESTINATION ${PKGDATADIR})
install(DIRECTORY install/gl DESTINATION ${PKGDATADIR})
install(DIRECTORY install/ui DESTINATION ${PKGDATADIR}
FILES_MATCHING PATTERN "*.ttf" PATTERN "*.xrc")
install(DIRECTORY install/resources DESTINATION ${PKGDATADIR})
install(FILES ${PROJECT_SOURCE_DIR}/install/bitmaps/radianteditor_icon_64x64.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/64x64/apps
RENAME net.radianteditor.RadiantEditor.png)
install(FILES ${PROJECT_SOURCE_DIR}/install/bitmaps/radianteditor_icon_128x128.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps
RENAME net.radianteditor.RadiantEditor.png)
install(FILES ${PROJECT_SOURCE_DIR}/install/net.radianteditor.RadiantEditor.metainfo
DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
# Install locale data
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14")
# CMake 3.14 and above support TYPE LOCALE, they deduct DESTINATION themselves
install(DIRECTORY install/i18n/de TYPE LOCALE
FILES_MATCHING PATTERN "*.mo")
else()
install(DIRECTORY install/i18n/de DESTINATION ${CMAKE_INSTALL_LOCALEDIR}
FILES_MATCHING PATTERN "*.mo")
endif()
# Install scripts
install(DIRECTORY install/scripts DESTINATION ${PKGDATADIR}
FILES_MATCHING PATTERN "*.py")