forked from strasdat/Sophus
-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
104 lines (84 loc) · 3.59 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
SET(PROJECT_NAME Sophus)
PROJECT(${PROJECT_NAME})
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET( CMAKE_VERBOSE_MAKEFILE ON)
################################################################################
# Release by default
# Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug"
IF( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Release )
ENDIF()
IF( CMAKE_COMPILER_IS_GNUCXX )
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3")
ADD_DEFINITIONS("-Wall -Werror")
ENDIF()
################################################################################
# Add local path for finding packages, set the local version first
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
################################################################################
# Create variables used for exporting (from build tree) in SophusConfig.cmake
SET( Sophus_LIBRARIES "" )
SET( Sophus_INCLUDE_DIR ${PROJECT_SOURCE_DIR} )
################################################################################
FIND_PACKAGE( Eigen3 REQUIRED )
LIST( APPEND Sophus_INCLUDE_DIR ${EIGEN3_INCLUDE_DIR} )
################################################################################
SET( SOURCE_DIR "sophus")
SET( TEMPLATES so2
se2
so3
se3
rxso3
sim3
)
SET( SOURCES ${SOURCE_DIR}/sophus.hpp ${SOURCE_DIR}/ensure.hpp
${SOURCE_DIR}/example_ensure_handler.cpp )
FOREACH(templ ${TEMPLATES})
LIST(APPEND SOURCES ${SOURCE_DIR}/${templ}.hpp)
ENDFOREACH(templ)
# Add sources as custom target so that they are shown in IDE's
ADD_CUSTOM_TARGET( libsophus SOURCES ${SOURCES} )
################################################################################
# Create 'test' make target using ctest
option(BUILD_TESTS "Build tests." ON)
if(BUILD_TESTS)
ENABLE_TESTING()
ADD_SUBDIRECTORY( test )
endif()
#######################################################
## Generate Doxygen documentation target (make doc)
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc )
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif()
################################################################################
# Export package for use from the build tree
EXPORT( PACKAGE Sophus )
# Create the SophusConfig.cmake file for other cmake projects.
# ... for the build tree
SET( CONFIG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET( CONFIG_DIR ${CMAKE_CURRENT_BINARY_DIR})
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/SophusConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SophusConfig.cmake @ONLY )
# ... for the install tree
SET( CMAKECONFIG_INSTALL_DIR lib/cmake/Sophus )
FILE( RELATIVE_PATH REL_INCLUDE_DIR
"${CMAKE_INSTALL_PREFIX}/${CMAKECONFIG_INSTALL_DIR}"
"${CMAKE_INSTALL_PREFIX}/include" )
SET( Sophus_INCLUDE_DIR "\${Sophus_CMAKE_DIR}/${REL_INCLUDE_DIR}" )
SET( CONFIG_SOURCE_DIR )
SET( CONFIG_DIR )
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/SophusConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/SophusConfig.cmake @ONLY )
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/SophusConfig.cmake"
DESTINATION ${CMAKECONFIG_INSTALL_DIR} )
# Install headers
INSTALL(DIRECTORY sophus DESTINATION ${CMAKE_INSTALL_PREFIX}/include
FILES_MATCHING PATTERN "*.hpp" )