forked from wjakob/instant-meshes
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
148 lines (129 loc) · 5.21 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
cmake_minimum_required (VERSION 2.8.3)
project(instant_meshes)
option(INSTANT_MESHES_DEV_MODE "Instant meshes developer mode" OFF)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ext/rply/rply.c")
message(FATAL_ERROR "The Instant Meshes dependency repositories are missing! "
"You probably did not clone the project with --recursive. It is possible to recover "
"by calling \"git submodule update --init --recursive\"")
endif()
# Enable folders for projects in Visual Studio
if (CMAKE_GENERATOR MATCHES "Visual Studio")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
# Sanitize build environment for static build with C++11
if (MSVC)
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
# Parallel build on MSVC (all targets)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
# Disable Eigen vectorization for Windows 32 bit builds (issues with unaligned access segfaults)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DEIGEN_DONT_ALIGN")
endif()
# Static build
set(CompilerFlags
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
elseif(APPLE)
# Try to auto-detect a suitable SDK
# Commented out for now -- causes a too new SDK to be selected on AppVeyor
#execute_process(COMMAND bash -c "xcodebuild -version -sdk | grep MacOSX | grep Path | head -n 1 | cut -f 2 -d ' '" OUTPUT_VARIABLE CMAKE_OSX_SYSROOT)
#string(REGEX REPLACE "(\r?\n)+$" "" CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT}")
#string(REGEX REPLACE "^.*X([0-9.]*).sdk$" "\\1" CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_OSX_SYSROOT}")
endif()
# Enable C++11 mode on GCC / Clang
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
# Compile instant meshes with various compiler warnings turned on
if(MSVC)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-anonymous-struct -Wno-c99-extensions -Wno-nested-anon-types")
endif()
endif()
# Header file directories of dependency libraries
include_directories(
# Disjoint set data structure
${CMAKE_CURRENT_SOURCE_DIR}/ext/dset
# Parallel stable sort
${CMAKE_CURRENT_SOURCE_DIR}/ext/pss
# Pseudorandom number generator
${CMAKE_CURRENT_SOURCE_DIR}/ext/pcg32
# RPLY mesh I/O library
${CMAKE_CURRENT_SOURCE_DIR}/ext/rply
# Half precision type
${CMAKE_CURRENT_SOURCE_DIR}/ext/half
# Eigen (must be set with -DEIGEN3_INCLUDE_DIR)
${EIGEN3_INCLUDE_DIR}
)
include_directories(
${TBB_INCLUDE_DIR} # Allow for extra include paths (ios builds tbb in 3rdparty)
/opt/local/include # Make sure we can find tbb with Mac + Macports
/usr/local/include # Make sure we can find tbb with Mac + Homebrew
/opt/homebrew/include # Make sure we can find tbb with Mac + Homebrew + M1
)
if (INSTANT_MESHES_DEV_MODE)
add_definitions(-DDEV_MODE)
endif()
add_library(instant_meshes
src/aabb.h
src/common.h
src/meshio.h src/meshio.cpp
src/normal.h src/normal.cpp
src/adjacency.h src/adjacency.cpp
src/meshstats.h src/meshstats.cpp
src/hierarchy.h src/hierarchy.cpp
src/extract.h src/extract.cpp
src/field.h src/field.cpp
src/bvh.h src/bvh.cpp
src/subdivide.h src/subdivide.cpp
src/reorder.h src/reorder.cpp
src/serializer.h src/serializer.cpp
src/batch.h src/batch.cpp
src/smoothcurve.h src/smoothcurve.cpp
src/cleanup.h src/cleanup.cpp
src/dedge.h src/dedge.cpp
ext/rply/rply.c
)
if (WIN32)
# Quench some warnings on MSVC
if (MSVC)
set_source_files_properties(ext/rply/rply.c PROPERTIES COMPILE_FLAGS "/wd4127")
endif()
elseif (APPLE)
#pass
else()
# Insulate from a few types of ABI changes by statically linking against libgcc and libstdc++
set_target_properties(instant_meshes PROPERTIES LINK_FLAGS "-static-libgcc")
#set_target_properties(instant_meshes PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
endif()
target_link_libraries(instant_meshes tbb)
install(TARGETS instant_meshes
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(FILES src/batch.h src/common.h
DESTINATION include/instant_meshes
)