-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
221 lines (176 loc) · 7.44 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
cmake_minimum_required(VERSION 3.1)
project(seamlesssurfmap)
# Print the build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release" FORCE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
set(EXTRA_LIBS "")
if (UNIX AND NOT APPLE)
set(EXTRA_LIBS "pthread")
endif()
message("EXTRA_LIBS: ${EXTRA_LIBS}")
#--------------------+
# External libraries |
#--------------------+
include_directories(${CMAKE_CURRENT_LIST_DIR}/external)
# MOSEK
find_package(MOSEK REQUIRED)
include_directories(${MOSEK_INCLUDE_DIR})
function (fix_mosek_lib_path app)
if (NOT APPLE)
return()
endif()
# Convince cmake to fix the linker path for mosek
# http://www.alecjacobson.com/weblog/?p=4878
add_custom_command(TARGET ${app} POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change `otool -L ${app} | sed -n -e \""s/.*\\(libmosek.*dylib\\).*/\\1/p"\"` ${MOSEK_C_LIBRARY} ${app})
add_custom_command(TARGET ${app} POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change `otool -L ${app} | sed -n -e \""s/.*\\(libfusion.*dylib\\).*/\\1/p"\"` ${MOSEK_CXX_LIBRARY} ${app})
endfunction()
# geometry-central
set(GC_EIGEN_LOCATION ${CMAKE_CURRENT_LIST_DIR}/external/eigen CACHE PATH "Eigen path")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/geometry-central)
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/geometry-central/include)
# spdlog
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/spdlog/include)
# libigl
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/libigl/include)
add_definitions(-DLIBIGL_TUTORIAL_DATA=\"${CMAKE_CURRENT_LIST_DIR}/external/libigl-tutorial-data\")
# UltiMaille
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/ultimaille)
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/ultimaille)
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/ultimaille/ext)
# Eigen
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/eigen)
# GLEW
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/glew-2.2.0/build/cmake)
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/glew-2.2.0/include)
## 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)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/glfw)
# ImGUI (CMakeLists.txt not provided)
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/imgui)
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/imgui/backends)
add_library(imgui
${CMAKE_CURRENT_LIST_DIR}/external/imgui/imgui.cpp
# ${CMAKE_CURRENT_LIST_DIR}/external/imgui/imgui_demo.cpp # Useful for testing via ImGui::ShowDemoWindow
${CMAKE_CURRENT_LIST_DIR}/external/imgui/imgui_draw.cpp
${CMAKE_CURRENT_LIST_DIR}/external/imgui/imgui_tables.cpp
${CMAKE_CURRENT_LIST_DIR}/external/imgui/imgui_widgets.cpp
${CMAKE_CURRENT_LIST_DIR}/external/imgui/backends/imgui_impl_glfw.cpp
${CMAKE_CURRENT_LIST_DIR}/external/imgui/backends/imgui_impl_opengl2.cpp)
target_link_libraries(imgui glfw)
#---------+
# My code |
#---------+
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
# hard-coded data path
add_definitions(-DDATA_PATH=\"${CMAKE_CURRENT_LIST_DIR}/data\")
# Version
find_package(Git QUIET)
set(VERSIONTAG "unknown")
if (GIT_FOUND OR Git_FOUND)
execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD RESULT_VARIABLE RET OUTPUT_VARIABLE COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT RET)
set(VERSIONTAG "${COMMIT}")
endif()
endif()
message(STATUS "Version tag: ${VERSIONTAG}")
configure_file("src/version.cpp.in" "version.cpp")
add_library(version version.cpp)
# MOSEK example
add_executable(test_lo1 test/lo1.cc)
target_link_libraries(test_lo1 ${MOSEK_C_LIBRARY} ${MOSEK_CXX_LIBRARY})
fix_mosek_lib_path(test_lo1)
# Utility library
add_library(util src/util.cpp)
target_link_libraries(util geometry-central)
# Handle-cutting library
add_library(handlecut src/handlecut.cpp)
target_link_libraries(handlecut util)
# Surface co-cutting library
add_library(cocut src/cocut.cpp)
target_link_libraries(cocut util)
# Untangling library
add_library(untangle src/untangle.cpp)
target_link_libraries(untangle ultimaille)
# G-mapping library
add_library(gmap src/gmap.cpp)
target_link_libraries(gmap util ${MOSEK_C_LIBRARY} ${MOSEK_CXX_LIBRARY} untangle)
# Path lifting library
add_library(lift src/transformation.cpp src/lift.cpp)
target_link_libraries(lift util)
# Refinement library
add_library(refine src/refine.cpp)
target_link_libraries(refine util)
# Tutte embedding test
add_executable(test_tutte test/tutte.cpp)
target_link_libraries(test_tutte ${MOSEK_C_LIBRARY} ${MOSEK_CXX_LIBRARY} ${EXTRA_LIBS})
fix_mosek_lib_path(test_tutte)
# Isometric mapping test
add_executable(test_isometric test/isometric.cpp)
target_link_libraries(test_isometric util ${MOSEK_C_LIBRARY} ${MOSEK_CXX_LIBRARY} ${EXTRA_LIBS})
fix_mosek_lib_path(test_isometric)
# Conformal mapping test
add_executable(test_conformal test/conformal.cpp)
target_link_libraries(test_conformal util ${MOSEK_C_LIBRARY} ${MOSEK_CXX_LIBRARY} ${EXTRA_LIBS})
fix_mosek_lib_path(test_conformal)
# G-flattening test
add_executable(test_gflatten test/gflatten.cpp)
target_link_libraries(test_gflatten util ${MOSEK_C_LIBRARY} ${MOSEK_CXX_LIBRARY})
fix_mosek_lib_path(test_gflatten)
# Surface cutting test
add_executable(test_cut test/cut.cpp)
target_link_libraries(test_cut util)
# Surface co-cutting test
add_executable(test_cocut test/cocut.cpp)
target_link_libraries(test_cocut cocut)
# G-mapping test
add_executable(test_gmap test/gmap.cpp)
target_link_libraries(test_gmap gmap)
fix_mosek_lib_path(test_gmap)
# Path lifting test
add_executable(test_lift test/lift.cpp)
target_link_libraries(test_lift lift)
# Refinement test
add_executable(test_refine test/refine.cpp)
target_link_libraries(test_refine refine)
# Handle-cutting test
add_executable(test_handlecut test/handlecut.cpp)
target_link_libraries(test_handlecut handlecut)
# Handle-cutter app
add_executable(app_handlecut src/app_handlecut.cpp)
target_link_libraries(app_handlecut handlecut version)
set_target_properties(app_handlecut PROPERTIES OUTPUT_NAME handlecut) # https://gist.github.com/jlgerber/eafc4ee2b9954e27dd2bb009496b1b03
# Landmarker app
add_executable(landmarker src/app_landmarker.cpp)
target_link_libraries(landmarker glew imgui handlecut version)
# Seamless Surface Mapping app
add_executable(seamlesssurfmap src/app_seamlesssurfmap.cpp)
target_link_libraries(seamlesssurfmap cocut gmap lift refine version)
fix_mosek_lib_path(seamlesssurfmap)
# Untangle app
add_executable(app_untangle src/app_untangle.cpp)
target_link_libraries(app_untangle untangle util version)
set_target_properties(app_untangle PROPERTIES OUTPUT_NAME untangle) # https://gist.github.com/jlgerber/eafc4ee2b9954e27dd2bb009496b1b03
# UV Projector app
add_executable(uvprojector src/app_uvprojector.cpp)
target_link_libraries(uvprojector glew imgui geometry-central)
# GoogleTest
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/1b18723e874b256c1e39378c6774a90701d70f7a.zip
)
FetchContent_MakeAvailable(googletest)
enable_testing()
include(GoogleTest)
# Unit test for util.cpp
add_executable(test_util ${CMAKE_CURRENT_LIST_DIR}/test/util.cpp)
target_link_libraries(test_util util gtest_main)
gtest_discover_tests(test_util)