-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
193 lines (176 loc) · 6.95 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
cmake_minimum_required (VERSION 3.8)
project ("Scaffolder")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# libigl
option(LIBIGL_WITH_OPENGL "Use OpenGL" OFF)
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" OFF)
option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)
option(IGL_STATIC_RUNTIME "Use LibIGL as static library" ON)
option(BUILD_SCAFFOLDER "Build binary" ON)
option(BUILD_PYSCAFFOLDER "Build python library" ON)
option(BUILD_WITH_OPENMP "USE OpenMP" ON)
add_definitions(-DOPENCTM_STATIC)
if(MSVC)
# Enable parallel compilation for Visual Studio
add_compile_options(/MP /bigobj /D_CRT_SECURE_NO_WARNINGS /Zc:__cplusplus)
add_definitions(-DNOMINMAX -D_USE_MATH_DEFINES -DWIN32_LEAN_AND_MEAN)
# Silencing some compile warnings
add_compile_options(
# Type conversion warnings. These can be fixed with some effort and possibly more verbose code.
/wd4267 # conversion from 'size_t' to 'type', possible loss of data
/wd4244 # conversion from 'type1' to 'type2', possible loss of data
/wd4018 # signed/unsigned mismatch
/wd4305 # truncation from 'double' to 'float'
# This one is from template instantiations generated by autoexplicit.sh:
/wd4667 # no function template defined that matches forced instantiation ()
# This one is easy to fix, just need to switch to safe version of C functions
/wd4996 # this function or variable may be unsafe
# This one is when using bools in adjacency matrices
/wd4804 #'+=': unsafe use of type 'bool' in operation
)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-pedantic)
endif()
message(STATUS "CMAKE SYSTEM NAME: ${CMAKE_SYSTEM_NAME}")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message(STATUS "[OSX Detected]")
add_definitions(-D_DARWIN_C_SOURCE -D_GNU_SOURCE -D_XOPEN_SOURCE=600)
add_compile_options(-faligned-allocation)
endif()
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
message(STATUS "[CLANG Detected]")
endif()
message(STATUS "PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}")
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/libigl/CMakeLists.txt" OR
NOT EXISTS "${PROJECT_SOURCE_DIR}/external/tbb/CMakeLists.txt" OR
NOT EXISTS "${PROJECT_SOURCE_DIR}/external/sol2/CMakeLists.txt" OR
NOT EXISTS "${PROJECT_SOURCE_DIR}/external/pybind11/CMakeLists.txt" OR
NOT EXISTS "${PROJECT_SOURCE_DIR}/external/vcglib/wrap/" OR
NOT EXISTS "${PROJECT_SOURCE_DIR}/external/OpenCTM-1.0.3/lib/openctm.h")
include(download_external_files)
download_external_files(
https://github.com/nodtem66/Scaffolder/releases/download/v1.5.2/external.tar.gz
"${PROJECT_SOURCE_DIR}/scripts/external.tar.gz"
7c85850c2983cced32efab8a290795dd5dd67710c48501e5f54d76b8d43be519
)
file(ARCHIVE_EXTRACT INPUT "${PROJECT_SOURCE_DIR}/scripts/external.tar.gz" DESTINATION ${PROJECT_SOURCE_DIR})
endif()
find_package(Threads REQUIRED)
find_package(LIBIGL REQUIRED)
find_package(TBB REQUIRED)
find_package(VCG REQUIRED)
find_package(Sol2 REQUIRED)
find_package(OpenCTM REQUIRED)
if(BUILD_WITH_OPENMP)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(OpenMP_CXX "${CMAKE_CXX_COMPILER}" CACHE STRING "" FORCE)
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" CACHE INTERNAL "OpenMP flags for Xcode toolchain.")
set(OpenMP_CXX_LIB_NAMES "omp" CACHE INTERNAL "OpenMP lib name for Xcode toolchain.")
set(OpenMP_omp_LIBRARY "/usr/local/opt/libomp/lib/libomp.dylib" CACHE INTERNAL "OpenMP lib name for Xcode toolchain.")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND ${CMAKE_C_COMPILER_ID} MATCHES "Clang")
set(OpenMP_C "${CMAKE_C_COMPILER}" CACHE STRING "" FORCE)
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" CACHE INTERNAL "OpenMP flags for Xcode toolchain.")
set(OpenMP_C_LIB_NAMES "omp" CACHE INTERNAL "OpenMP lib name for Xcode toolchain.")
endif()
find_package(OpenMP REQUIRED)
message(STATUS "OpenMP: ${OpenMP_CXX_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
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()
if(BUILD_SCAFFOLDER)
# Add your project files
file(GLOB MAIN_SOURCES
"${PROJECT_SOURCE_DIR}/include/*/*.c"
"${PROJECT_SOURCE_DIR}/include/*/*.cpp"
"${PROJECT_SOURCE_DIR}/src/utils.cpp"
"${PROJECT_SOURCE_DIR}/src/Scaffolder.cpp"
"${VCG_INCLUDE_DIR}/wrap/ply/plylib.cpp"
"${OpenCTM_INCLUDE_DIR}/*.c"
"${OpenCTM_INCLUDE_DIR}/liblzma/*.c"
)
include(update_deps_file)
update_deps_file("main_sources" "${MAIN_SOURCES}")
# Build binary
add_executable(${PROJECT_NAME} ${MAIN_SOURCES} ${PROJECT_SOURCE_DIR}/src/Main.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE
"${PROJECT_SOURCE_DIR}/include"
${TBB_INCLUDE_DIR}
${VCG_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR}
${SOL2_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
${OpenCTM_INCLUDE_DIR}
${LIBIGL_INCLUDE_DIR}
"${OpenCTM_INCLUDE_DIR}/liblzma/"
)
target_link_libraries(${PROJECT_NAME} PRIVATE
igl::core
tbb
Threads::Threads
OpenMP::OpenMP_CXX
${LUA_LIBRARIES}
)
add_executable("${PROJECT_NAME}.SliceTest"
${PROJECT_SOURCE_DIR}/src/SliceTest.cpp
${PROJECT_SOURCE_DIR}/src/utils.cpp
${VCG_INCLUDE_DIR}/wrap/ply/plylib.cpp
)
target_include_directories("${PROJECT_NAME}.SliceTest" PRIVATE
"${PROJECT_SOURCE_DIR}/include"
${VCG_INCLUDE_DIR}
${LIBIGL_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR}
${OpenCTM_INCLUDE_DIR}
"${OpenCTM_INCLUDE_DIR}/liblzma/"
)
target_link_libraries("${PROJECT_NAME}.SliceTest" PRIVATE tbb OpenMP::OpenMP_CXX)
# Install binary
include(GNUInstallDirs)
install(TARGETS "${PROJECT_NAME}" DESTINATION bin COMPONENT scaffolder)
install(TARGETS "${PROJECT_NAME}.SliceTest" DESTINATION bin COMPONENT scaffolder)
endif()
if(BUILD_PYSCAFFOLDER)
message(STATUS "[Build PyScaffolder]")
find_package(PyBind11 REQUIRED)
file(GLOB PYTHON_SOURCES
"${PROJECT_SOURCE_DIR}/src/python/*.cpp"
${PROJECT_SOURCE_DIR}/src/Scaffolder.cpp
${PROJECT_SOURCE_DIR}/src/utils.cpp
)
include(update_deps_file)
update_deps_file("python_sources" "${PYTHON_SOURCES}")
pybind11_add_module("Py${PROJECT_NAME}" ${PYTHON_SOURCES})
target_include_directories("Py${PROJECT_NAME}" PRIVATE
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/src/python/"
${TBB_INCLUDE_DIR}
${VCG_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR}
${SOL2_INCLUDE_DIR}
${LIBIGL_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
${PyBind11_INCLUDE_DIR}
${OpenCTM_INCLUDE_DIR}
"${OpenCTM_INCLUDE_DIR}/liblzma/"
)
target_link_libraries("Py${PROJECT_NAME}" PRIVATE
igl::core
tbb
Threads::Threads
OpenMP::OpenMP_CXX
${LUA_LIBRARIES}
)
include(GNUInstallDirs)
install(TARGETS "Py${PROJECT_NAME}"
COMPONENT python
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
endif()