forked from MIT-SPARK/Kimera-RPGO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
130 lines (114 loc) · 4.42 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
cmake_minimum_required (VERSION 3.5)
project(kimera_rpgo VERSION 1.0 LANGUAGES CXX)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
IF(APPLE)
# Fix linking on 10.14+. See https://stackoverflow.com/questions/54068035
LINK_DIRECTORIES(/usr/local/lib)
ENDIF()
find_package(GTSAM REQUIRED)
find_package(GTSAM_UNSTABLE QUIET)
###########################################################################
# Compile
add_library(KimeraRPGO SHARED
src/GenericSolver.cpp
src/RobustSolver.cpp
src/Logger.cpp
include/KimeraRPGO/SolverParams.h )
include_directories(include)
# Add source code for max clique finder
add_subdirectory(include/KimeraRPGO/max_clique_finder)
# Add source for outlier rejection stuff
add_subdirectory(include/KimeraRPGO/outlier)
# Add source for utils
add_subdirectory(include/KimeraRPGO/utils)
add_subdirectory(src/utils)
target_include_directories(KimeraRPGO PUBLIC
${GTSAM_INCLUDE_DIR}
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
# INSTALL
$<INSTALL_INTERFACE:include>
)
target_link_libraries(KimeraRPGO
PUBLIC
gtsam
gtsam_unstable
PRIVATE
rpgo_max_clique
)
target_compile_options(KimeraRPGO
PRIVATE -Wall -pipe
)
###########################################################################
# Define executables
add_executable(RpgoReadG2o examples/RpgoReadG2o.cpp)
target_link_libraries(RpgoReadG2o KimeraRPGO)
add_executable(RpgoReadG2oIncremental examples/RpgoReadG2oIncremental.cpp)
target_link_libraries(RpgoReadG2oIncremental KimeraRPGO)
add_executable(GenerateTrajectories examples/GenerateTrajectories.cpp)
target_link_libraries(GenerateTrajectories gtsam)
###########################################################################
# Tests
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/UnitTesting.cmake)
add_subdirectory(tests)
set(TEST_DATA_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tests/data")
configure_file(tests/test_config.h.in tests/test_config.h)
###########################################################################
# Installation
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/KimeraRPGOConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# Create KimeraRPGOConfig.cmake with extra info from KimeraRPGOConfig.cmake.in
# This file is necessary to find_package the library KimeraRPGO.
set(INSTALL_CONFIGDIR lib/cmake/KimeraRPGO)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/KimeraRPGOConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/KimeraRPGOConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR})
include(GNUInstallDirs)
install(TARGETS KimeraRPGO
EXPORT kimera-rpgo-export
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include # We need this right?
RUNTIME DESTINATION bin
)
install(EXPORT kimera-rpgo-export
FILE
KimeraRPGOTargets.cmake
DESTINATION
${INSTALL_CONFIGDIR}
)
# Install header files
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION include
FILES_MATCHING PATTERN "*.h")
## Install the config and configversion
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/KimeraRPGOConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/KimeraRPGOConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
export(TARGETS KimeraRPGO FILE KimeraRPGOTargets.cmake)
export(PACKAGE KimeraRPGO)
################################################################################
# Print configuration variables
message(STATUS "===============================================================")
message(STATUS "================ Configuration Options ======================")
message(STATUS "CMAKE_CXX_COMPILER_ID type : ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION : ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "Build flags ")
if(NOT MSVC AND NOT XCODE_VERSION)
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Release" AND NOT ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
message(WARNING " Build type is not in RELEASE, this will slow down the code.")
endif()
message(STATUS " C compilation flags (Release) : ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}")
message(STATUS " C++ compilation flags (Release) : ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
endif()