-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
164 lines (131 loc) · 4.52 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
# Copyright (c) 2022 The University of Washington and Contributors
#
# SPDX-License-Identifier: LicenseRef-UW-Non-Commercial
cmake_minimum_required(VERSION 3.14)
project(passive-gripper)
option(CLUSTER_RELEASE_BUILD "Release build that should run on cluster" OFF)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Set build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
if (CLUSTER_RELEASE_BUILD)
# Enable link-time optimization
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "Link time optimization enabled")
endif()
# Add your project files
file(GLOB_RECURSE CORE_SRCFILES "include/passive-gripper/*.cpp")
file(GLOB_RECURSE UI_SRCFILES "src-ui/*.cpp")
file(GLOB_RECURSE BATCH_SRCFILES "src-batch/*.cpp")
include_directories("include")
if (MSVC)
# For Microsoft compiler
set_source_files_properties(
${CORE_SRCFILES}
PROPERTIES
COMPILE_FLAGS "/W4"
)
set_source_files_properties(
${UI_SRCFILES}
PROPERTIES
COMPILE_FLAGS "/W4"
)
set_source_files_properties(
${BATCH_SRCFILES}
PROPERTIES
COMPILE_FLAGS "/W4"
)
# Find LAPACK
set(LAPACK_DIR "external/lapack")
find_package(LAPACK CONFIG REQUIRED)
# Copy shared libraries to binary directory
file(GLOB LAPACK_DLLS ${LAPACK_DIR}/*.dll)
foreach (lapack_lib ${LAPACK_DLLS})
message(STATUS "Copying ${lapack_lib} to build directory")
file(COPY ${lapack_lib} DESTINATION ${PROJECT_BINARY_DIR})
endforeach()
else()
# For other compilers
set_source_files_properties(
${CORE_SRCFILES}
PROPERTIES
COMPILE_FLAGS "-Wall -Wextra -pedantic"
)
set_source_files_properties(
${UI_SRCFILES}
PROPERTIES
COMPILE_FLAGS "-Wall -Wextra -pedantic"
)
set_source_files_properties(
${BATCH_SRCFILES}
PROPERTIES
COMPILE_FLAGS "-Wall -Wextra -pedantic"
)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
find_package(LAPACK)
endif()
message(STATUS "Copying assets")
file(COPY assets DESTINATION ${PROJECT_BINARY_DIR})
# Link OpenMP
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
# Qhull
find_package(Qhull CONFIG REQUIRED)
# NLOPT
find_package(NLopt CONFIG REQUIRED)
# CGAL
find_package(CGAL CONFIG REQUIRED)
# Boost
find_package(Boost COMPONENTS system filesystem REQUIRED)
# Autodiff (not the best way)
include_directories("external/autodiff")
# Link libigl
option(LIBIGL_WITH_OPENGL "Use OpenGL" ON)
option(LIBIGL_WITH_PNG "Use PNG" ON)
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" ON)
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use IMGUI" ON)
option(LIBIGL_WITH_EMBREE "Use Embree" ON)
option(LIBIGL_WITH_CGAL "Use CGAL" ON)
find_package(LIBIGL REQUIRED QUIET)
# Swept Volume
file(GLOB_RECURSE SWEPT_VOLUME_SRCFILES "external/swept-volumes/include/*.cpp")
add_library(swept-volume ${SWEPT_VOLUME_SRCFILES})
target_link_libraries(swept-volume igl::core igl::opengl igl::cgal)
include_directories("external/swept-volumes/include")
# ikfast
add_library(ikfast "external/ikfast/ikfast61.cpp")
include_directories("external/ikfast")
# Linking
set(CORE_LINK_LIBS ikfast igl::core igl::embree igl::png igl::cgal lapack Qhull::qhullcpp NLopt::nlopt CGAL::CGAL swept-volume)
if (NOT MSVC)
list(APPEND CORE_LINK_LIBS stdc++fs Qhull::qhullstatic_r)
else()
list(APPEND CORE_LINK_LIBS Qhull::qhull_r)
endif()
set(UI_LINK_LIBS psg-core igl::core igl::opengl_glfw igl::opengl_glfw_imgui Boost::filesystem Boost::system)
set(BATCH_LINK_LIBS psg-core Boost::filesystem Boost::system)
if (NOT MSVC)
list(APPEND BATCH_LINK_LIBS stdc++fs)
endif()
# Enable easy profiler
if (ENABLE_EASY_PROFILER)
message(STATUS "Using easy profiler in path:" ${EASY_PROFILER_LIB_PATH})
list(APPEND CMAKE_PREFIX_PATH ${EASY_PROFILER_LIB_PATH})
find_package(easy_profiler REQUIRED)
list(APPEND CORE_LINK_LIBS easy_profiler)
add_compile_definitions(COMPILE_WITH_EASY_PROFILER)
endif()
add_library(psg-core ${CORE_SRCFILES})
target_link_libraries(psg-core ${CORE_LINK_LIBS})
add_executable(${PROJECT_NAME} ${UI_SRCFILES})
target_link_libraries(${PROJECT_NAME} ${UI_LINK_LIBS})
add_executable(psg-batch ${BATCH_SRCFILES})
target_link_libraries(psg-batch ${BATCH_LINK_LIBS})