-
Notifications
You must be signed in to change notification settings - Fork 22
/
CMakeLists.txt
143 lines (122 loc) · 6.03 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
cmake_minimum_required(VERSION 3.1.0)
project(RobustPureHexMeshing)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Build geogram
set(THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern)
include(geogram.cmake)
set_property(TARGET geogram PROPERTY FOLDER "dependencies")
#find_package(LIBIGL QUIET)
#
#if (NOT LIBIGL_FOUND)
# message(FATAL_ERROR "libigl not found --- You can download it using: \n git clone --recursive https://github.com/libigl/libigl.git ${PROJECT_SOURCE_DIR}/../libigl")
#endif()
#
# Compilation flags: adapt to your needs
if(MSVC)
# Enable parallel compilation
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /bigobj /openmp")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR} )
else()
# Libigl requires a modern C++ compiler that supports c++11
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "." )
endif()
if(WIN32)
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") # Add the directory where FindSuiteSparse.cmake module can be
set(SuiteSparse_USE_LAPACK_BLAS ON)
find_package(SuiteSparse QUIET NO_MODULE) # 1st: Try to locate the *config.cmake file.
if(NOT SuiteSparse_FOUND)
find_package(SuiteSparse REQUIRED) # 2nd: Use FindSuiteSparse.cmake module
include_directories(${SuiteSparse_INCLUDE_DIRS})
else()
message(STATUS "Find SuiteSparse : include(${USE_SuiteSparse})")
include(${USE_SuiteSparse})
endif()
MESSAGE(STATUS "SuiteSparse_LIBS: ${SuiteSparse_LIBRARIES}")
# ------------------------------------------------------------------
# End of SuiteSparse detection
# ------------------------------------------------------------------
else()
# ------------------------------------------------------------------
# Detect SuiteSparse libraries:
# If not found automatically, set SuiteSparse_DIR in CMake to the
# directory where SuiteSparse was built.
# ------------------------------------------------------------------
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/..") # Add the directory where FindSuiteSparse.cmake module can be found.
find_package(SuiteSparse REQUIRED) # 1st: Try to locate the *config.cmake file.
if(CSPARSE_FOUND AND CHOLMOD_FOUND)
include_directories(${CHOLMOD_INCLUDE_DIR} ${CSPARSE_INCLUDE_DIR})
else()
#message(FATAL_ERROR "UNABLE to Find SuiteSpars, pass SUITE_SPARSE_ROOT to cmake")
message("UNABLE to Find SuiteSpars, pass SUITE_SPARSE_ROOT to cmake")
endif()
MESSAGE(STATUS "SuiteSparse_LIBS: ${CHOLMOD_LIBRARY} ${CHOLMOD_INCLUDE_DIR}")
# ------------------------------------------------------------------
# End of SuiteSparse detection
# ------------------------------------------------------------------
endif()
# libigl options: choose between header only and compiled static library
# Header-only is preferred for small projects. For larger projects the static build
# considerably reduces the compilation times
option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)
# add a customizable menu bar
option(LIBIGL_WITH_NANOGUI "Use Nanogui menu" ON)
# libigl options: choose your dependencies (by default everything is OFF except opengl)
option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" ON)
option(LIBIGL_WITH_OPENGL "Use OpenGL" ON)
option(LIBIGL_WITH_GLFW "Use GLFW" ON)
option(LIBIGL_WITH_BBW "Use BBW" OFF)
option(LIBIGL_WITH_EMBREE "Use Embree" ON)
option(LIBIGL_WITH_PNG "Use PNG" ON)
option(LIBIGL_WITH_TETGEN "Use Tetgen" OFF)
option(LIBIGL_WITH_TRIANGLE "Use Triangle" ON)
option(LIBIGL_WITH_XML "Use XML" OFF)
option(LIBIGL_WITH_LIM "Use LIM" OFF)
option(LIBIGL_WITH_COMISO "Use CoMiso" OFF)
option(LIBIGL_WITH_MATLAB "Use Matlab" OFF) # This option is not supported yet
option(LIBIGL_WITH_MOSEK "Use MOSEK" OFF) # This option is not supported yet
option(LIBIGL_WITH_CGAL "Use CGAL" OFF)
if(LIBIGL_WITH_CGAL) # Do not remove or move this block, the cgal build system fails without it
find_package(CGAL REQUIRED)
set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "CGAL's CMAKE Setup is super annoying ")
include(${CGAL_USE_FILE})
endif()
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/extern/libigl/shared/cmake" "libigl")
# libigl information
message("libigl includes: ${LIBIGL_INCLUDE_DIRS}")
message("libigl libraries: ${LIBIGL_LIBRARIES}")
message("libigl extra sources: ${LIBIGL_EXTRA_SOURCES}")
message("libigl extra libraries: ${LIBIGL_EXTRA_LIBRARIES}")
message("libigl definitions: ${LIBIGL_DEFINITIONS}")
# Build TBB
set(TBB_BUILD_STATIC ON CACHE BOOL " " FORCE)
set(TBB_BUILD_SHARED OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TBBMALLOC OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TBBMALLOC_PROXY OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TESTS OFF CACHE BOOL " " FORCE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extern/tbb extern_build/tbb)
set_property(TARGET tbb_static tbb_def_files PROPERTY FOLDER "dependencies")
# Build VCG
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extern/vcg extern_build/vcg)
set_property(TARGET vcg PROPERTY FOLDER "dependencies")
# Prepare the build environment
include_directories(
${LIBIGL_INCLUDE_DIRS}
# Intel Thread Building Blocks
${CMAKE_CURRENT_SOURCE_DIR}/extern/tbb/include
# VCG
${CMAKE_CURRENT_SOURCE_DIR}/extern/vcg
${CMAKE_CURRENT_SOURCE_DIR}/extern/geogram
)
add_definitions(${LIBIGL_DEFINITIONS})
add_definitions(-DENABLE_SERIALIZATION)
add_definitions(-DNOMINMAX)
file(GLOB header *.h grid_meshing/*.h)
file(GLOB source *.cpp grid_meshing/*.cpp)
add_executable(${PROJECT_NAME} ${source} ${header})
# Build geogram
set(THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern)
include(geogram.cmake)
set_property(TARGET geogram PROPERTY FOLDER "dependencies")
target_link_libraries(${PROJECT_NAME} PUBLIC geogram tbb_static vcg ${LIBIGL_LIBRARIES} ${LIBIGL_EXTRA_LIBRARIES})