-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
141 lines (122 loc) · 4.25 KB
/
Copy pathCMakeLists.txt
File metadata and controls
141 lines (122 loc) · 4.25 KB
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
cmake_minimum_required(VERSION 3.20)
project(hatching LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# ===========================================================================
# Dependencies via FetchContent
# ===========================================================================
include(FetchContent)
# --- Eigen (header-only linear algebra) ---
FetchContent_Declare(eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.4.0
GIT_SHALLOW TRUE
)
# --- GLFW (windowing) ---
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
FetchContent_Declare(glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.4
GIT_SHALLOW TRUE
)
# --- glad (pre-generated OpenGL 4.1 Core loader, vendored) ---
# Generated via: python -m glad --out-path third_party/glad --api gl:core=4.1 --reproducible c
# --- Dear ImGui (UI) ---
FetchContent_Declare(imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.91.8
GIT_SHALLOW TRUE
)
# --- tinyobjloader (OBJ file loading) ---
FetchContent_Declare(tinyobjloader
GIT_REPOSITORY https://github.com/tinyobjloader/tinyobjloader.git
GIT_TAG v2.0.0rc13
GIT_SHALLOW TRUE
)
# --- Google Test (testing, test-only) ---
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.2
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(eigen glfw tinyobjloader googletest imgui)
# --- glad: build from vendored pre-generated sources ---
add_library(glad_gl_core_41 STATIC
${CMAKE_SOURCE_DIR}/third_party/glad/src/gl.c
)
target_include_directories(glad_gl_core_41 PUBLIC
${CMAKE_SOURCE_DIR}/third_party/glad/include
)
# --- Dear ImGui: build as static library (no native CMakeLists.txt) ---
find_package(OpenGL REQUIRED)
set(IMGUI_DIR ${imgui_SOURCE_DIR})
add_library(imgui STATIC
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_demo.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
)
target_include_directories(imgui PUBLIC
${IMGUI_DIR}
${IMGUI_DIR}/backends
)
target_link_libraries(imgui PUBLIC glfw glad_gl_core_41 OpenGL::GL)
# ===========================================================================
# Core library (algorithms, no OpenGL dependency)
# ===========================================================================
add_library(hatching_core STATIC
src/triangle_mesh.cpp
src/geometry.cpp
src/direction_field.cpp
src/stripe_pattern.cpp
)
target_include_directories(hatching_core PUBLIC src)
target_link_libraries(hatching_core PUBLIC Eigen3::Eigen tinyobjloader)
# ===========================================================================
# Main application
# ===========================================================================
add_executable(hatching
src/main.cpp
src/renderer.cpp
src/camera.cpp
)
target_link_libraries(hatching PRIVATE
hatching_core
glfw
glad_gl_core_41
imgui
OpenGL::GL
)
# Copy shaders and assets next to the binary
add_custom_command(TARGET hatching POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/shaders $<TARGET_FILE_DIR:hatching>/shaders
)
# ===========================================================================
# Diagnostic tools (no OpenGL needed)
# ===========================================================================
add_executable(diagnose_omega tools/diagnose_omega.cpp)
target_link_libraries(diagnose_omega PRIVATE hatching_core)
# ===========================================================================
# Tests
# ===========================================================================
enable_testing()
add_executable(hatching_tests
tests/test_mesh.cpp
tests/test_geometry.cpp
tests/test_direction_field.cpp
tests/test_stripe_pattern.cpp
)
target_link_libraries(hatching_tests PRIVATE hatching_core GTest::gtest_main)
# Make test data paths available
target_compile_definitions(hatching_tests PRIVATE
TEST_DATA_DIR="${CMAKE_SOURCE_DIR}"
)
include(GoogleTest)
gtest_discover_tests(hatching_tests)