-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
154 lines (129 loc) · 4.96 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(asura C CXX)
if(APPLE)
enable_language(OBJC)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(ASURA_PROJECT_NAME "example")
set(ASURA_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set(ASURA_FOLDER_PREGEN FOLDER "Pre-generated")
set(ASURA_FOLDER_THIRD_PARTY FOLDER "3rd-party")
set(ASURA_FOLDER_PROFILR FOLDER "profiler")
set(ASURA_FOLDER_ENGINE FOLDER "Engine")
set(ASURA_FOLDER_GAME FOLDER "Game")
option(ASURA_SHIPPING "Shipping build of asura" OFF)
option(ASURA_BOX2D_OPTIMIZED "Enable optimized version of Box2D" OFF)
option(ASURA_OPTICK "Enable optick profiler" OFF)
option(ASURA_ASAN "Enable address sanitizer" OFF)
option(ASURA_MIMALLOC "Enable mimalloc" ON)
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
endif()
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
if (ASURA_ASAN)
elseif (ASURA_SHIPPING)
set(ASURA_OPTICK OFF CACHE BOOL "force optick" FORCE)
endif()
option(BOX2D_BUILD_UNIT_TESTS "Build the Box2D unit tests" ON)
option(BOX2D_BUILD_TESTBED "Build the Box2D testbed and benchmarks" ON)
set(BOX2D_BUILD_UNIT_TESTS OFF CACHE BOOL "shared libraries" FORCE)
set(BOX2D_BUILD_TESTBED OFF CACHE BOOL "shared libraries" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "shared libraries" FORCE)
set(PNG_BUILD_ZLIB ON CACHE BOOL "shared libraries" FORCE)
set(PNG_TESTS OFF CACHE BOOL "shared libraries" FORCE)
set(PNG_SHARED OFF CACHE BOOL "shared libraries" FORCE)
set(OPTICK_ENABLED ${ASURA_OPTICK} CACHE BOOL "optick enabled" FORCE)
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
include_directories(/usr/local/include)
endif()
if (NOT ASURA_ASAN)
set(MIMALLOC_ENABLED ${ASURA_MIMALLOC} CACHE BOOL "mimalloc enabled" FORCE)
else()
set(MIMALLOC_ENABLED OFF CACHE BOOL "mimalloc enabled" FORCE)
endif()
set(BUILD_TESTING OFF CACHE BOOL "shared libraries" FORCE)
set(ALSOFT_EXAMPLES OFF CACHE BOOL "shared libraries" FORCE)
set(ALSOFT_UTILS OFF CACHE BOOL "shared libraries" FORCE)
set(ALSOFT_UPDATE_BUILD_VERSION OFF CACHE BOOL "shared libraries" FORCE)
set(AL_LIBTYPE_STATIC ON CACHE BOOL "shared libraries" FORCE)
set(OPUS_BUILD_SHARED_LIBRARY OFF CACHE BOOL "shared libraries" FORCE)
set(OPUS_X86_MAY_HAVE_SSE4_1 ON CACHE BOOL "shared libraries" FORCE)
set(OPUS_X86_PRESUME_AVX ON CACHE BOOL "shared libraries" FORCE)
set(OP_DISABLE_DOCS ON CACHE BOOL "shared libraries" FORCE)
set(OP_DISABLE_EXAMPLES ON CACHE BOOL "shared libraries" FORCE)
set(OP_DISABLE_HTTP ON CACHE BOOL "shared libraries" FORCE)
add_compile_definitions("ENTT_USE_ATOMIC")
if (ASURA_SHIPPING)
add_compile_definitions("ASURA_SHIPPING")
endif()
if (MIMALLOC_ENABLED)
add_compile_definitions("MIMALLOC_ENABLED")
endif()
if (OPTICK_ENABLED)
add_compile_definitions("OPTICK_ENABLED")
endif()
set(MI_BUILD_SHARED OFF CACHE BOOL "mimalloc enabled" FORCE)
set(MI_BUILD_OBJECT OFF CACHE BOOL "mimalloc enabled" FORCE)
set(MI_BUILD_TESTS OFF CACHE BOOL "mimalloc enabled" FORCE)
set(MI_OVERRIDE OFF CACHE BOOL "mimalloc enabled" FORCE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bins/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bins/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bins/bin)
# Create ImGui CMake file
FILE(WRITE libs/imgui/CMakeLists.txt
"cmake_minimum_required(VERSION 3.16)\n"
"project(asura C CXX)\n\n"
"file(GLOB IMGUI_SRC\n"
" \"imgui.h\"\n"
" \"imconfig.h\"\n"
" \"imgui_internal.h\"\n"
" \"imgui.cpp\"\n"
" \"imgui_demo.cpp\"\n"
" \"imgui_draw.cpp\"\n"
" \"imgui_tables.cpp\"\n"
" \"imgui_widgets.cpp\"\n"
" \"imgui_rectpack.cpp\"\n"
" \"imgui_textedit.cpp\"\n"
" \"imgui_truetype.cpp\"\n"
")\n\n"
"file(GLOB IMGUI_BACKEND_SRC\n"
" \"backends/imgui_impl_glfw.h\"\n"
" \"backends/imgui_impl_glfw.cpp\"\n"
" \"backends/imgui_impl_opengl3.h\"\n"
" \"backends/imgui_impl_opengl3.cpp\"\n"
")\n\n"
"add_library(\"imgui\" STATIC \${IMGUI_SRC} \${IMGUI_BACKEND_SRC})\n"
"target_include_directories(\"imgui\" PUBLIC \"\")\n"
"find_package(OpenGL REQUIRED)\n"
"add_dependencies(\"imgui\" OpenGL::GL)\n"
"include_directories(\${OPENGL_INCLUDE_DIRS})\n"
"target_link_libraries(\"imgui\" \${OPENGL_LIBRARIES})\n"
"target_include_directories(\"imgui\" PUBLIC \"../glfw/include\")\n"
"target_include_directories(\"imgui\" PUBLIC \"backends\")\n"
)
if (OPTICK_ENABLED)
add_subdirectory("libs/optick")
endif()
add_subdirectory("libs/mimalloc")
add_subdirectory("libs/glfw")
add_subdirectory("libs/imgui")
add_subdirectory("libs/entt")
add_subdirectory("libs/ogg")
add_subdirectory("libs/opus")
add_subdirectory("libs/opusfile")
add_subdirectory("libs/openal-soft")
add_subdirectory("libs/SOIL2")
if (UNIX)
add_subdirectory("libs/fmt")
endif()
if (ASURA_BOX2D_OPTIMIZED)
add_subdirectory("libs/box2d-opt")
else()
add_subdirectory("libs/box2d")
endif()
add_subdirectory("src")
FILE(REMOVE libs/imgui/CMakeLists.txt)