-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
executable file
·146 lines (109 loc) · 4.13 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.2.3)
# Define basic compiler and CMake configuration
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
set (OSPGL_STACKTRACES OFF)
##################################################################################
# OSPGL - The game engine
##################################################################################
project(OSPGL)
# Define source files for OSP and non-cmake dependencies
file(GLOB_RECURSE OSP_SOURCES "src/*.cpp")
file(GLOB_RECURSE IMGUI_SOURCES "dep/imgui/*.cpp")
set(GLAD_SOURCES "dep/glad/glad.c")
set(STB_SOURCES "dep/stb/stb_impl.cpp")
set(FASTNOISEC_SOURCES "dep/FastNoiseC/FastNoise.c")
set(NANOVG_SOURCES "dep/nanovg/nanovg_ext.cpp")
set(TINY_GLTF_SOURCES "dep/tiny_gltf/tiny_gltf.cpp")
set(BACKWARD_SOURCES "dep/tiny_gltf/tiny_gltf.cpp")
set(MINIAUDIO_SOURCES "dep/miniaudio/miniaudio.c")
# Create the OSPGL executable
add_executable(OSPGL ${OSP_SOURCES} ${IMGUI_SOURCES} ${GLAD_SOURCES}
${FASTNOISEC_SOURCES} ${STB_SOURCES} ${NANOVG_SOURCES} ${TINY_GLTF_SOURCES}
${BACKWARD_SOURCES} ${MINIAUDIO_SOURCES})
# Name it ospgl (lowercase)
set_target_properties(OSPGL PROPERTIES OUTPUT_NAME "ospgl")
# Set compiler options for OSPGL
if(OSPGL_STACKTRACES)
add_definitions(-DOSPGL_STACKTRACES=1)
endif()
add_definitions(-DLUAJIT_ENABLE_LUA52COMPAT)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
target_compile_options(OSPGL PUBLIC /bigobj)
else()
if(CMAKE_BUILD_TYPE MATCHES "Release")
message(WARNING "Building in release, debugging may misbehave!")
target_compile_options(OSPGL PUBLIC -g -O2)
else()
target_compile_options(OSPGL PUBLIC -g -O0)
endif()
set(EXTRA_LINK "stdc++fs")
if(OSPGL_STACKTRACES)
add_definitions(-DBACKWARD_HAS_DW=1)
set(STACKTRACE_LINK "dw")
endif()
link_libraries(${CMAKE_DL_LIBS} GL)
endif()
include_directories(dep)
include_directories(OSPGL PUBLIC dep/bullet3/src)
include_directories(OSPGL PUBLIC src)
include_directories(OSPGL PUBLIC pkg)
# Include CMake dependencies
# GLFW
add_subdirectory(dep/glfw)
target_link_libraries(OSPGL glfw)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
# OpenGL
find_package(OpenGL REQUIRED)
include_directories(OSPGL PUBLIC ${OPENGL_INCLUDE_DIR})
# Threads
find_package(Threads REQUIRED)
target_link_libraries(OSPGL ${CMAKE_THREAD_LIBS_INIT})
# LuaJIT
add_subdirectory(dep/LuaJIT-cmake)
# Bullet3
add_subdirectory(dep/bullet3)
# Make sure we use double precision, and it's enabled for
# the bullet compilation
set(USE_DOUBLE_PRECISION ON CACHE BOOL "" FORCE)
ADD_DEFINITIONS( -DBT_USE_DOUBLE_PRECISION)
set(BUILD_BULLET3 OFF CACHE BOOL "" FORCE) #< Bullet3 is incomplete and uses only floats
# fmt
add_subdirectory(dep/fmt)
# FreeType
find_package(Freetype)
if(Freetype_FOUND)
target_link_Libraries(OSPGL ${FREETYPE_LIBRARIES})
include_directories(OSPGL ${FREETYPE_INCLUDE_DIRS})
add_compile_definitions(WITH_FREETYPE)
else()
message(WARNING "Could not find FreeType, text quality will be worse")
endif()
# Link libraries
target_link_libraries(OSPGL fmt liblua-static BulletSoftBody BulletDynamics
BulletCollision LinearMath ${CMAKE_DL_LIBS} ${EXTRA_LINK} ${STACKTRACE_LINK})
##################################################################################
# ospm - The package manager for OSPGL (Open Space Program Manager)
##################################################################################
project(ospm)
file(GLOB_RECURSE OSPM_SOURCES "ospm_src/*.cpp")
set(MINIZ_SOURCES "ospm_src/dep/miniz.c")
add_executable(ospm ${OSPM_SOURCES} ${MINIZ_SOURCES})
if(MSVC)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DNOMINMAX)
else()
target_compile_options(ospm PUBLIC -g -O0)
endif()
add_definitions(-DCPPHTTPLIB_OPENSSL_SUPPORT)
find_package(OpenSSL REQUIRED)
message(STATUS "OpenSSL Version: " ${OPENSSL_VERSION})
message(STATUS "OpenSSL Include: " ${OPENSSL_INCLUDE_DIR})
include_directories(dep)
include_directories(pkg)
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(ospm ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS} ${EXTRA_LINK})