-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
125 lines (104 loc) · 2.98 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
cmake_minimum_required(VERSION 3.10)
project(SceneDebugger)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set policy for MSVC runtime library selection
if (MSVC)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
# Include directories for ImGui and project headers
include_directories(
${PROJECT_SOURCE_DIR}/imgui
${PROJECT_SOURCE_DIR}/imgui/backends
${PROJECT_SOURCE_DIR}
)
# Source files
set(SOURCES
main.cpp
Camera.h
Shader.h
# ImGui source files
imgui/imgui.cpp
imgui/imgui_draw.cpp
imgui/imgui_widgets.cpp
imgui/imgui_tables.cpp
imgui/imgui_demo.cpp
imgui/backends/imgui_impl_glfw.cpp
imgui/backends/imgui_impl_opengl3.cpp
)
# Find OpenGL
find_package(OpenGL REQUIRED)
if (WIN32)
# On Windows, set OpenGL library explicitly
set(OPENGL_LIBRARIES opengl32.lib)
endif()
# Set paths to libraries
if (WIN32)
# Modify these paths to where you've installed the libraries
set(GLFW_ROOT "C:/Devel/glfw-3.3.8.bin.WIN64")
set(GLEW_ROOT "C:/Devel/glew-2.1.0")
set(GLM_ROOT "C:/Devel/glm")
# GLFW
set(GLFW_INCLUDE_DIR "${GLFW_ROOT}/include")
set(GLFW_LIBRARY "${GLFW_ROOT}/lib-vc2019/glfw3.lib")
# GLEW
set(GLEW_INCLUDE_DIR "${GLEW_ROOT}/include")
set(GLEW_LIBRARY "${GLEW_ROOT}/lib/Release/x64/glew32.lib")
# GLM
set(GLM_INCLUDE_DIR "${GLM_ROOT}")
# Include directories
include_directories(
${GLFW_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${GLM_INCLUDE_DIR}
)
# Link directories
link_directories(
${GLFW_ROOT}/lib-vc2019
${GLEW_ROOT}/lib/Release/x64
)
# Add executable
add_executable(SceneDebugger ${SOURCES})
# Link libraries
target_link_libraries(SceneDebugger
${GLFW_LIBRARY}
${GLEW_LIBRARY}
${OPENGL_LIBRARIES}
)
# Include GLM
target_include_directories(SceneDebugger PRIVATE ${GLM_INCLUDE_DIR})
else()
# Unix-like systems
# Find GLFW
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
# Find GLEW
find_package(GLEW REQUIRED)
# Find GLM
find_package(glm REQUIRED)
# Include directories
include_directories(
${GLFW_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
${GLM_INCLUDE_DIRS}
)
# Add executable
add_executable(SceneDebugger ${SOURCES})
# Link libraries
target_link_libraries(SceneDebugger
${GLFW_LIBRARIES}
${GLEW_LIBRARIES}
${OPENGL_LIBRARIES}
)
# Include GLM
target_include_directories(SceneDebugger PRIVATE ${GLM_INCLUDE_DIRS})
endif()
# Copy shader files to the output directory
add_custom_command(TARGET SceneDebugger POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PROJECT_SOURCE_DIR}/vertex_shader.glsl"
"${PROJECT_SOURCE_DIR}/fragment_shader.glsl"
$<TARGET_FILE_DIR:SceneDebugger>
)