-
-
Notifications
You must be signed in to change notification settings - Fork 95
/
CMakeLists.txt
420 lines (365 loc) · 19.9 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
####################################################################################################
# TGUI - Texus' Graphical User Interface
# Copyright (C) 2012-2024 Bruno Van de Velde ([email protected])
#
# This software is provided 'as-is', without any express or implied warranty.
# In no event will the authors be held liable for any damages arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it freely,
# subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented;
# you must not claim that you wrote the original software.
# If you use this software in a product, an acknowledgment
# in the product documentation would be appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such,
# and must not be misrepresented as being the original software.
#
# 3. This notice may not be removed or altered from any source distribution.
####################################################################################################
# If the cmake version is higher than the minimum version then enable all new policies, up to the maximum version specified.
# When cmake is newer than the highest version then its newest policies will still be set to the old behavior for compatibility.
cmake_minimum_required(VERSION 3.16...3.29)
# Include macros such as tgui_set_option
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Macros.cmake)
# Set a default build type
tgui_set_option(CMAKE_BUILD_TYPE Release STRING "Choose the type of build (Debug or Release)")
# Project name and version
project(TGUI VERSION 1.6.1 LANGUAGES CXX)
# Use the paths from the cmake GNUInstallDirs module as defaults (https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html)
include(GNUInstallDirs)
# Include the configuration file which identifies the OS and compiler
include(${PROJECT_SOURCE_DIR}/cmake/Config.cmake)
if(TGUI_OS_IOS)
# SFML 2 doesn't detect iOS in SFMLConfigDependencies.cmake when CMAKE_SYSTEM_NAME isn't "Darwin",
# but luckily they don't have an error case so we just manually set the option about which OS was detected.
# This hack is no longer needed for SFML 3.
set(FIND_SFML_OS_IOS 1)
endif()
# Add the modules directory to find some of the dependencies
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules")
# When building for Android, we install everything in $NDK/sources/third_party by default.
# The CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT variable is only TRUE on the first run,
# so this code needs to be before the backend selection (or any other code that can fail).
if(TGUI_OS_ANDROID AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_ANDROID_NDK}/sources/third_party/tgui CACHE PATH "Installation path (should be inside your NDK's 'sources' directory)" FORCE)
endif()
# Add an option for choosing the build type (shared or static)
if(TGUI_OS_ANDROID)
set(TGUI_SHARED_LIBS TRUE)
else()
# If TGUI_SHARED_LIBS is explicitly set then it overrules BUILD_SHARED_LIBS, otherwise honor the global setting
if(NOT DEFINED TGUI_SHARED_LIBS)
if(NOT DEFINED BUILD_SHARED_LIBS)
option(BUILD_SHARED_LIBS "ON to build a shared (dynamic) library, OFF to build a static library" ON)
endif()
set(TGUI_SHARED_LIBS ${BUILD_SHARED_LIBS})
endif()
endif()
# Use c++17 by default on GCC >= 11, Clang >= 16 and IntelLLVM
if ((TGUI_COMPILER_GCC AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "11")
OR (TGUI_COMPILER_LLVM_CLANG AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "16")
OR TGUI_COMPILER_INTEL_ONEAPI)
set(TGUI_DEFAULT_CXX_STANDARD "17")
else() # Use c++14 by default on all other compilers
set(TGUI_DEFAULT_CXX_STANDARD "14")
endif()
tgui_set_option(TGUI_CXX_STANDARD ${TGUI_DEFAULT_CXX_STANDARD} STRING "C++ standard version to build TGUI with. Possible values: 14, 17, 20 or 23. Projects using TGUI must use a c++ version equal or higher to this")
# At least c++14 has to be used
if(TGUI_CXX_STANDARD LESS "14")
message(FATAL_ERROR "TGUI_CXX_STANDARD has to be at least 14")
endif()
if(TGUI_BACKEND)
set(backend_provided TRUE)
endif()
# Construct a list of supported backends based on the platform
set(TGUI_BACKEND_OPTIONS "")
set(TGUI_BACKEND_OPTIONS_DESC "")
if(TGUI_OS_WINDOWS OR TGUI_OS_LINUX OR TGUI_OS_MACOS OR TGUI_OS_ANDROID OR TGUI_OS_IOS)
list(APPEND TGUI_BACKEND_OPTIONS SFML_GRAPHICS)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - SFML_GRAPHICS: sfml-graphics\n")
endif()
if(TGUI_OS_WINDOWS OR TGUI_OS_LINUX OR TGUI_OS_MACOS)
list(APPEND TGUI_BACKEND_OPTIONS SFML_OPENGL3)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - SFML_OPENGL3: sfml-window + OpenGL + FreeType\n")
endif()
if(TGUI_OS_WINDOWS OR TGUI_OS_LINUX OR TGUI_OS_MACOS OR TGUI_OS_ANDROID OR TGUI_OS_IOS)
list(APPEND TGUI_BACKEND_OPTIONS SDL_RENDERER)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - SDL_RENDERER: SDL2 + SDL_ttf\n")
endif()
if(TGUI_OS_WINDOWS OR TGUI_OS_LINUX OR TGUI_OS_MACOS)
list(APPEND TGUI_BACKEND_OPTIONS SDL_OPENGL3)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - SDL_OPENGL3: SDL2 + OpenGL + FreeType\n")
endif()
if(TGUI_OS_LINUX)
list(APPEND TGUI_BACKEND_OPTIONS SDL_GLES2)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - SDL_GLES2: SDL2 + OpenGL ES + FreeType\n")
endif()
if(TGUI_OS_WINDOWS OR TGUI_OS_LINUX OR TGUI_OS_MACOS)
list(APPEND TGUI_BACKEND_OPTIONS SDL_TTF_OPENGL3)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - SDL_TTF_OPENGL3: SDL2 + OpenGL + SDL2_ttf\n")
endif()
if(TGUI_OS_LINUX OR TGUI_OS_ANDROID OR TGUI_OS_IOS)
list(APPEND TGUI_BACKEND_OPTIONS SDL_TTF_GLES2)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - SDL_TTF_GLES2: SDL2 + OpenGL ES + SDL2_ttf\n")
endif()
if(TGUI_OS_WINDOWS OR TGUI_OS_LINUX OR TGUI_OS_MACOS)
list(APPEND TGUI_BACKEND_OPTIONS GLFW_OPENGL3)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - GLFW_OPENGL3: GLFW + OpenGL + FreeType\n")
endif()
if(TGUI_OS_LINUX)
list(APPEND TGUI_BACKEND_OPTIONS GLFW_GLES2)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - GLFW_GLES2: GLFW + OpenGL ES + FreeType\n")
endif()
if(TGUI_OS_WINDOWS OR TGUI_OS_LINUX OR TGUI_OS_MACOS)
list(APPEND TGUI_BACKEND_OPTIONS RAYLIB)
string(APPEND TGUI_BACKEND_OPTIONS_DESC " - RAYLIB: raylib\n")
endif()
tgui_set_option(TGUI_BACKEND SFML_GRAPHICS STRING "Select a backend for rendering or select Custom to use multiple or no backends")
set_property(CACHE TGUI_BACKEND PROPERTY STRINGS Custom;${TGUI_BACKEND_OPTIONS})
if(NOT backend_provided)
message(FATAL_ERROR
" Please select a backend by setting the value of TGUI_BACKEND.\n"
" \n"
" The following backends are available:\n"
${TGUI_BACKEND_OPTIONS_DESC}
" \n"
" SFML_GRAPHICS is the default and has been preselected, press configure again to continue with this backend.\n"
" Select 'Custom' if you wish to build TGUI with multiple or no backends.\n")
endif()
string(TOUPPER "${TGUI_BACKEND}" TGUI_BACKEND_UPPERCASE)
# Add an option to build TGUI as a c++20 module (when using CMake >= 3.28)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
# We currently don't create the option as it is still too experimental,
# it can still be used if the user manually specifies the option though.
#option(TGUI_BUILD_AS_CXX_MODULE "ON to build TGUI as a c++20 module instead of using header files" OFF)
#mark_as_advanced(TGUI_BUILD_AS_CXX_MODULE)
if(TGUI_BUILD_AS_CXX_MODULE)
if(TGUI_CXX_STANDARD LESS 20)
message(FATAL_ERROR "TGUI_BUILD_AS_CXX_MODULE can only be turned on if TGUI_CXX_STANDARD is set to at least 20")
endif()
endif()
endif()
# Define an option for choosing between static and dynamic C runtime
if(TGUI_OS_WINDOWS)
option(TGUI_USE_STATIC_STD_LIBS "TRUE to statically link to the standard libraries, FALSE to use the standard libraries as DLLs. This is NOT the option that you need to build TGUI statically, for that you just need to set TGUI_SHARED_LIBS to FALSE." FALSE)
mark_as_advanced(TGUI_USE_STATIC_STD_LIBS)
# Building TGUI as a dynamic library but linking statically to the standard library is not valid
if(TGUI_SHARED_LIBS AND TGUI_USE_STATIC_STD_LIBS)
message(FATAL_ERROR "TGUI_SHARED_LIBS and TGUI_USE_STATIC_STD_LIBS cannot be used together, you can only link statically to the standard library when TGUI is also build statically")
endif()
endif()
if(TGUI_OS_WINDOWS AND TGUI_COMPILER_MSVC AND (CMAKE_GENERATOR MATCHES "Visual Studio"))
option(TGUI_USE_MULTI_PROCESSOR_COMPILATION "Use /MP to speed up compilation of the TGUI library by using all cores" ON)
endif()
# Apple-specific options
if(TGUI_OS_MACOS OR TGUI_OS_IOS)
# Add an option to build framework instead of dylib (release only)
option(TGUI_BUILD_FRAMEWORK "TRUE to build TGUI as a framework library (release only), FALSE to build according to TGUI_SHARED_LIBS" ${TGUI_SHARED_LIBS})
if (TGUI_OS_IOS AND TGUI_SHARED_LIBS AND NOT TGUI_BUILD_FRAMEWORK)
message(FATAL_ERROR "Naked dynamic libs not supported for iOS, build static or frameworks instead")
endif()
if(TGUI_BUILD_FRAMEWORK)
# Frameworks are only available for release (because cmake currently doesn't allow specifying a custom framework name so TGUI-d is not possible)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
message(FATAL_ERROR "CMAKE_BUILD_TYPE should be \"Release\" when TGUI_BUILD_FRAMEWORK is TRUE")
return()
endif()
# Frameworks only work with TGUI_SHARED_LIBS enabled
if(NOT TGUI_SHARED_LIBS)
message(FATAL_ERROR "TGUI_SHARED_LIBS should be TRUE when TGUI_BUILD_FRAMEWORK is TRUE")
return()
endif()
endif()
endif()
# Android-specific options
if(TGUI_OS_ANDROID)
if(CMAKE_ANDROID_API LESS 19)
message(FATAL_ERROR "Android API level (${CMAKE_ANDROID_API}) must be equal or greater than 19.")
endif()
# We install libs in a subdirectory named after the ABI (e.g. lib/armeabi/libtgui.so)
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${CMAKE_ANDROID_ARCH_ABI}")
endif()
# Add an option to choose whether PDB debug symbols should be generated for Visual Studio
if(TGUI_COMPILER_MSVC)
option(TGUI_GENERATE_PDB "True to generate PDB debug symbols, FALSE otherwise." TRUE)
endif()
# Set the path for the libraries
set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")
# Don't create an install target if we detect a dependency that is being build without an install target
if (NOT DEFINED TGUI_INSTALL)
if ((DEFINED SDL2_DISABLE_INSTALL AND SDL2_DISABLE_INSTALL)
OR (DEFINED SDL_DISABLE_INSTALL AND SDL_DISABLE_INSTALL)
OR (DEFINED SDL2TTF_INSTALL AND NOT SDL2TTF_INSTALL)
OR (DEFINED SDL3TTF_INSTALL AND NOT SDL3TTF_INSTALL)
OR (DEFINED GLFW_INSTALL AND NOT GLFW_INSTALL))
set(TGUI_INSTALL OFF)
else()
set(TGUI_INSTALL ON)
endif()
endif()
# Define the macros to link TGUI to its dependencies
include(${PROJECT_SOURCE_DIR}/cmake/Dependencies.cmake)
# Set up the TGUI library
add_subdirectory(src)
# If system dependencies are used instead of the headers from the extlibs directory then locate the header files
if(TGUI_USE_SYSTEM_STB)
find_path(TGUI_SYSTEM_STB_IMAGE_INCLUDE_DIR stb_image.h REQUIRED)
target_include_directories(tgui SYSTEM PRIVATE "${TGUI_SYSTEM_STB_IMAGE_INCLUDE_DIR}")
find_path(TGUI_SYSTEM_STB_IMAGE_WRITE_INCLUDE_DIR stb_image_write.h REQUIRED)
target_include_directories(tgui SYSTEM PRIVATE "${TGUI_SYSTEM_STB_IMAGE_WRITE_INCLUDE_DIR}")
endif()
if(TGUI_USE_SYSTEM_NANOSVG)
find_path(TGUI_SYSTEM_NANOSVG_INCLUDE_DIR nanosvg.h REQUIRED)
target_include_directories(tgui SYSTEM PRIVATE "${TGUI_SYSTEM_NANOSVG_INCLUDE_DIR}")
find_path(TGUI_SYSTEM_NANOSVG_RAST_INCLUDE_DIR nanosvgrast.h REQUIRED)
target_include_directories(tgui SYSTEM PRIVATE "${TGUI_SYSTEM_NANOSVG_RAST_INCLUDE_DIR}")
endif()
if(TGUI_USE_SYSTEM_GLAD)
find_package(glad CONFIG REQUIRED)
target_link_libraries(tgui PRIVATE glad::glad)
endif()
# Create an interface to create a console app that uses TGUI (used to build the tests)
add_library(tgui-console-app-interface INTERFACE)
target_link_libraries(tgui-console-app-interface INTERFACE tgui)
if(TGUI_DEFAULT_BACKEND STREQUAL "SFML_GRAPHICS" OR TGUI_DEFAULT_BACKEND STREQUAL "SFML_OPENGL3")
if(TGUI_OS_IOS)
tgui_find_dependency_sfml(Main QUIET)
if (${SFML_VERSION} VERSION_GREATER_EQUAL 3)
target_link_libraries(tgui-console-app-interface INTERFACE SFML::Main)
else()
target_link_libraries(tgui-console-app-interface INTERFACE sfml-main)
endif()
endif()
elseif(TGUI_DEFAULT_BACKEND STREQUAL "SDL_RENDERER"
OR TGUI_DEFAULT_BACKEND STREQUAL "SDL_OPENGL3" OR TGUI_DEFAULT_BACKEND STREQUAL "SDL_GLES2"
OR TGUI_DEFAULT_BACKEND STREQUAL "SDL_TTF_OPENGL3" OR TGUI_DEFAULT_BACKEND STREQUAL "SDL_TTF_GLES2")
tgui_find_dependency_sdl()
if (NOT TGUI_USE_SDL3 AND TARGET SDL2::SDL2main) # This target is only required on Windows or iOS
target_link_libraries(tgui-console-app-interface INTERFACE SDL2::SDL2main)
endif()
elseif(TGUI_DEFAULT_BACKEND STREQUAL "GLFW_OPENGL3" OR TGUI_DEFAULT_BACKEND STREQUAL "GLFW_GLES2" OR TGUI_DEFAULT_BACKEND STREQUAL "RAYLIB")
# We don't have to do anything for console apps when using GLFW or raylib as they assumes a normal main function
endif()
# Create an interface to create a graphical app that uses TGUI (used to build the examples and Gui Builder)
add_library(tgui-gui-app-interface INTERFACE)
target_link_libraries(tgui-gui-app-interface INTERFACE tgui)
if(TGUI_DEFAULT_BACKEND STREQUAL "SFML_GRAPHICS" OR TGUI_DEFAULT_BACKEND STREQUAL "SFML_OPENGL3")
if(TGUI_OS_WINDOWS OR TGUI_OS_IOS)
tgui_find_dependency_sfml(Main QUIET)
if (SFML_VERSION VERSION_GREATER_EQUAL 3)
target_link_libraries(tgui-gui-app-interface INTERFACE SFML::Main)
else()
target_link_libraries(tgui-gui-app-interface INTERFACE sfml-main)
endif()
endif()
elseif(TGUI_DEFAULT_BACKEND STREQUAL "SDL_RENDERER"
OR TGUI_DEFAULT_BACKEND STREQUAL "SDL_OPENGL3" OR TGUI_DEFAULT_BACKEND STREQUAL "SDL_GLES2"
OR TGUI_DEFAULT_BACKEND STREQUAL "SDL_TTF_OPENGL3" OR TGUI_DEFAULT_BACKEND STREQUAL "SDL_TTF_GLES2")
tgui_find_dependency_sdl()
if (NOT TGUI_USE_SDL3 AND TARGET SDL2::SDL2main) # This target is only required on Windows or iOS
target_link_libraries(tgui-gui-app-interface INTERFACE SDL2::SDL2main)
endif()
elseif(TGUI_DEFAULT_BACKEND STREQUAL "GLFW_OPENGL3" OR TGUI_DEFAULT_BACKEND STREQUAL "GLFW_GLES2" OR TGUI_DEFAULT_BACKEND STREQUAL "RAYLIB")
if(TGUI_OS_WINDOWS)
if(TGUI_COMPILER_MSVC OR TGUI_COMPILER_CLANG_CL)
target_link_options(tgui-gui-app-interface INTERFACE "/ENTRY:mainCRTStartup" "/SUBSYSTEM:WINDOWS")
elseif(TGUI_COMPILER_LLVM_CLANG OR TGUI_COMPILER_INTEL_ONEAPI)
target_link_options(tgui-gui-app-interface INTERFACE "LINKER:/ENTRY:mainCRTStartup,/SUBSYSTEM:WINDOWS")
else()
target_link_options(tgui-gui-app-interface INTERFACE "-mwindows")
endif()
endif()
endif()
# Define the install directory for miscellaneous files
if(TGUI_OS_WINDOWS OR TGUI_OS_IOS)
set(DEFAULT_INSTALL_MISC_DIR .)
elseif(TGUI_OS_ANDROID)
set(DEFAULT_INSTALL_MISC_DIR ${CMAKE_ANDROID_NDK}/sources/third_party/tgui)
else()
set(DEFAULT_INSTALL_MISC_DIR ${CMAKE_INSTALL_DATAROOTDIR}/tgui-${TGUI_VERSION_MAJOR})
endif()
tgui_set_option(TGUI_MISC_INSTALL_PREFIX "${DEFAULT_INSTALL_MISC_DIR}" PATH "Prefix installation path for miscellaneous files")
mark_as_advanced(TGUI_MISC_INSTALL_PREFIX)
# Optionally build the GUI Builder
if(NOT TGUI_OS_IOS AND NOT TGUI_OS_ANDROID)
tgui_assign_bool(TGUI_DEFAULT_BUILD_GUI_BUILDER TGUI_DEFAULT_BACKEND)
option(TGUI_BUILD_GUI_BUILDER "TRUE to build the GUI Builder" ${TGUI_DEFAULT_BUILD_GUI_BUILDER})
if(TGUI_BUILD_GUI_BUILDER)
add_subdirectory("${PROJECT_SOURCE_DIR}/gui-builder")
endif()
endif()
# Optionally build the examples
if(NOT TGUI_OS_ANDROID)
option(TGUI_BUILD_EXAMPLES "TRUE to build the TGUI examples, FALSE to ignore them" FALSE)
if(TGUI_BUILD_EXAMPLES)
if(TGUI_BUILD_AS_CXX_MODULE)
message(FATAL_ERROR "Examples don't support c++20 modules. Turn off either TGUI_BUILD_AS_CXX_MODULE or TGUI_BUILD_EXAMPLES.")
endif()
add_subdirectory(examples)
endif()
endif()
# Optionally build the tests
if(NOT TGUI_OS_IOS AND NOT TGUI_OS_ANDROID)
option(TGUI_BUILD_TESTS "TRUE to build the TGUI tests" FALSE)
if(TGUI_BUILD_TESTS)
add_subdirectory(tests)
endif()
endif()
# Optionally build the documentation
option(TGUI_BUILD_DOC "TRUE to generate the API documentation, FALSE to ignore it" FALSE)
if(TGUI_BUILD_DOC)
add_subdirectory(doc)
endif()
if (TGUI_INSTALL)
# Install pkg-config files by default on Linux (and BSD)
tgui_assign_bool(TGUI_INSTALL_PKGCONFIG_DEFAULT TGUI_OS_LINUX)
option(TGUI_INSTALL_PKGCONFIG_FILES "TRUE to automatically install pkg-config files so other projects can find TGUI" ${TGUI_INSTALL_PKGCONFIG_DEFAULT})
if (TGUI_INSTALL_PKGCONFIG_FILES)
if (TGUI_OS_BSD)
set(default_pkgconfig_dir "libdata/pkgconfig")
else()
set(default_pkgconfig_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()
tgui_set_option(TGUI_PKGCONFIG_INSTALL_DIR "${default_pkgconfig_dir}" PATH "Install directory for TGUI's pkg-config .pc file")
configure_file("cmake/pkgconfig/tgui.pc.in" "pkgconfig/tgui.pc" @ONLY)
if (TGUI_PKGCONFIG_INSTALL_PREFIX)
message(WARNING "TGUI_PKGCONFIG_INSTALL_PREFIX is deprecated, use TGUI_PKGCONFIG_INSTALL_DIR instead (which is a relative instead of an absolute path by default)")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/tgui.pc" DESTINATION "${TGUI_PKGCONFIG_INSTALL_PREFIX}")
else()
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkgconfig/tgui.pc" DESTINATION "${TGUI_PKGCONFIG_INSTALL_DIR}")
endif()
endif()
# Install include files
if(NOT TGUI_BUILD_FRAMEWORK)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT devel
PATTERN "*.in" EXCLUDE)
endif()
# Install PDB file
if(TGUI_GENERATE_PDB)
# When using a Visual Studio generator, the pdb files are located in Debug and RelWithDebInfo subfolders, but not when
# using single-configuration generators such as NMake Makefiles.
# When using Linker PDB files (i.e. TGUI_SHARED_LIBS=FALSE), CMake 3.13 introduced a generator expression that helps us.
# Linker PDB files are installed next to the dll file (where VS searches them) while compiler PDB files are placed next to the lib file.
if(TGUI_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:tgui> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL COMPONENT devel)
else()
# TODO: Find a reliable way to know whether the file has a "-d" postfix instead of trying to install both. OPTIONAL is also required when config is Release.
if (MSVC_IDE)
install(FILES "${PROJECT_BINARY_DIR}/lib/\${CMAKE_INSTALL_CONFIG_NAME}/tgui-s.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL)
install(FILES "${PROJECT_BINARY_DIR}/lib/\${CMAKE_INSTALL_CONFIG_NAME}/tgui-s-d.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL)
else()
install(FILES "${PROJECT_BINARY_DIR}/lib/tgui-s.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL)
install(FILES "${PROJECT_BINARY_DIR}/lib/tgui-s-d.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel OPTIONAL)
endif()
endif()
endif()
# Install miscellaneous files
install(FILES license.txt DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(DIRECTORY themes DESTINATION "${TGUI_MISC_INSTALL_PREFIX}")
endif()