forked from fzi-forschungszentrum-informatik/vdb_mapping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
119 lines (101 loc) · 2.89 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
cmake_minimum_required(VERSION 3.0.2)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" ${CMAKE_MODULE_PATH})
option(BUILDING_TESTS "Build unit tests." ON)
project(vdb_mapping CXX)
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
message("${PROJECT_NAME}: You did not request a specific build type: selecting 'Release'.")
set(CMAKE_BUILD_TYPE Release)
endif()
## System dependencies are found with CMake's conventions
find_package(Eigen3 REQUIRED)
find_package(OpenVDB REQUIRED)
find_package(PCL REQUIRED)
find_package(TBB REQUIRED)
###########
## Build ##
###########
##
## Check C++14 support/ enable global pedantic and Wall
##
include(DefineCXX14CompilerFlag)
DEFINE_CXX_14_COMPILER_FLAG(CXX14_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
##
## Collect source format files
##
include(ClangformatMacros)
include(ClangtidyMacros)
add_format_source(${PROJECT_NAME} PATTERN "include/${PROJECT_NAME}/[a-zA-Z]*.h")
add_format_source(${PROJECT_NAME} PATTERN "src/[a-zA-Z]*.h")
add_format_source(${PROJECT_NAME} PATTERN "src/[a-zA-Z]*.cpp")
ADD_CLANGFORMAT_TARGET(${PROJECT_NAME})
ADD_CLANGTIDY_TARGET(${PROJECT_NAME})
## Declare a C++ library
add_library(${PROJECT_NAME} SHARED
src/OccupancyVDBMapping.cpp
)
target_compile_options(${PROJECT_NAME} PUBLIC ${CXX14_FLAG})
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${EIGEN3_INCLUDE_DIR}
${OpenVDB_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
PUBLIC
${OpenVDB_LIBRARIES}
${PCL_LIBRARIES}
${TBB_LIBRARIES}
-lHalf
)
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
##
## Build testing if enabled by option
##
if (BUILDING_TESTS)
enable_testing()
add_subdirectory(tests)
else()
message(STATUS "Building tests disabled.")
endif()
#############
## Install ##
#############
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
install(
EXPORT ${PROJECT_NAME}_targets
DESTINATION lib/cmake/${PROJECT_NAME}
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
)
## Mark cpp header files for installation
install(
DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME}
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake VERSION 1.0.0
COMPATIBILITY SameMajorVersion)
install(
FILES
${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
CMakeModules/FindOpenVDB.cmake
CMakeModules/FindTBB.cmake
DESTINATION
lib/cmake/${PROJECT_NAME}
)