-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
79 lines (67 loc) · 2.47 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
# Copyright Matt Overby 2021.
# Distributed under the MIT License.
cmake_minimum_required(VERSION 3.0)
project(mclccd LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(FetchContent)
option(MCLCCD_DEBUG "Compile in test mode" OFF)
option(MCLCCD_BUILD_EXAMPLES "Compile examples" ON)
if (MCLCCD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wundef -Wextra -Wno-long-long -Wlogical-op -Wshadow -Wmaybe-uninitialized")
endif()
else()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
endif()
# thread building blocks
# TODO: build this with fetchcontent if not found
find_package(TBB REQUIRED)
# Eigen, download if not found
find_package(Eigen3)
if(NOT EIGEN_FOUND)
FetchContent_Declare(
Eigen3
QUIET
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.4.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(Eigen3)
endif()
# Create the library
file(GLOB MCLBVH_INCLUDE
${CMAKE_CURRENT_SOURCE_DIR}/include/MCL/*.hpp)
file(GLOB MCLBVH_SRC
${CMAKE_CURRENT_SOURCE_DIR}/include/MCL/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/MCL/ccd_internal/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/MCL/ccd_internal/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/MCL/ccd_internal/*.cpp)
add_library(${PROJECT_NAME} ${MCLBVH_INCLUDE} ${MCLBVH_SRC})
target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen TBB::tbb)
target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
add_library(mcl::ccd ALIAS ${PROJECT_NAME})
# build examples
if(MCLCCD_BUILD_EXAMPLES)
# Libigl for rendering/interface
option(LIBIGL_WITH_OPENGL "Use OpenGL" ON)
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" ON)
include(libigl)
set(MCLCCD_DEP_LIBRARIES
igl::core
igl::opengl_glfw
mcl::ccd)
add_definitions(-DMCLCCD_ROOT_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
add_executable(dillo ${CMAKE_CURRENT_SOURCE_DIR}/examples/dillo.cpp)
add_executable(traverser ${CMAKE_CURRENT_SOURCE_DIR}/examples/traverser.cpp)
target_link_libraries(dillo ${MCLCCD_DEP_LIBRARIES})
target_link_libraries(traverser ${MCLCCD_DEP_LIBRARIES})
endif()
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(FILES ${MCLBVH_INCLUDE} DESTINATION include/MCL)