This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
145 lines (116 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
cmake_minimum_required(VERSION 3.6)
project(Core VERSION 0.3.0 DESCRIPTION "Core Engine" LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/")
# Build options
# HH:MM:SS:ms -> YY/MM/DD HH:MM:SS.ms
option(CORE_LOG_DATE "Adds year, month and date to each log entry" OFF)
# at [filename:line] -> at [full/file/path/filename:line]
option(CORE_LOG_FULL_PATH "LOG_HERE adds full filepath to log" OFF)
# Adds core::VkRenderer -> core::Renderer kind of typedefs. Gives better looking client-side
# code, but you will not be able to include two modules with same typedefs in the same file
option(CORE_SIMPLIFY_SYNTAX "Adds typedefs for modules and components" ON)
# Core Engine
set( CORE_INCLUDE_DIR include )
set( CORE_LIB_DIR lib )
set( CORE_SRC_DIR src )
file( GLOB_RECURSE CORE_SOURCES
${CORE_INCLUDE_DIR}/core/*.h
${CORE_INCLUDE_DIR}/core/*.tpp
${CORE_SRC_DIR}/*.cpp )
add_library( core STATIC ${CORE_SOURCES} )
target_include_directories( core PUBLIC ${CORE_INCLUDE_DIR} )
if ( CORE_LOG_DATE )
target_compile_definitions( core PUBLIC CORE_LOG_DATE )
endif()
if ( CORE_LOG_FULL_PATH )
target_compile_definitions( core PUBLIC CORE_LOG_FULL_PATH )
endif()
if ( CORE_SIMPLIFY_SYNTAX )
target_compile_definitions( core PUBLIC CORE_SIMPLIFY_SYNTAX )
endif()
# Compiler-specific options
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_link_options(-pthread -lpthread)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -O3 -Wa,-mbig-obj" )
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -O3 -Wa,-mbig-obj" )
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /W4" )
# required by corrade
set(MSVC2019_COMPATIBILITY TRUE)
endif()
# SDL2
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/SDL2-2.0.10")
set(SDL_ATOMIC OFF CACHE BOOL "" FORCE)
set(SDL_CPUINFO OFF CACHE BOOL "" FORCE)
set(SDL_EVENTS OFF CACHE BOOL "" FORCE)
set(SDL_FILE OFF CACHE BOOL "" FORCE)
set(SDL_FILESYSTEM OFF CACHE BOOL "" FORCE)
set(SDL_HAPTIC OFF CACHE BOOL "" FORCE)
set(SDL_LOCALE OFF CACHE BOOL "" FORCE)
set(SDL_POWER OFF CACHE BOOL "" FORCE)
set(SDL_RENDER OFF CACHE BOOL "" FORCE)
set(SDL_SENSOR OFF CACHE BOOL "" FORCE)
set(SDL_THREADS OFF CACHE BOOL "" FORCE)
set(SDL_TIMERS OFF CACHE BOOL "" FORCE)
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
# assimp
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(ASSIMP_NO_EXPORT ON CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(INJECT_DEBUG_POSTFIX OFF CACHE BOOL "" FORCE)
set(ASSIMP_INJECT_DEBUG_POSTFIX OFF CACHE BOOL "" FORCE)
# Dear ImGUI
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/imgui")
set(IMGUI_DIR lib/imgui)
# magnum
set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
set(MAGNUM_PLUGINS_DIR lib/magnum-plugins)
set(WITH_ANYSCENEIMPORTER ON CACHE BOOL "" FORCE)
set(WITH_ANYIMAGEIMPORTER ON CACHE BOOL "" FORCE)
set(WITH_CGLTFIMPORTER ON CACHE BOOL "" FORCE)
set(WITH_STBIMAGEIMPORTER ON CACHE BOOL "" FORCE)
set(WITH_TINYGLTFIMPORTER ON CACHE BOOL "" FORCE)
set(WITH_SDL2APPLICATION ON CACHE BOOL "" FORCE)
set(WITH_ASSIMPIMPORTER ON CACHE BOOL "" FORCE)
set(WITH_OBJIMPORTER ON CACHE BOOL "" FORCE)
set(WITH_IMGUI ON CACHE BOOL "" FORCE)
add_subdirectory(${CORE_LIB_DIR}/assimp EXCLUDE_FROM_ALL)
add_subdirectory(${CORE_LIB_DIR}/corrade EXCLUDE_FROM_ALL)
add_subdirectory(${CORE_LIB_DIR}/magnum EXCLUDE_FROM_ALL)
add_subdirectory(${CORE_LIB_DIR}/magnum-plugins EXCLUDE_FROM_ALL)
add_subdirectory(${CORE_LIB_DIR}/magnum-integration EXCLUDE_FROM_ALL)
add_dependencies(core MagnumPlugins::StbImageImporter
MagnumPlugins::CgltfImporter)
find_package(MagnumIntegration REQUIRED
ImGui)
find_package(Magnum REQUIRED
GL
Trade
Shaders
MeshTools
SceneGraph
Primitives
ObjImporter
Sdl2Application
AnySceneImporter)
target_link_libraries(core PUBLIC
Corrade::Main
Magnum::GL
Magnum::Trade
Magnum::Magnum
Magnum::Shaders
Magnum::MeshTools
Magnum::Primitives
Magnum::SceneGraph
Magnum::ObjImporter
Magnum::Application
Magnum::Sdl2Application
Magnum::AnySceneImporter
MagnumPlugins::AssimpImporter
MagnumIntegration::ImGui)