forked from Try/OpenGothic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
154 lines (129 loc) · 5.07 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
cmake_minimum_required(VERSION 3.16)
project(Gothic2Notr LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/opengothic)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/opengothic)
set(CMAKE_DEBUG_POSTFIX "")
set(CMAKE_RELWITHDEBINFO_POSTFIX "")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_SKIP_RPATH ON)
add_executable(${PROJECT_NAME})
if(MSVC)
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
add_definitions(-DNOMINMAX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800")
endif()
if(NOT MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wconversion -Wno-strict-aliasing -Werror)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "7.1" AND NOT APPLE AND NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-format-truncation)
endif()
if(UNIX)
# -rdynamic is needed to allow obtaining meaningful backtraces
target_link_options(${PROJECT_NAME} PRIVATE -rdynamic)
endif()
endif()
if(WIN32)
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup" )
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows -lstdc++fs")
endif()
endif()
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)
enable_language(OBJCXX)
target_link_libraries(${PROJECT_NAME} "-framework AppKit")
file(GLOB_RECURSE ObjCSOURCES "game/*.mm")
endif()
## OpenGothic
# sources
file(GLOB_RECURSE OPENGOTHIC_SOURCES
"game/*.h"
"game/*.cpp")
target_sources(${PROJECT_NAME} PRIVATE ${OPENGOTHIC_SOURCES} ${ObjCSOURCES} icon.rc)
# shaders
add_subdirectory(shader)
target_link_libraries(${PROJECT_NAME} GothicShaders)
include_directories("game")
## submodule dependencies
# edd-dbg
add_subdirectory(lib/edd-dbg)
include_directories(lib/edd-dbg/include)
if(WIN32)
target_link_libraries(${PROJECT_NAME} edd_dbg)
endif()
if(WIN32)
target_link_libraries(${PROJECT_NAME} shlwapi DbgHelp)
elseif(UNIX)
target_link_libraries(${PROJECT_NAME} -lpthread -ldl)
endif()
# phoenix
set(BUILD_SQUISH_WITH_SSE2 OFF CACHE INTERNAL "")
set(PHOENIX_DISABLE_SANITIZERS ON CACHE INTERNAL "")
set(PHOENIX_LOG_LEVEL "3")
add_subdirectory(lib/phoenix)
target_link_libraries(${PROJECT_NAME} phoenix)
# TinySoundFont
add_definitions(-DTSF_NO_STDIO)
include_directories(lib/TinySoundFont)
# Tempest
set(TEMPEST_BUILD_SHARED ON CACHE INTERNAL "")
add_subdirectory(lib/Tempest/Engine)
include_directories(lib/Tempest/Engine/include)
target_link_libraries(${PROJECT_NAME} Tempest)
# zip
include_directories(lib/miniz)
add_library(miniz STATIC "lib/miniz/miniz.h" "lib/miniz/miniz.c")
target_link_libraries(${PROJECT_NAME} miniz)
# bullet physics
set(BULLET2_MULTITHREADING ON CACHE INTERNAL "")
set(USE_MSVC_RUNTIME_LIBRARY_DLL ON CACHE INTERNAL "")
set(USE_GRAPHICAL_BENCHMARK OFF CACHE INTERNAL "")
set(BUILD_BULLET2_DEMOS OFF CACHE INTERNAL "") # No samples
set(BUILD_OPENGL3_DEMOS OFF CACHE INTERNAL "") # No samples
set(BUILD_UNIT_TESTS OFF CACHE INTERNAL "") # No tests
set(BUILD_CPU_DEMOS OFF CACHE INTERNAL "") # No samples
set(BUILD_EXTRAS OFF CACHE INTERNAL "") # No bugs
set(GLFW_BUILD_EXAMPLES OFF CACHE INTERNAL "")
set(GLFW_BUILD_TESTS OFF CACHE INTERNAL "")
set(GLFW_BUILD_DOCS OFF CACHE INTERNAL "")
set(BUILD_BULLET3 OFF CACHE INTERNAL "") # Can use bullet2, bullet3 wants to build examples...
add_subdirectory(lib/bullet3)
if(NOT MSVC)
target_compile_options(BulletDynamics PRIVATE -Wno-argument-outside-range)
target_compile_options(BulletInverseDynamics PRIVATE -Wno-argument-outside-range)
target_compile_options(BulletSoftBody PRIVATE -Wno-argument-outside-range)
target_compile_options(Bullet3Common PRIVATE -Wno-argument-outside-range)
target_compile_options(BulletCollision PRIVATE -Wno-argument-outside-range)
target_compile_options(LinearMath PRIVATE -Wno-argument-outside-range)
endif()
include_directories(lib/bullet3/src)
target_link_libraries(${PROJECT_NAME} BulletDynamics BulletCollision LinearMath)
# script for launching in binary directory
if(WIN32)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/scripts/Gothic2Notr.bat
${CMAKE_CURRENT_BINARY_DIR}/opengothic/Gothic2Notr.bat)
elseif(UNIX)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/scripts/Gothic2Notr.sh
${CMAKE_CURRENT_BINARY_DIR}/opengothic/Gothic2Notr.sh)
endif()
# in debug mode, enable sanitizers
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
add_compile_options(-fsanitize=address)
add_compile_options(-fsanitize=leak)
add_link_options (-fsanitize=address)
add_link_options (-fsanitize=leak)
endif()
# installation
install(TARGETS ${PROJECT_NAME} DESTINATION bin)