-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
145 lines (115 loc) · 3.27 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
cmake_minimum_required(VERSION 3.16)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project(CatacombGL LANGUAGES CXX VERSION 0.5.4)
option(BUILD_TESTS "Build Tests" OFF)
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_library( CatacombGL_ThirdParty OBJECT
ThirdParty/RefKeen/be_st.h
ThirdParty/RefKeen/be_st_sdl_audio_timer.cpp
ThirdParty/RefKeen/id_sd.cpp
ThirdParty/RefKeen/id_sd.h
ThirdParty/opl/dbopl.cpp
ThirdParty/opl/dbopl.h
)
add_subdirectory(src/Engine)
add_subdirectory(src/Abyss)
add_subdirectory(src/Apocalypse)
add_subdirectory(src/Armageddon)
add_subdirectory(src/Catacomb3D)
if(WIN32)
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.24.1/SDL2-devel-2.24.1-VC.zip
URL_MD5 63dd0eca2c6715c8170b1cd3e84017fc
)
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()
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
OpenGL::GLU
)
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)