-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
97 lines (80 loc) · 3.15 KB
/
CMakeLists.txt
File metadata and controls
97 lines (80 loc) · 3.15 KB
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
#
# Copyright (c) 2015 Pavlo Lavrenenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
cmake_minimum_required(VERSION 3.5)
project(MAINUI)
set(CMAKE_CXX_STANDARD 11)
option(MAINUI_USE_CUSTOM_FONT_RENDER "Use custom font rendering" ON)
option(MAINUI_USE_STB "Use stb_truetype.h for rendering(*nix-only)" OFF)
option(MAINUI_FONT_SCALE "Scale fonts by height" OFF)
if(NOT XASH_SDK)
set(XASH_SDK "sdk_includes/")
endif()
file(GLOB MAINUI_CONTROLS_SOURCES "controls/*.cpp")
file(GLOB MAINUI_MENUS_SOURCES "menus/*.cpp" "menus/dynamic/*.cpp")
file(GLOB MAINUI_FONT_RENDER_SOURCES "font/*.cpp")
file(GLOB MAINUI_SOURCES "miniutl/*.cpp" "*.cpp")
add_library(menu SHARED ${MAINUI_CONTROLS_SOURCES} ${MAINUI_MENUS_SOURCES} ${MAINUI_FONT_RENDER_SOURCES} ${MAINUI_SOURCES})
if(NOT WIN32 AND NOT MINGW)
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-variable)
endif()
if(MAINUI_FONT_SCALE)
add_definitions(-DMAINUI_FONT_SCALE)
endif()
add_definitions(-DSTDINT_H=<cstdint>)
# Android uses stb_truetype by default for rendering fonts
if(ANDROID)
set(MAINUI_USE_STB TRUE)
endif()
include_directories(${XASH_SDK}/common ${XASH_SDK}/engine ${XASH_SDK}/pm_shared ${XASH_SDK}/public . controls/ menus/ miniutl/ font/ model/)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
# Font Rendering(FreeType or WinAPI)
if(MAINUI_USE_CUSTOM_FONT_RENDER)
# Win32 will always use GDI font renderer
if(NOT WIN32)
if(MAINUI_USE_STB)
# Use stbtt
add_definitions(-DMAINUI_USE_STB)
else()
# Use freetype2
find_package(PkgConfig)
pkg_check_modules(FT2 REQUIRED freetype2)
include_directories(${FT2_INCLUDE_DIRS})
target_link_libraries(menu ${FT2_LIBRARIES})
add_definitions(-DMAINUI_USE_FREETYPE)
endif()
endif()
add_definitions(-DMAINUI_USE_CUSTOM_FONT_RENDER)
endif()
if(NOT BUILD_AS_PART_OF_ENGINE)
# grab platform library suffix
set_target_postfix(menu)
else()
# install to the same directory as engine
set(GAMEDIR ".")
set(CLIENT_INSTALL_DIR ".")
endif()
install(TARGETS menu DESTINATION "${GAMEDIR}/${CLIENT_INSTALL_DIR}")
if(MSVC)
install(FILES $<TARGET_PDB_FILE:menu> DESTINATION "${GAMEDIR}/${CLIENT_INSTALL_DIR}" OPTIONAL)
endif()