-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
147 lines (116 loc) · 3.53 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
cmake_minimum_required(VERSION 3.16)
# CMake will not change any file in the source folder.
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
# The build process should be kept in a different folder from the main source code.
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project(CatacombGL LANGUAGES CXX C VERSION 0.5.7)
# GoogleTests are by default not part of the build process, but can be added
# by selecting the option in CMake.
option(BUILD_TESTS "Build Tests" OFF)
# Sets the C++ Language Standard to "ISO C++17 Standard" in Visual Studio.
set(CMAKE_CXX_STANDARD 17)
if(MINGW)
# This might not only be required for mingw
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++")
endif()
find_package(OpenGL)
add_subdirectory(ThirdParty)
add_subdirectory(src/Engine)
add_subdirectory(src/Abyss)
add_subdirectory(src/Apocalypse)
add_subdirectory(src/Armageddon)
add_subdirectory(src/Catacomb3D)
if(WIN32)
# On Windows, the SDL2 development package is fetched from Github.
include(FetchContent)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
FetchContent_Declare(
sdldev
URL https://github.com/libsdl-org/SDL/releases/download/release-2.30.6/SDL2-devel-2.30.6-VC.zip
URL_MD5 54e68b9c4627627107105fa108bf7eed
)
FetchContent_MakeAvailable(sdldev)
set(SDL2_PATH ${sdldev_SOURCE_DIR})
find_package(SDL2 REQUIRED CONFIG PATHS ${sdldev_SOURCE_DIR}/cmake NO_DEFAULT_PATH)
target_link_libraries( CatacombGL_Engine
"shlwapi"
SDL2::SDL2main
)
target_link_libraries( CatacombGL_ThirdParty
"shlwapi"
SDL2::SDL2main
)
else()
# On Linux, it is assumed that the SDL2 development package is already installed.
find_package(SDL2 REQUIRED)
endif()
add_executable(CatacombGL)
function(link_each_target_to_libs libs targets)
foreach(target ${targets})
target_link_libraries( ${target}
${libs}
)
endforeach()
endfunction()
function(add_include_dirs_for_each_target dirs targets)
foreach(target ${targets})
target_include_directories( ${target}
PRIVATE
${dirs}
)
endforeach()
endfunction()
set( CATACOMBGL_TARGETS
"CatacombGL_Engine"
"CatacombGL_Abyss"
"CatacombGL_Armageddon"
"CatacombGL_Apocalypse"
"CatacombGL_Catacomb3D"
"CatacombGL_ThirdParty"
)
if(SDL2_VERSION VERSION_GREATER_EQUAL "2.0.12")
link_each_target_to_libs( SDL2::SDL2
"${CATACOMBGL_TARGETS}"
)
else()
link_each_target_to_libs( ${SDL2_LIBRARIES}
"${CATACOMBGL_TARGETS}"
)
add_include_dirs_for_each_target( ${SDL2_INCLUDE_DIRS}
"CatacombGL;${CATACOMBGL_TARGETS}"
)
endif()
add_subdirectory(src/System)
if(WIN32)
target_sources( CatacombGL
PUBLIC
${CMAKE_SOURCE_DIR}/res/win/CatacombGL.ico
${CMAKE_SOURCE_DIR}/res/win/CatacombGL.rc
${CMAKE_SOURCE_DIR}/res/win/resource.h
)
set_source_files_properties(
${CMAKE_SOURCE_DIR}/res/win/CatacombGL.rc
PROPERTIES LANGUAGE RC
)
endif()
target_link_libraries( CatacombGL
CatacombGL_ThirdParty
CatacombGL_Engine
CatacombGL_Abyss
CatacombGL_Armageddon
CatacombGL_Apocalypse
CatacombGL_Catacomb3D
OpenGL::GL
)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTS)
add_subdirectory(src/Test)
endif()
include(CPack)
if(WIN32)
set(CMAKE_INSTALL_BINDIR ".")
set(CMAKE_INSTALL_LIBDIR ".")
install(FILES $<TARGET_RUNTIME_DLLS:CatacombGL> TYPE LIB)
endif()
install(TARGETS CatacombGL RUNTIME)