Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
335 lines (281 sloc) 10.3 KB
CMAKE_MINIMUM_REQUIRED(VERSION 3.11.1)
project(Mandoline
DESCRIPTION "A robust cut-cell mesh generator"
LANGUAGES CXX)
SET(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(MTAO_PATH "" CACHE STRING "location of mtao core libs" )
SET(LIBIGL_PATH "" CACHE STRING "location of libigl libs" )
OPTION(USE_OPENGL "Build opengl stuff" ON)
IF(APPLE)
SET(USE_OPENMP_PRE OFF)
ELSE(APPLE)
SET(USE_OPENMP_PRE ON)
ENDIF(APPLE)
OPTION(USE_OPENMP "Use OpenMP stuff" ${USE_OPENMP_PRE})
OPTION(HANDLE_SELF_INTERSECTIONS "Handle Self-Intersections" ON)
include(FetchContent REQUIRED)
MESSAGE(STATUS "MTAO Path: ${MTAO_PATH}")
OPTION(MTAO_USE_ELTOPO "Should we build the el topo submodule" OFF)
OPTION(MTAO_USE_LOSTOPOS "Should we build the LOS Topos submodule" OFF)
OPTION(MTAO_USE_OPENGL "Build opengl stuff" ${USE_OPENGL})
OPTION(MTAO_USE_PNGPP "Use PNG++ for screenshots" OFF)
if(MTAO_PATH)
ADD_SUBDIRECTORY("${MTAO_PATH}" ${CMAKE_BINARY_DIR}/mtao EXCLUDE_FROM_ALL)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${MTAO_PATH}/cmake")
else()
FetchContent_Declare(
mtao
GIT_REPOSITORY https://github.com/mtao/core.git
GIT_TAG 5cd1e17a409d89de68afe34b4c45eecc6f1fcc00
)
if(${CMAKE_VERSION} VERSION_LESS 3.14)
FetchContent_Populate(mtao)
add_subdirectory(${mtao_SOURCE_DIR} ${mtao_BINARY_DIR} EXCLUDE_FROM_ALL)
else()
FetchContent_MakeAvailable(mtao)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${mtao_SOURCE_DIR}/cmake")
endif()
FIND_PACKAGE(Eigen3 3.3.9)
if(NOT Eigen3_FOUND)
FetchContent_Declare(
eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG bcbaad6d874d451817457ae0603f953cda3c0c06
)
if(${CMAKE_VERSION} VERSION_LESS 3.14)
FetchContent_Populate(eigen)
add_subdirectory(${eigen_SOURCE_DIR} ${eigen_BINARY_DIR} EXCLUDE_FROM_ALL)
else()
FetchContent_MakeAvailable(eigen)
endif()
ENDIF()
IF(USE_OPENMP)
FIND_PACKAGE(OpenMP REQUIRED)
ENDIF(USE_OPENMP)
MESSAGE(STATUS "MODULE PATH:${CMAKE_MODULE_PATH}")
#FIND_PACKAGE(libigl REQUIRED)
FIND_PACKAGE(Boost COMPONENTS thread REQUIRED)
MESSAGE(STATUS "LIBIGL Path: ${LIBIGL_PATH}")
option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF)
option(LIBIGL_WITH_COMISO "Use CoMiso" OFF)
option(LIBIGL_WITH_EMBREE "Use Embree" OFF)
option(LIBIGL_WITH_OPENGL "Use OpenGL" OFF)
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" OFF)
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" OFF)
option(LIBIGL_WITH_PNG "Use PNG" OFF)
option(LIBIGL_WITH_TETGEN "Use Tetgen" OFF)
option(LIBIGL_WITH_TRIANGLE "Use Triangle" OFF)
option(LIBIGL_WITH_PREDICATES "Use exact predicates" OFF)
option(LIBIGL_WITH_XML "Use XML" OFF)
option(LIBIGL_WITH_PYTHOFF "Use Python" OFF)
option(LIBIGL_SKIP_DOWNLOAD "Skip downloading external libraries" ON)
if(LIBIGL_PATH)
ADD_SUBDIRECTORY("${LIBIGL_PATH}" ${CMAKE_BINARY_DIR}/libigl EXCLUDE_FROM_ALL)
else()
FetchContent_Declare(
libigl
GIT_REPOSITORY https://github.com/libigl/libigl.git
#GIT_TAG f6b406427400ed7ddb56cfc2577b6af571827c8c
GIT_TAG v2.1.0
)
if(${CMAKE_VERSION} VERSION_LESS 3.14)
FetchContent_Populate(libigl)
add_subdirectory(${libigl_SOURCE_DIR} ${libigl_BINARY_DIR} EXCLUDE_FROM_ALL)
else()
FetchContent_MakeAvailable(libigl)
endif()
endif()
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR}/unsupported)
find_package(Protobuf REQUIRED)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS proto/cutmesh.proto)
protobuf_generate_python(PROTO_PY proto/cutmesh.proto)
ADD_LIBRARY(cutmesh_proto OBJECT ${PROTO_SRCS} ${PROTO_HDRS})
TARGET_LINK_LIBRARIES(cutmesh_proto protobuf::libprotobuf)
TARGET_INCLUDE_DIRECTORIES(cutmesh_proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
find_package(CGAL)
IF(HANDLE_SELF_INTERSECTIONS)
SET(SELF_INTERSECTION_LIBS
gmp CGAL::CGAL mpfr
)
SET(COMMON_SRCS
#src/diffgeo_utils.cpp
)
SET(CUTMESH2_SRCS
src/mesh2.cpp
)
SET(CUTMESH3_SRCS
src/mesh3.cpp
src/cutcell.cpp
src/proto_util.cpp
src/barycentric_triangle_face.cpp
src/cutface.cpp
src/adaptive_grid.cpp
)
SET(CUTMESH_HDRS
include/mandoline/line_impl.hpp
include/mandoline/line.hpp
include/mandoline/mesh_impl.hpp
include/mandoline/mesh.hpp
include/mandoline/coord_masked_geometry.hpp
#include/mandoline/diffgeo_utils.hpp
include/mandoline/coord_mask.hpp
include/mandoline/adaptive_grid.hpp
$<TARGET_OBJECTS:cutmesh_proto>
)
SET(CUTMESH2_HDRS
${CUTMESH_HDRS}
include/mandoline/mesh2.hpp
)
SET(CUTMESH3_HDRS
${CUTMESH_HDRS}
include/mandoline/construction/cell_collapser.hpp
include/mandoline/construction/face_collapser.hpp
include/mandoline/construction/remesh_self_intersections.hpp
include/mandoline/proto_util.hpp
include/mandoline/cutface.hpp
include/mandoline/cutface_impl.hpp
include/mandoline/barycentric_triangle_face.hpp
include/mandoline/mesh3.hpp
include/mandoline/cutcell.hpp
)
SET(CONSTRUCTION_SRCS
src/construction/generator3_make_faces.cpp
src/construction/generator.cpp
src/construction/generator3.cpp
src/construction/cell_collapser.cpp
src/construction/remesh_self_intersections.cpp
src/construction/generator2.cpp
src/construction/subgrid_transformer.cpp
src/construction/face_collapser.cpp
src/construction/construct.cpp
)
SET(CONSTRUCTION_HDRS
${CUTMESH2_HDRS}
${CUTMESH3_HDRS}
include/mandoline/construction/generator.hpp
include/mandoline/construction/generator_impl.hpp
include/mandoline/construction/vertex_types.hpp
include/mandoline/construction/vertex_types_impl.hpp
include/mandoline/construction/cutdata.hpp
include/mandoline/construction/cutdata_impl.hpp
include/mandoline/construction/facet_intersections.hpp
include/mandoline/construction/facet_intersections_impl.hpp
include/mandoline/construction/subgrid_transformer.hpp
include/mandoline/construction/construct.hpp
)
if(USE_OPENGL)
set(CONSTRUCTION_SRCS ${CONSTRUCTION_SRCS} src/construction/construct_imgui.cpp)
set(CONSTRUCTION_HDRS ${CONSTRUCTION_HDRS} src/construction/construct_imgui.cpp)
endif()
SET(MANDOLINE2_SRCS
${CUTMESH2_SRCS}
${CUTMESH2_HDRS}
${CONSTRUCTION_SRCS}
${CONSTRUCTION_HDRS}
)
SET(MANDOLINE3_SRCS
${CUTMESH3_SRCS}
${CUTMESH3_HDRS}
${CONSTRUCTION_SRCS}
${CONSTRUCTION_HDRS}
)
SET(MANDOLINE_CUTMESH_SRCS
${CUTMESH3_SRCS}
${CUTMESH3_HDRS}
${CONSTRUCTION_SRCS}
${CONSTRUCTION_HDRS}
)
SET(TOOLS_SRCS
src/tools/planar_slicer.cpp
src/tools/exploded_mesh.cpp
)
SET(TOOLS_HDRS
include/mandoline/tools/planar_slicer.hpp
include/mandoline/tools/exploded_mesh.hpp
)
ENDIF(HANDLE_SELF_INTERSECTIONS)
ADD_LIBRARY(cutmesh2_obj OBJECT ${CUTMESH2_SRCS} ${CUTMESH2_HDRS})
ADD_LIBRARY(cutmesh3_obj OBJECT ${CUTMESH3_SRCS} ${CUTMESH3_HDRS})
ADD_LIBRARY(construction_obj OBJECT ${CONSTRUCTION_SRCS} ${CONSTRUCTION_HDRS})
ADD_LIBRARY(tools_obj OBJECT ${TOOLS_SRCS} ${TOOLS_HDRS})
TARGET_INCLUDE_DIRECTORIES(cutmesh2_obj PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
TARGET_INCLUDE_DIRECTORIES(cutmesh3_obj PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
TARGET_INCLUDE_DIRECTORIES(construction_obj PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
TARGET_INCLUDE_DIRECTORIES(tools_obj PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
TARGET_LINK_LIBRARIES(cutmesh2_obj PUBLIC mtao::headers mtao::geometry igl::core )
TARGET_LINK_LIBRARIES(cutmesh3_obj PUBLIC mtao::headers mtao::geometry igl::core )
TARGET_LINK_LIBRARIES(construction_obj PUBLIC mtao::headers mtao::geometry igl::core)
if(USE_OPENGL)
find_package(ImGui REQUIRED)
find_package(MagnumIntegration COMPONENTS ImGui)
TARGET_LINK_LIBRARIES(construction_obj PUBLIC ImGui::ImGui MagnumIntegration::ImGui)
endif()
TARGET_LINK_LIBRARIES(tools_obj PUBLIC mtao::headers mtao::geometry igl::core )
ADD_DEFINITIONS(-g)
IF(OpenMP_Found)
ADD_DEFINITIONS(-DMTAO_OPENMP)
ENDIF(OpenMP_Found)
ADD_DEFINITIONS(-DUSE_FLOP_FREE_ANGLE_COMPUTATION)
ADD_LIBRARY(mandoline
$<TARGET_OBJECTS:cutmesh_proto>
$<TARGET_OBJECTS:cutmesh2_obj>
$<TARGET_OBJECTS:cutmesh3_obj>
$<TARGET_OBJECTS:construction_obj>
$<TARGET_OBJECTS:tools_obj>
)
TARGET_LINK_LIBRARIES(mandoline
mtao::geometry OpenMP::OpenMP_CXX
${SELF_INTERSECTION_LIBS} Boost::thread
igl::core
protobuf::libprotobuf
)
ADD_LIBRARY(mandoline2 EXCLUDE_FROM_ALL
$<TARGET_OBJECTS:cutmesh_proto>
$<TARGET_OBJECTS:cutmesh2_obj>
$<TARGET_OBJECTS:construction_obj>
)
TARGET_LINK_LIBRARIES(mandoline2
mtao::geometry OpenMP::OpenMP_CXX
${SELF_INTERSECTION_LIBS} Boost::thread
igl::core
protobuf::libprotobuf
)
ADD_LIBRARY(mandoline3 EXCLUDE_FROM_ALL
$<TARGET_OBJECTS:cutmesh_proto>
$<TARGET_OBJECTS:cutmesh3_obj>
$<TARGET_OBJECTS:construction_obj>
$<TARGET_OBJECTS:tools_obj>
)
TARGET_LINK_LIBRARIES(mandoline3
mtao::geometry OpenMP::OpenMP_CXX
${SELF_INTERSECTION_LIBS} Boost::thread
igl::core
protobuf::libprotobuf
)
ADD_LIBRARY(mandoline_cutmesh3
$<TARGET_OBJECTS:cutmesh_proto>
$<TARGET_OBJECTS:cutmesh3_obj>
)
TARGET_LINK_LIBRARIES(mandoline_cutmesh3
mtao::geometry OpenMP::OpenMP_CXX
${SELF_INTERSECTION_LIBS} Boost::thread
igl::core
protobuf::libprotobuf
)
message(STATUS "BINARY DIR: ${CMAKE_CURRENT_BINARY_DIR}")
TARGET_INCLUDE_DIRECTORIES(mandoline PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
TARGET_INCLUDE_DIRECTORIES(mandoline2 PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
TARGET_INCLUDE_DIRECTORIES(mandoline3 PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
TARGET_INCLUDE_DIRECTORIES(mandoline_cutmesh3 PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
IF(HANDLE_SELF_INTERSECTIONS)
FOREACH(TARG mandoline mandoline2 mandoline3 construction_obj)
TARGET_COMPILE_DEFINITIONS(${TARG}
PUBLIC -DMANDOLINE_HANDLE_SELF_INTERSECTIONS)
ENDFOREACH()
ENDIF(HANDLE_SELF_INTERSECTIONS)
ADD_SUBDIRECTORY(examples EXCLUDE_FROM_ALL)
ADD_SUBDIRECTORY(tests EXCLUDE_FROM_ALL)
ADD_SUBDIRECTORY(tools EXCLUDE_FROM_ALL)
You can’t perform that action at this time.