Skip to content

Commit 64d598b

Browse files
committed
chore: clean up cmake
1 parent 451fcc5 commit 64d598b

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

.gitmodules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
path = distant/imgui
33
url = https://github.com/ocornut/imgui.git
44
ignore = dirty
5-
[submodule "distant/glfw"]
6-
path = distant/glfw
7-
url = https://github.com/glfw/glfw
8-
ignore = dirty
95
[submodule "distant/glm"]
106
path = distant/glm
117
url = https://github.com/g-truc/glm.git

CMakeLists.txt

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,51 @@ set (CMAKE_CXX_STANDARD 14)
1414
set (CMAKE_CXX_STANDARD_REQUIRED ON)
1515
set (CMAKE_CXX_EXTENSIONS OFF)
1616

17-
##################################################################################
18-
# Externals
19-
##################################################################################
17+
##############
18+
# Automatically managed dependencies
19+
#
20+
# glm and imgui are git submodules of this project.
21+
22+
set(WEB_ROOT "${CMAKE_SOURCE_DIR}/distant/web")
2023
set(GLM_ROOT "${CMAKE_SOURCE_DIR}/distant/glm")
2124
set(IMGUI_ROOT "${CMAKE_SOURCE_DIR}/distant/imgui")
22-
set(WEB_ROOT "${CMAKE_SOURCE_DIR}/distant/web")
2325

2426
set(GLM_INC "${GLM_ROOT}")
2527
set(IMGUI_INC "${IMGUI_ROOT}")
26-
set(GLFW_LOCATION "${CMAKE_SOURCE_DIR}/distant/glfw")
2728

28-
if (NOT EXISTS ${GLFW_LOCATION} OR
29-
NOT EXISTS ${GLM_INC} OR
30-
NOT EXISTS ${IMGUI_INC}/examples)
31-
message(STATUS "Updating submodules")
32-
execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
29+
if (NOT EXISTS ${GLM_INC} OR
30+
NOT EXISTS ${IMGUI_INC}/examples)
31+
32+
message(STATUS "Updating submodules")
33+
34+
execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
3335
endif()
3436

37+
# Copy imgui glfw implementation file.
38+
# As is, imgui use gl3w and we change it to use GLAD instead.
3539
if (NOT EXISTS ${IMGUI_ROOT}/imgui_impl_glfw_gl3.cpp OR
3640
NOT EXISTS ${IMGUI_ROOT}/imgui_impl_glfw_gl3.h)
41+
3742
message(STATUS "Generating imgui glfw implementation files")
43+
3844
file(COPY
3945
${IMGUI_ROOT}/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
4046
${IMGUI_ROOT}/examples/opengl3_example/imgui_impl_glfw_gl3.h
4147
DESTINATION ${IMGUI_ROOT})
4248

49+
# I don't want imgui to use gl3w, I want it to use GLAD.
4350
message(STATUS "Replacing gl3w with glad in imgui implementation files")
4451
FILE(READ ${IMGUI_ROOT}/imgui_impl_glfw_gl3.cpp IMGUI_HEADER_STR)
45-
# I don't want imgui to use gl3w, I want it to use GLAD.
4652
string(REPLACE "GL/gl3w.h" "glad/glad.h" IMGUI_HEADER_STR "${IMGUI_HEADER_STR}")
4753
FILE(WRITE ${IMGUI_ROOT}/imgui_impl_glfw_gl3.cpp "${IMGUI_HEADER_STR}")
4854
endif()
49-
5055
file (GLOB IMGUI_SRC "${IMGUI_ROOT}/*.cpp")
5156

57+
##############
58+
# Non-automatically managed dependencies
59+
#
60+
# This include: assimp, OpenGL and GLFW
61+
5262
find_package(OpenGL REQUIRED)
5363
find_package(assimp REQUIRED)
5464
find_package(GLFW REQUIRED)
@@ -60,17 +70,11 @@ include_directories(
6070
${ASSIMP_INCLUDE_DIR}
6171
${IMGUI_INC}
6272
${WEB_INC}
63-
)
64-
65-
66-
##############
67-
# Build assets
68-
69-
message(STATUS "Copy resources into ${CMAKE_CURRENT_BINARY_DIR}/resources")
70-
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/resources" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
73+
)
7174

7275
##############
7376
# Build glad lib
77+
7478
set (glad_sources
7579
"${SRC_DIR}/thirdparty/glad/glad.c"
7680
"${SRC_DIR}/thirdparty/glad/glad.h"
@@ -90,6 +94,12 @@ install (TARGETS glad
9094
DESTINATION lib
9195
)
9296

97+
##############
98+
# Build assets
99+
100+
message(STATUS "Copy resources into ${CMAKE_CURRENT_BINARY_DIR}/resources")
101+
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/resources" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
102+
93103
##############
94104
# Build core lib
95105
set (core_sources

distant/glfw

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)