-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
130 lines (106 loc) · 3.61 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
# CMakeList.txt : CMake project for gKernel, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.25)
# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
project ("gKernel")
## get submodules from github
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
## Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
## CHECK ALL THE SUBMODULES
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/glfw/CMakeLists.txt")
message(FATAL_ERROR "The glfw submodules was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/assimp/CMakeLists.txt")
message(FATAL_ERROR "The assimp submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
file(
GLOB imgui_src
"external/imgui/*.cpp"
"external/imgui/backends/imgui_impl_glfw.cpp"
"external/imgui/backends/imgui_impl_opengl3.cpp"
)
file(GLOB src
"src/core/*.cpp"
"src/math/*.cpp"
"src/core/gizmos/*.cpp"
"src/app/*.cpp"
)
#Set asset paths
set(ASSET_DIR
" \"${CMAKE_CURRENT_BINARY_DIR}/../../../assets/\" "
)
set(SHADER_DIR " \"${CMAKE_CURRENT_BINARY_DIR}/../../../assets/shaders/\" ")
set(MODEL_DIR " \"${CMAKE_CURRENT_BINARY_DIR}/../../../assets/models/\" ")
set(IMAGE_DIR " \"${CMAKE_CURRENT_BINARY_DIR}/../../../assets/images/\" ")
message("Using Asset directory: ${ASSET_DIR}")
message("Using Shader directory: ${SHADER_DIR}")
message("Using Model directory: ${MODEL_DIR}")
message("Using Image directory: ${IMAGE_DIR}")
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/src/core/settings.h.in"
"${CMAKE_CURRENT_LIST_DIR}/src/core/settings.h"
)
# Add source to this project's executable.
add_executable (
${PROJECT_NAME}
"src/main.cpp"
external/glad/src/glad.c
${imgui_src}
${src}
)
add_subdirectory(external/glfw)
#Disable warnings as errors in assimp
OPTION ( ASSIMP_WARNINGS_AS_ERRORS
"Do not treat assimp warnings as errors."
OFF
)
#TODO: Build shared libs for debugging?, but not release
OPTION( BUILD_SHARED_LIBS
"Do not build package with shared libraries."
ON
)
OPTION( ASSIMP_INSTALL
"Disable this if you want to use assimp as a submodule."
OFF
)
add_subdirectory(${PROJECT_SOURCE_DIR}/external/assimp)
target_include_directories(
${PROJECT_NAME}
PUBLIC external/glfw/include
PUBLIC external/glad/include
PUBLIC external/imgui
PUBLIC external/imgui/backends
PUBLIC external/assimp/include
PUBLIC src
PUBLIC src/core
PUBLIC src/core/gizmos
PUBLIC src/app
)
target_link_directories(
${PROJECT_NAME}
PUBLIC external/glfw/src
)
target_link_libraries(
${PROJECT_NAME}
glfw
assimp
)
set_property(TARGET gKernel PROPERTY CXX_STANDARD 17)
# TODO: Add tests and install targets if needed.