-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
141 lines (95 loc) · 4.62 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
133
134
135
136
137
138
139
140
# PROJECT CONFIGURATION
cmake_minimum_required(VERSION 3.1)
# set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel.")
project(RotPriorH LANGUAGES C CXX VERSION 1.0.0)
set(LIBRARY_TARGET_NAME "RotPriorH")
set(LIBRARY_TARGET_NAME_EXPORT "${LIBRARY_TARGET_NAME}Export")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # We require C++ 14
# build the examples
set(BUILD_${LIBRARY_TARGET_NAME}_EXAMPLE ON)
set(DO_INSTALL_LIBRARY OFF) # install library
# Build type
# Directory for built libraries
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib CACHE PATH "The directory in which to place libraries built by this project")
# Directory for built executables
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH "The directory in which to place executables built by this project")
# BUILD CONFIGURATIONS
option(CMAKE_VERBOSE_MAKEFILE "Generate verbose makefiles?" OFF)
set(CODE_PROFILING OFF CACHE BOOL "Turn on code profiling?")
if(${CODE_PROFILING})
message(STATUS "Turning on code profiling for Essential Matrix Estimation")
endif()
# Add the .cmake files that ship with Eigen3 to the CMake module path (useful for finding other stuff)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" CACHE STRING "The CMake module path used for this project")
# FIND EIGEN3
set( ENV{EIGEN3_ROOT_DIR} ${CMAKE_SOURCE_DIR}/eigen)
find_package(Eigen3 3.3 REQUIRED)
if(EIGEN3_FOUND)
message(STATUS "Found Eigen3 library (version ${EIGEN3_VERSION_STRING})")
message(STATUS "Eigen3 include directory: ${EIGEN3_INCLUDE_DIR}\n")
else()
message(STATUS "Eigen library not found!")
endif()
# do not include this if add_subdirectory
# for essential is used
add_subdirectory(dependences/Rosen_optimization)
find_package(IterCertAlg REQUIRED)
set(${LIBRARY_TARGET_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(${LIBRARY_TARGET_NAME}_SOURCE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(${LIBRARY_TARGET_NAME}_EXAMPLES_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/examples)
# Expose the include directories for this project
set(${LIBRARY_TARGET_NAME}_ADD_INCLUDES ${Optimization_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR} )
set(${LIBRARY_TARGET_NAME}_CERT_INCLUDES ${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS} ${${LIBRARY_TARGET_NAME}_ADD_INCLUDES})
message(STATUS "Essential headers in ${${LIBRARY_TARGET_NAME}_CERT_INCLUDES} \n")
# Get the set of Essential header and source files
set(${LIBRARY_TARGET_NAME}_HDRS
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/RotPriorH.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/RotPriorHManifold.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/RotPriorHProblem.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/RotPriorHTypes.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/RotPriorHUtils.h
${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}/RotPriorHConstraints.h
)
set(${LIBRARY_TARGET_NAME}_SRCS
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/RotPriorH.cpp
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/RotPriorHManifold.cpp
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/RotPriorHProblem.cpp
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/RotPriorHUtils.cpp
${${LIBRARY_TARGET_NAME}_SOURCE_DIRS}/RotPriorHConstraints.cpp
)
message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode\n")
# Build the Essential library
add_library(${LIBRARY_TARGET_NAME} ${${LIBRARY_TARGET_NAME}_HDRS} ${${LIBRARY_TARGET_NAME}_SRCS} )
target_include_directories(${LIBRARY_TARGET_NAME} PUBLIC
# only when building from the source tree
$<BUILD_INTERFACE:${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}>
# ---------------------$<INSTALL_INTERFACE:${INSTALL_CMAKE_DIR}"/${LIBRARY_TARGET_NAME}EstimationRosen/include">) or:
# $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${${LIBRARY_TARGET_NAME}_INCLUDE_DIRS}>)
# only when using the lib from the install path
$<INSTALL_INTERFACE:include>
${${LIBRARY_TARGET_NAME}_ADD_INCLUDES}
)
target_link_libraries(${LIBRARY_TARGET_NAME}
PUBLIC ${BLAS_LIBRARIES} ${M} ${LAPACK}
)
if(${CODE_PROFILING})
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES COMPILE_FLAGS "-pg -g" LINK_FLAGS "-pg -g")
endif()
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
install(TARGETS ${LIBRARY_TARGET_NAME}
EXPORT ${LIBRARY_TARGET_NAME_EXPORT}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
INCLUDES DESTINATION "include"
PUBLIC_HEADER DESTINATION "include/${LIBRARY_TARGET_NAME}"
)
# Build the example executable
IF(BUILD_${LIBRARY_TARGET_NAME}_EXAMPLE)
message(STATUS "Adding examples to build")
add_subdirectory(examples)
endif()
IF (DO_INSTALL_LIBRARY)
include(cmake/setup_installation.cmake)
ENDIF()