This repository was archived by the owner on Feb 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
152 lines (128 loc) · 4.58 KB
/
CMakeLists.txt
File metadata and controls
152 lines (128 loc) · 4.58 KB
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
cmake_minimum_required(VERSION 3.15)
project(MARS)
if(MSVC)
add_definitions(/Wall)
else()
add_definitions(-c -Wall -msse2 -Wextra)
endif()
if ( CMAKE_BUILD_TYPE STREQUAL "" )
set(
CMAKE_BUILD_TYPE
"Debug"
CACHE STRING
"Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) \"DebugEditor\" \"Debug\" \"VerboseDebug\" \"Shipping\"."
FORCE
)
endif ( CMAKE_BUILD_TYPE STREQUAL "" )
if ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
add_definitions( -O2 )
endif ( CMAKE_BUILD_TYPE STREQUAL "Debug" )
if ( CMAKE_BUILD_TYPE STREQUAL "VerboseDebug" )
add_definitions( -O4 )
endif ( CMAKE_BUILD_TYPE STREQUAL "VerboseDebug" )
# Begin MARS
file(GLOB_RECURSE HDRS
${MARS_SOURCE_DIR}/Engine/Platform/*.h
${MARS_SOURCE_DIR}/Engine/Platform/*.hpp
${MARS_SOURCE_DIR}/Engine/Classes/*.h
${MARS_SOURCE_DIR}/Engine/Classes/*.hpp
${MARS_SOURCE_DIR}/Engine/*.h
${MARS_SOURCE_DIR}/Engine/*.hpp
)
file(GLOB_RECURSE SRCS
${MARS_SOURCE_DIR}/Engine/Platform/*.cpp
${MARS_SOURCE_DIR}/Engine/Platform/*.cc
${MARS_SOURCE_DIR}/Engine/Platform/*.c
${MARS_SOURCE_DIR}/Engine/Source/*.cpp
${MARS_SOURCE_DIR}/Engine/Source/*.cc
${MARS_SOURCE_DIR}/Engine/Source/*.c
${MARS_SOURCE_DIR}/Engine/*.cpp
${MARS_SOURCE_DIR}/Engine/*.cc
${MARS_SOURCE_DIR}/Engine/*.c
)
file(GLOB_RECURSE EDITOR_HDRS
${MARS_SOURCE_DIR}/Editor/Classes/*.h
${MARS_SOURCE_DIR}/Editor/Classes/*.hpp
${MARS_SOURCE_DIR}/Editor/Platform/*.h
${MARS_SOURCE_DIR}/Editor/*.h
${MARS_SOURCE_DIR}/Editor/*.hpp
)
file(GLOB_RECURSE EDITOR_SRCS
${MARS_SOURCE_DIR}/Editor/Source/*.cpp
${MARS_SOURCE_DIR}/Editor/Source/*.c
${MARS_SOURCE_DIR}/Editor/Platform/*.c
${MARS_SOURCE_DIR}/Editor/Platform/*.cpp
${MARS_SOURCE_DIR}/Editor/Source/*.cc
${MARS_SOURCE_DIR}/Editor/*.cpp
${MARS_SOURCE_DIR}/Editor/*.c
${MARS_SOURCE_DIR}/Editor/*.cc
)
find_package(OpenGL REQUIRED)
include_directories(
${MARS_SOURCE_DIR}/Engine/Classes
${MARS_SOURCE_DIR}/Engine/Source
${MARS_SOURCE_DIR}/Engine/Platform
${MARS_SOURCE_DIR}/Engine/
${MARS_SOURCE_DIR}/Thirdparty/Includes/
${OPENGL_INCLUDE_DIRS}
)
link_directories(
${MARS_SOURCE_DIR}/Thirdparty/Libs
)
add_library(MARS STATIC ${HDRS} ${SRCS})
add_library(ImGui STATIC
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imgui.cpp
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imgui.h
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imgui_demo.cpp
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imgui_draw.cpp
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imgui_internal.h
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imgui_widgets.cpp
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imstb_rectpack.h
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imstb_textedit.h
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imstb_truetype.h
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/imconfig.h
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/examples/imgui_impl_glfw.h
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/examples/imgui_impl_glfw.cpp
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/examples/imgui_impl_opengl3.h
${MARS_SOURCE_DIR}/Thirdparty/Includes/imgui/examples/imgui_impl_opengl3.cpp
)
target_link_libraries(MARS ImGui)
target_link_libraries( MARS
${OPENGL_LIBRARIES}
glfw3.lib
assimp.lib
SDL2.lib
SDL2main.lib
#SDL2test.lib
#ImGui.lib
)
# End MARS
# Begin MARSEditor
add_executable(MARSEditor ${EDITOR_HDRS} ${EDITOR_SRCS})
target_link_libraries(MARSEditor MARS)
set_property(DIRECTORY ${MARS_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT MARSEditor)
# End MARSEditor
set_target_properties(MARS PROPERTIES CXX_STANDARD 17)
if(WIN32)
string(REPLACE "/" "\\" source_path_windows "${MARS_SOURCE_DIR}/Resources")
string(REPLACE "/" "\\" build_path_windows "${MARS_BINARY_DIR}/Resources")
execute_process(COMMAND cmd.exe /c mklink /J "${build_path_windows}" "${source_path_windows}" RESULT_VARIABLE exitcode)
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${MARS_SOURCE_DIR}/Resources ${MARS_BINARY_DIR}/Resources RESULT_VARIABLE exitcode)
endif()
if(NOT ${exitcode} EQUAL 0)
MESSAGE("SYMLINKING FAILED: ${exitcode}")
MESSAGE("FALLING BACK TO COPYING")
endif()
file(GLOB_RECURSE RES RELATIVE ${MARS_SOURCE_DIR}/Resources/ ${MARS_SOURCE_DIR}/Resources/*.*)
foreach(file IN LISTS RES)
configure_file(${MARS_SOURCE_DIR}/Resources/${file} ${MARS_BINARY_DIR}/Resources/${file} COPYONLY)
endforeach()
if(MSVC_IDE)
foreach(source IN LISTS SRCS HDRS)
get_filename_component(source_path "${source}" PATH)
string(REPLACE "${MARS_SOURCE_DIR}" "" relative_source_path "${source_path}")
string(REPLACE "/" "\\" source_path_msvc "${relative_source_path}")
source_group("${source_path_msvc}" FILES "${source}")
endforeach()
endif()