-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
150 lines (129 loc) · 3.48 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
cmake_minimum_required(VERSION 3.21)
# Project definition
project("glfw-imgui"
DESCRIPTION "ImGUI App"
LANGUAGES C CXX
)
message("Project name: " ${CMAKE_PROJECT_NAME})
# Set C++ standard and export compile commands
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set postfix for debug configuration
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Filename postfix for libraries under DEBUG configuration")
#add_compile_options(
#"-Wno-unused-local-typedefs"
#)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs" )
# Define source and header files
set(sources
src/app.cpp
src/buffer.cpp
src/camera.cpp
src/input_handler.cpp
src/functions.cpp
src/main.cpp
src/menu_bar.cpp
src/mesh.cpp
src/ogl_window.cpp
src/ogl.cpp
src/scene_view.cpp
src/shader.cpp
src/ui.cpp
)
set(headers
includes/app.h
includes/buffer.h
includes/camera.h
includes/config.h
includes/functions.h
includes/imgui_stdlib.h
includes/imgui-style.h
includes/input_handler.h
includes/menu_bar.h
includes/mesh.h
includes/ogl_window.h
includes/ogl.h
includes/render.h
includes/scene_view.h
includes/shader.h
includes/ui.h
includes/vertex.h
includes/window.h
)
set(resource_files
${CMAKE_SOURCE_DIR}/includes/JetBrainsMono-ExtraLight.ttf
)
# Find OpenGL
find_package(OpenGL REQUIRED)
# If UNIX, find necessary dependencies for non-Apple systems
if (UNIX)
if (NOT APPLE)
find_package(Threads REQUIRED)
find_package(X11 REQUIRED)
endif()
endif()
# Find dependencies: ImGui, GLFW, and GLAD
find_package(imgui REQUIRED)
message("ImGui version name: " ${imgui_VERSION})
find_package(glfw3 CONFIG REQUIRED)
find_package(glad CONFIG REQUIRED)
find_package(glm REQUIRED)
find_package(assimp REQUIRED)
# Define the executable
add_executable(${CMAKE_PROJECT_NAME} ${sources} ${headers}
bindings/imgui_impl_glfw.cpp
bindings/imgui_impl_glfw.h
bindings/imgui_impl_opengl3.cpp
bindings/imgui_impl_opengl3.h
bindings/imgui_impl_opengl3_loader.h
bindings/stb_image.h
bindings/stb_image_write.h
)
# Specify include directories for the compiler
target_include_directories(${CMAKE_PROJECT_NAME}
PRIVATE
${CMAKE_SOURCE_DIR}/includes
${CMAKE_SOURCE_DIR}/bindings
)
# Link libraries
target_link_libraries(${CMAKE_PROJECT_NAME}
PRIVATE imgui::imgui glad::glad glfw OpenGL::GL glm::glm assimp::assimp
)
# Add source files to the target
target_sources(${CMAKE_PROJECT_NAME}
PRIVATE ${sources}
)
# Platform-specific linking
if (UNIX)
if (APPLE)
target_link_libraries(${CMAKE_PROJECT_NAME}
PRIVATE
"-framework Cocoa"
"-framework IOKit"
"-framework CoreVideo"
)
else()
target_link_libraries(${CMAKE_PROJECT_NAME}
PRIVATE
${CMAKE_THREAD_LIBS_INIT}
${X11_LIBRARIES}
${CMAKE_DL_LIBS}
)
endif()
endif()
# Set target properties for debug builds
set_target_properties(${CMAKE_PROJECT_NAME}
PROPERTIES
DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}"
)
# Install configuration
include(GNUInstallDirs)
install(TARGETS ${CMAKE_PROJECT_NAME}
COMPONENT ${CMAKE_PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/${CMAKE_PROJECT_NAME}
)
install(FILES
${resource_files}
DESTINATION ${CMAKE_INSTALL_BINDIR}/${CMAKE_PROJECT_NAME}
COMPONENT ${CMAKE_PROJECT_NAME}
)