-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
166 lines (143 loc) · 3.89 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
cmake_minimum_required(VERSION 3.16)
project(Interpol CXX C)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_C_STANDARD 99)
if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
elseif(UNIX AND NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
endif()
include(FetchContent)
FetchContent_Declare(googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# download and configure the glad project
FetchContent_Declare(
glad
GIT_REPOSITORY https://github.com/Dav1dde/glad.git
)
FetchContent_MakeAvailable(glad)
FetchContent_GetProperties(glad)
if(NOT glad_POPULATED)
FetchContent_Populate(glad)
set(
GLAD_PROFILE "core"
CACHE STRING "OpenGL profile"
)
set(
GLAD_API "gl=4.6"
CACHE STRING "API type/version pairs, "
"like \"gl=3.2,gles=\", no version means latest"
)
set(
GLAD_GENERATOR "c"
CACHE STRING "Language to generate the binding for")
add_subdirectory(
${glad_SOURCE_DIR}
${glad_BINARY_DIR}
)
endif()
# download and configure the GLFW project
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
)
FetchContent_MakeAvailable(glfw)
FetchContent_GetProperties(glfw)
if(NOT glfw_POPULATED)
FetchContent_Populate(glfw)
set(GLFW_BUILD_DOCS off CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS off CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES off CACHE BOOL "" FORCE)
add_subdirectory(
${glfw_SOURCE_DIR}
${glfw_BINARY_DIR}
)
endif()
# download the Dear ImGUI project
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
)
FetchContent_MakeAvailable(imgui)
FetchContent_GetProperties(imgui)
if(NOT imgui_POPULATED)
FetchContent_Populate(imgui)
add_subdirectory(
${imgui_SOURCE_DIR}
)
endif()
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
find_package(OpenGL REQUIRED)
# Dear ImGui library configuration
add_library(
imgui
${imgui_SOURCE_DIR}/imgui.cpp
${imgui_SOURCE_DIR}/imgui_draw.cpp
${imgui_SOURCE_DIR}/imgui_widgets.cpp
${imgui_SOURCE_DIR}/imgui_tables.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
)
include_directories(
${imgui_SOURCE_DIR}
${imgui_SOURCE_DIR}/backends
${glad_BINARY_DIR}/include # so imgui can find glad
)
target_include_directories(
imgui PRIVATE
${imgui_SOURCE_DIR}
${imgui_SOURCE_DIR}/backends
${glad_BINARY_DIR}/include # so imgui can find glad
)
target_link_libraries(
imgui PRIVATE
glad
glfw
${OPENGL_LIBRARY}
)
file(GLOB_RECURSE SOURCES_MATH src/math/*.cpp)
file(GLOB_RECURSE SOURCES_CONSOLE src/user_interaction/*.cpp)
file(GLOB_RECURSE SOURCES_GUI src/drawing/*.cpp)
file(GLOB_RECURSE SOURCES_UTILS src/utils/*.cpp)
file(GLOB_RECURSE TESTS tests/*.cpp)
# unit_test configuration
add_executable(
unit_tests
${TESTS}
${SOURCES_MATH}
${SOURCES_CONSOLE}
${SOURCES_GUI}
${SOURCES_UTILS}
)
target_include_directories(unit_tests PUBLIC googletest)
target_include_directories(unit_tests PUBLIC include)
target_include_directories(unit_tests PUBLIC imgui)
target_link_libraries(
unit_tests
imgui
glfw
glad
gtest
gtest_main
)
# triangle_intersection configuration
add_executable(
Interpol
src/main.cpp
${SOURCES_MATH}
${SOURCES_CONSOLE}
${SOURCES_GUI}
${SOURCES_UTILS}
)
target_include_directories(Interpol PUBLIC include)
target_include_directories(Interpol PUBLIC imgui)
target_include_directories(Interpol PUBLIC glad)
target_include_directories(Interpol PUBLIC glfw)
target_link_libraries(
Interpol
imgui
glfw
glad
)