-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
135 lines (107 loc) · 3.34 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
cmake_minimum_required(VERSION 3.12)
# Project
project(mrvnradiant VERSION 0.0)
# Options
option(BUILD_PLUGINS "Build plugins" ON)
option(BUILD_RADIANT "Build radiant" ON)
option(BUILD_TOOLS "Build tools" ON)
option(INSTALL_DLLS "Install DLLs" OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Why are you trying to do this on linux
if(NOT WIN32)
set(INSTALL_DLLS OFF)
endif()
# Install dlls is separate from the build process
if(INSTALL_DLLS)
set(BUILD_PLUGINS OFF)
set(BUILD_RADIANT OFF)
set(BUILD_TOOLS OFF)
endif()
# Github actions moment
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
# Build system setup
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Compile flags
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_C_FLAGS_RELEASE "")
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
add_compile_definitions(RADIANT_EXECUTABLE="")
add_compile_definitions(POSIX)
add_compile_definitions(XWINDOWS)
endif()
if(WIN32)
add_compile_definitions(RADIANT_EXECUTABLE=".exe")
add_compile_definitions(WIN32)
add_compile_definitions(_WIN32)
endif()
if(${MSVC})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO")
endif()
# Debug
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_compile_definitions(_DEBUG)
else()
add_compile_definitions(NDEBUG)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/install)
# Radiant definitions
add_compile_definitions(RADIANT_VERSION="0.0")
add_compile_definitions(RADIANT_MAJOR_VERSION=0)
add_compile_definitions(RADIANT_MINOR_VERSION=0)
add_compile_definitions(RADIANT_ABOUTMSG="Dev build")
# Remap definitions
add_compile_definitions(Q3MAP_VERSION="Dev build")
# Compile defs
add_compile_definitions(QT_NO_KEYWORDS)
# Find dependencies
if (${MSVC}) # Visual studio
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/windeps/cmake)
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/windeps/qt)
find_package(Glib2 REQUIRED)
find_package(LibPng REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(ZLib REQUIRED)
find_package(LibJpeg REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)
find_package(Threads REQUIRED)
else() # Msys / Linux
include(FindPkgConfig)
pkg_check_modules(GLIB glib-2.0 REQUIRED)
pkg_check_modules(PNG libpng REQUIRED)
pkg_check_modules(LIBXML2 libxml-2.0 REQUIRED)
pkg_check_modules(ZLIB zlib REQUIRED)
pkg_check_modules(JPEG libjpeg REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)
find_package(Threads REQUIRED)
endif()
# Global include dirs
include_directories(include libs)
# Libs
if(BUILD_RADIANT OR BUILD_TOOLS OR BUILD_PLUGINS)
add_subdirectory(libs)
endif()
# Contrib
if(BUILD_PLUGINS)
add_subdirectory(contrib)
endif()
# Plugins && Radiant
if(BUILD_RADIANT)
add_subdirectory(plugins)
add_subdirectory(radiant)
endif()
# Tools
if(BUILD_TOOLS)
add_subdirectory(tools)
endif()
# https://stackoverflow.com/questions/11944060/how-to-detect-target-architecture-using-cmake
if(INSTALL_DLLS)
execute_process( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE )
execute_process( COMMAND sh ./install-dlls-msys2-mingw.sh ${ARCHITECTURE})
endif()