This repository was archived by the owner on May 15, 2025. It is now read-only.
forked from eryar/OcctImgui
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
145 lines (126 loc) · 4.36 KB
/
Copy pathCMakeLists.txt
File metadata and controls
145 lines (126 loc) · 4.36 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
142
143
144
145
cmake_minimum_required(VERSION 3.15)
# Project configuration
project(OcctImgui LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
# Set output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})
# Include directories
find_package(imgui REQUIRED)
find_package(OpenCASCADE REQUIRED)
find_package(Netgen CONFIG REQUIRED)
find_package(Boost REQUIRED COMPONENTS signals2 unit_test_framework)
find_package(nfd REQUIRED)
find_package(spdlog REQUIRED)
option(LIBIGL_USE_STATIC_LIBRARY "Use libIGL as static library" ON)
find_package(libigl REQUIRED)
find_package(Eigen3 REQUIRED)
# Enable testing with CTest
include(CTest)
enable_testing()
# Define test data directory
set(MESH_TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/data")
file(MAKE_DIRECTORY ${MESH_TEST_DATA_DIR})
# Create a library for shared components that will be used in both the main app and tests
add_library(OcctImguiLib STATIC
src/ais/Mesh_DataSource.cpp
src/mvvm/SelectionManager.cpp
src/model/IModel.cpp
src/model/GeometryModel.cpp
src/model/ModelFactory.cpp
src/model/ModelManager.cpp
src/model/ModelImporter.cpp
src/view/ImGuiView.cpp
src/view/OcctView.cpp
src/viewmodel/GeometryViewModel.cpp
src/viewmodel/ViewModelManager.cpp
src/window/WindowManager.cpp
src/input/InputManager.cpp
src/ApplicationBootstrapper.cpp
src/Application.cpp
src/GlfwOcctWindow.cpp
src/utils/Logger.cpp
src/utils/LoggerManager.cpp
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(OcctImguiLib PUBLIC OCCTIMGUI_DEBUG)
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
target_compile_definitions(OcctImguiLib PUBLIC OCCTIMGUI_RELWITHDEBINFO)
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(OcctImguiLib PUBLIC OCCTIMGUI_RELEASE)
endif()
target_include_directories(OcctImguiLib
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src # Only keep the src directory in the include path
)
target_link_libraries(OcctImguiLib
PUBLIC
${OpenCASCADE_LIBRARIES}
igl::igl_core
Eigen3::Eigen
nglib
ngcore
imgui::imgui
spdlog::spdlog
nfd::nfd
igl_copyleft::igl_copyleft_cgal
Boost::signals2
)
# Add executable target
add_executable(OcctImgui
src/main.cpp
)
target_include_directories(OcctImgui
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/window
${CMAKE_CURRENT_SOURCE_DIR}/src/input
)
# Link libraries
target_link_libraries(OcctImgui
PRIVATE
OcctImguiLib
)
target_compile_options(OcctImgui PRIVATE
$<$<CONFIG:Debug>:-g>
$<$<CONFIG:Release>:-O3>
)
option(OCCTIMGUI_BUILD_TESTING "Build tests" ON)
# Tests configuration
if(OCCTIMGUI_BUILD_TESTING)
# Create a function to add tests easily
function(add_boost_test TEST_NAME TEST_SOURCE)
add_executable(${TEST_NAME} ${TEST_SOURCE})
target_include_directories(${TEST_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/window
${CMAKE_CURRENT_SOURCE_DIR}/src/input
)
target_link_libraries(${TEST_NAME}
PRIVATE
OcctImguiLib
Boost::unit_test_framework
# Add other dependencies needed by your tests
)
# Define test target
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
# Tell Boost.Test to use dynamic linking
target_compile_definitions(${TEST_NAME} PRIVATE
BOOST_TEST_DYN_LINK
MESH_TEST_DATA_DIR="${MESH_TEST_DATA_DIR}"
)
endfunction()
# Add the tests
add_boost_test(model_test tests/model_test.cpp)
add_boost_test(model_manager_test tests/model_manager_test.cpp)
add_boost_test(mesh_datasource_test tests/mesh_datasource_test.cpp)
add_boost_test(geometry_model_test tests/geometry_model_test.cpp)
add_boost_test(model_importer_test tests/model_importer_test.cpp)
add_boost_test(signal_test tests/signal_test.cpp)
add_boost_test(message_bus_test tests/message_bus_test.cpp)
add_boost_test(mvvm_integration_test tests/mvvm_integration_test.cpp)
add_boost_test(property_test tests/property_test.cpp)
add_boost_test(selection_manager_test tests/selection_manager_test.cpp)
endif()