-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
132 lines (101 loc) · 3.58 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
131
132
project(PathGen)
cmake_minimum_required(VERSION 2.8)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules/")
string(TOLOWER ${PROJECT_NAME} LIBRARY_NAME)
# Mac ONLY. Define Relative Path on Mac OS
if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH 0)
endif()
include(install_package)
include(SetPlatformVars)
set(PathGen_VERSION_MAJOR 0)
set(PathGen_VERSION_MINOR 1)
set(PACKAGE_VERSION ${PathGen_VERSION_MAJOR}.${PathGen_VERSION_MINOR})
set(PathGen_VERSION ${PACKAGE_VERSION})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release )
endif()
# guard against in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
endif()
###############################################################################
# Set up options
option(BUILD_APPLICATIONS "Build Applications" ON)
SET(N_CORES 8 CACHE STRING "Using N number of cores for parallel build")
#####################################################################
## Find required packages
find_package(Eigen3 REQUIRED)
find_package(Glog REQUIRED)
find_package(GFlags REQUIRED)
find_package(Sophus REQUIRED)
set( REQUIRED_INCLUDE_DIRS
${GLOG_INCLUDE_DIRS}
${GFLAGS_INCLUDE_DIRS}
${EIGEN_INCLUDE_DIRS}
${Sophus_INCLUDE_DIRS}
)
set( REQUIRED_LIBRARIES
${GLOG_LIBRARIES}
${GFLAGS_LIBRARIES}
${Sophus_LIBRARIES}
)
#####################################################################
## Sources
set( INC_DIR include/${LIBRARY_NAME} )
set( HEADERS
${INC_DIR}/EulerSpline.h
${INC_DIR}/PoseSpline.h
${INC_DIR}/QuaternionAddons.h
${INC_DIR}/QuaternionSpline.h
${INC_DIR}/Types.h
${INC_DIR}/Utils.h
${INC_DIR}/Measurements.h
${INC_DIR}/IMUGenerator.h
${INC_DIR}/PathGenerator.h
)
foreach(INC_FILE ${HEADERS})
string(REPLACE "include/" "" INC_FILE ${INC_FILE})
set(PATHGEN_INCLUDES "${PATHGEN_INCLUDES}\n#include <${INC_FILE}>")
endforeach(INC_FILE)
configure_file(
include/pathgen/PathGen.h.in
include/pathgen/PathGen.h
)
set( SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src )
set( SOURCES
${SRC_DIR}/QuaternionSpline.cpp
${SRC_DIR}/PathGenerator.cpp
${SRC_DIR}/Utils.cpp
${SRC_DIR}/IMUGenerator.cpp
)
list(APPEND REQUIRED_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include)
list(APPEND REQUIRED_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/include)
include_directories(${REQUIRED_INCLUDE_DIRS})
add_library(${LIBRARY_NAME} SHARED ${SOURCES} ${HEADERS})
set_target_properties( ${LIBRARY_NAME} PROPERTIES VERSION "${PACKAGE_VERSION}" SOVERSION "${PACKAGE_VERSION}" )
target_link_libraries(${LIBRARY_NAME} ${REQUIRED_LIBRARIES})
install_package(
PKG_NAME ${PROJECT_NAME}
LIB_NAME ${LIBRARY_NAME}
VERSION ${PACKAGE_VERSION}
DESCRIPTION "Path and IMU data generation library"
INSTALL_INCLUDE_DIR true
DESTINATION ${CMAKE_INSTALL_PREFIX}
INCLUDE_DIRS ${REQUIRED_INCLUDE_DIRS}
LINK_LIBS ${REQUIRED_LIBRARIES}
)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
#####################################################################
## Add Components
# Build application
if(BUILD_APPLICATIONS)
MESSAGE(STATUS "BUILDING APPLICATIONS")
set( PathGen_DIR ${CMAKE_CURRENT_BINARY_DIR} )
add_subdirectory(applications)
endif()