@@ -14,41 +14,51 @@ set (CMAKE_CXX_STANDARD 14)
1414set (CMAKE_CXX_STANDARD_REQUIRED ON )
1515set (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" )
2023set (GLM_ROOT "${CMAKE_SOURCE_DIR} /distant/glm" )
2124set (IMGUI_ROOT "${CMAKE_SOURCE_DIR} /distant/imgui" )
22- set (WEB_ROOT "${CMAKE_SOURCE_DIR} /distant/web" )
2325
2426set (GLM_INC "${GLM_ROOT} " )
2527set (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} )
3335endif ()
3436
37+ # Copy imgui glfw implementation file.
38+ # As is, imgui use gl3w and we change it to use GLAD instead.
3539if (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} " )
4854endif ()
49-
5055file (GLOB IMGUI_SRC "${IMGUI_ROOT} /*.cpp" )
5156
57+ ##############
58+ # Non-automatically managed dependencies
59+ #
60+ # This include: assimp, OpenGL and GLFW
61+
5262find_package (OpenGL REQUIRED)
5363find_package (assimp REQUIRED)
5464find_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+
7478set (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
95105set (core_sources
0 commit comments