-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
174 lines (142 loc) · 6.15 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
167
168
169
170
171
172
173
174
cmake_minimum_required(VERSION 3.1)
project(simulator)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# set debug flag
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_BUILD_TYPE Release)
# Setting EIGEN3_ROOT here lets us override which Eigen library merely3d chooses
set(EIGEN3_ROOT ${PROJECT_SOURCE_DIR}/extern/eigen_3.3.4)
# Setting CEREALS_ROOT here
set(CEREALS_ROOT ${PROJECT_SOURCE_DIR}/extern/cereal/include)
set(CLI11_ROOT ${PROJECT_SOURCE_DIR}/extern/CLI11/include/CLI11)
if (UNIX)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif(OPENMP_FOUND)
endif (UNIX)
add_subdirectory(extern/merely3d)
add_subdirectory(extern/CompactNSearch)
set(TINY_OBJ_LOADER_INCLUDE ${CMAKE_SOURCE_DIR}/extern/tinyobjloader/include)
set(CLI11_FILES
${PROJECT_SOURCE_DIR}/extern/CLI11/include/CLI11/CLI11.hpp)
set(IMGUI_FILES
src/imgui/imgui.h
src/imgui/imgui.cpp
src/imgui/imconfig.h
src/imgui/imgui_draw.cpp
src/imgui/imgui_internal.h
src/imgui/stb_rect_pack.h
src/imgui/stb_textedit.h
src/imgui/stb_truetype.h
src/imgui/imgui_demo.cpp
src/imgui/imgui_event_handler.h
src/imgui/imgui_event_handler.cpp)
set(UTIL_FILES
src/util/obj.hpp
src/util/obj.cpp
src/util/triangle_mesh.hpp
src/util/triangle_mesh.cpp)
set(SOURCE_FILES
${CLI11_FILES}
${IMGUI_FILES}
${UTIL_FILES}
src/math_types.hpp
src/simulation.hpp
src/simulation.cpp
src/NeighborSearcher.hpp
src/NeighborSearcher.cpp
src/KernelHandler.hpp
src/KernelHandler.cpp
src/SPHSimulator.hpp
src/SPHSimulator.cpp
src/Particle.hpp
src/ParticleFunc.hpp
src/ParticleFunc.cpp
src/ParticleGenerator.hpp
src/ParticleGenerator.cpp
src/sim_record.hpp
src/mesh_record.hpp
)
set(DERIVED_CLASS_FOLDER src/derived_class)
set(DERIVED_CLASS_FILES
${DERIVED_CLASS_FOLDER}/SPHSimulator_2cubes.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_free_fall_motion.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_rigid_body.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_dam_breaking.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_double_dam_breaking.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_dam_breaking_thin.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_drop_center.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_drop_on_water.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_fluid_pillar.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_mid_column.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_mobile_rigid_body.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_wave_generator.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_moving_dam_break.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_watermill.hpp
${DERIVED_CLASS_FOLDER}/SPHSimulator_bullet.hpp
# when we have new simulation scenero, we do derive it from sphsimulator class, and add file here.
)
set(VISUAL_SOURCE_FILES
${CLI11_FILES}
${IMGUI_FILES}
${UTIL_FILES}
src/math_types.hpp
src/visual.hpp
src/visual.cpp
src/sim_record.hpp
src/Particle.hpp
src/mesh_record.hpp
src/visualizer_flag.hpp
)
# Compile source files into a static lib, so that we don't have to compile source files
# twice for our main executable and our unit tests
add_library(simulator_lib STATIC ${SOURCE_FILES} ${DERIVED_CLASS_FILES})
target_link_libraries(simulator_lib merely3d CompactNSearch)
target_include_directories(simulator_lib PUBLIC ${CMAKE_SOURCE_DIR}/src ${TINY_OBJ_LOADER_INCLUDE} ${CEREALS_ROOT} ${CLI11_ROOT} ${DERIVED_CLASS_FOLDER})
add_library(sim_visual_lib STATIC ${VISUAL_SOURCE_FILES} )
target_link_libraries(sim_visual_lib merely3d CompactNSearch)
target_include_directories(sim_visual_lib PUBLIC ${CMAKE_SOURCE_DIR}/src ${TINY_OBJ_LOADER_INCLUDE} ${CEREALS_ROOT} ${CLI11_ROOT})
add_executable(visualizer src/visualizer.cpp)
target_link_libraries(visualizer sim_visual_lib)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_BINARY_DIR})
# # Add source files for unit tests here.
set(TEST_FILES tests/sample_tests.cpp)
set(KERNEL_TEST_FILES tests/kernel_tests.cpp)
add_executable(simulator_test tests/testmain.cpp ${TEST_FILES})
target_link_libraries(simulator_test simulator_lib)
add_executable(kernel_test tests/testmain.cpp ${KERNEL_TEST_FILES})
target_link_libraries(kernel_test simulator_lib)
# # merely3d already ships with Catch for unit testing, so let's just use the same
target_include_directories(simulator_test PRIVATE extern/merely3d/extern/catch )
target_include_directories(kernel_test PRIVATE extern/merely3d/extern/catch )
add_executable(save_simulation src/save_simulation.cpp)
target_link_libraries(save_simulation simulator_lib)
target_include_directories(save_simulation PRIVATE ${EIGEN3_ROOT} ${CEREALS_ROOT} ${CLI11_ROOT})
set(MARCHING_CUBE_LIB_FILES
${CLI11_FILES}
${IMGUI_FILES}
src/marching_cube.cpp
src/marching_cube.hpp
src/marching_cubes_lut.hpp
src/derived_class/marching_cube_torus.hpp
src/derived_class/marching_cube_sphere.hpp
src/derived_class/marching_cube_fluid.hpp
)
add_library(marching_cube_lib STATIC ${MARCHING_CUBE_LIB_FILES} ${VISUAL_SOURCE_FILES})
target_link_libraries(marching_cube_lib merely3d)
target_include_directories(marching_cube_lib PUBLIC
${CMAKE_SOURCE_DIR}/src
${CLI11_ROOT}
${EIGEN_ROOT}
${CMAKE_SOURCE_DIR}/src/derived_class
${TINY_OBJ_LOADER_INCLUDE}
${CEREALS_ROOT}
)
add_executable(test_marching_cube src/test_marching_cube.cpp)
target_link_libraries(test_marching_cube marching_cube_lib)
#target_include_directories(test_marching_cube PUBLIC ${CMAKE_SOURCE_DIR}/src )
add_executable(save_fluid_mesh src/save_fluid_mesh.cpp)
target_link_libraries(save_fluid_mesh CompactNSearch merely3d simulator_lib marching_cube_lib)
target_include_directories(save_fluid_mesh PRIVATE ${EIGEN3_ROOT} ${EIGEN_ROOT} ${CEREALS_ROOT} ${CLI11_ROOT})