forked from qcr/gtsam-quadrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
146 lines (117 loc) · 6.34 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
141
142
143
144
145
146
cmake_minimum_required(VERSION 3.0)
project(gtsam_quadrics)
set(GTSAM_QUADRICS_VERSION 1.0.0)
# we want to use some C++11 features
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
###################################################################################
# set up options
option(BUILD_PYTHON_WRAP "Enable/Disable building of cython wrapper" OFF)
set(PYTHON_VERSION "3" CACHE STRING "The version of python to build the cython wrapper for (or Default)")
###################################################################################
# find GTSAM and GTSAM CMake tools
find_package(GTSAM REQUIRED HINTS "/Users/akashsha/Documents/projects/quadric-slam/.thirdparty/")
find_package(GTSAMCMakeTools REQUIRED HINTS "/Users/akashsha/Documents/projects/quadric-slam/.thirdparty/")
# include gtsam cmake tools
include(GtsamBuildTypes) # Load build type flags and default to Debug mode
include(GtsamTesting) # Easy functions for creating unit tests and scripts
include(GtsamMakeConfigFile) # Defines a function for generating config file so package can be found with find_package function
# NOTE: PYTHONPATH must include GTSAM_CYTHON_INSTALL_PATH for gtsam/gtsam.pxd
if(BUILD_PYTHON_WRAP)
# python version must be set before including gtsamcythonwrap
set(GTSAM_PYTHON_VERSION ${PYTHON_VERSION})
include(GtsamMatlabWrap) # Automatic MATLAB wrapper generation
include(GtsamCythonWrap) # Automatic MATLAB wrapper generation
endif()
###################################################################################
# add gtsam_quadrics
# include headers, ensure that local folder is searched before library folders
include_directories(BEFORE "${PROJECT_SOURCE_DIR}")
# set source files
set(
SOURCE_FILES
./gtsam_quadrics/base/Utilities.cpp
./gtsam_quadrics/geometry/ConstrainedDualQuadric.cpp
./gtsam_quadrics/geometry/AlignedBox2.cpp
./gtsam_quadrics/geometry/AlignedBox3.cpp
./gtsam_quadrics/geometry/BoundingBoxFactor.cpp
./gtsam_quadrics/geometry/QuadricAngleFactor.cpp
./gtsam_quadrics/geometry/QuadricCamera.cpp
./gtsam_quadrics/geometry/DualConic.cpp
)
###################################################################################
## Build static library from common sources
set(CONVENIENCE_LIB_NAME "gtsam_quadrics")
add_library(${CONVENIENCE_LIB_NAME} SHARED ${SOURCE_FILES})
# set_target_properties(${CONVENIENCE_LIB_NAME} PROPERTIES PREFIX "")
target_link_libraries(${CONVENIENCE_LIB_NAME} gtsam)
###################################################################################
# install library and PACKAGEConfig.cmake
install(
TARGETS ${CONVENIENCE_LIB_NAME}
EXPORT GTSAM_QUADRICS-exports
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
gtsammakeconfigfile(GTSAM_QUADRICS)
# list(APPEND GTSAM_EXPORTED_TARGETS ${CONVENIENCE_LIB_NAME})
# export(TARGETS ${GTSAM_EXPORTED_TARGETS} FILE GTSAM-exports.cmake)
file(GLOB gtsam_quadrics_base_headers "gtsam_quadrics/base/*.h")
install(FILES ${gtsam_quadrics_base_headers} DESTINATION include/gtsam_quadrics/base)
file(GLOB gtsam_quadrics_geometry_headers "gtsam_quadrics/geometry/*.h")
install(FILES ${gtsam_quadrics_geometry_headers} DESTINATION include/gtsam_quadrics/geometry)
###################################################################################
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
add_custom_target(
uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
)
###################################################################################
# Build tests (CMake tracks the dependecy to link with GTSAM through our project's static library)
gtsamaddtestsglob("geometry" "gtsam_quadrics/geometry/tests/test*.cpp" "" "${CONVENIENCE_LIB_NAME}")
gtsamaddtestsglob("geometry" "gtsam_quadrics/base/tests/test*.cpp" "" "${CONVENIENCE_LIB_NAME}")
###################################################################################
# Build example files (CMake tracks the dependecy to link with GTSAM through our project's static library)
# gtsamAddExamplesGlob("*.cpp" "" "${CONVENIENCE_LIB_NAME}")
# build examples if make examples
# https://stackoverflow.com/questions/17765618/cmake-add-subdirectories-to-custom-target-and-adding-custom-target-to-vs-solut
# TODO: pass ${CONVENIENCE_LIB_NAME} to examples/c++/CMakeLists.txt
# add_custom_target(examples) <-- already exists from GtsamTesting
add_subdirectory(examples/c++)
add_dependencies(examples examples_folder)
###################################################################################
# Build MATLAB wrapper (CMake tracks the dependecy to link with GTSAM through our project's static library)
# wrap_and_install_library("example.h" "${CONVENIENCE_LIB_NAME}" "" "")
###################################################################################
# Build Cython wrapper (CMake tracks the dependecy to link with GTSAM through our project's static library)
if(BUILD_PYTHON_WRAP)
# include gtsam eigency (handles numpy->eigen conversion)
include_directories(${GTSAM_EIGENCY_INSTALL_PATH})
# create __init__.py to allow build/cython/gtsam_quadrics be imported as a python package
file(WRITE "${PROJECT_BINARY_DIR}/cython/gtsam_quadrics/__init__.py" "from .gtsam_quadrics import *")
set(GTSAM_QUADRICS_CYTHON_INSTALL_PATH "${PROJECT_BINARY_DIR}/cython/gtsam_quadrics" CACHE PATH "Cython toolbox destination, blank defaults to CMAKE_INSTALL_PREFIX/cython")
# use gtsams cython wrapping functionality
wrap_and_install_library_cython(
"./gtsam_quadrics.h" # interface_header path
"from gtsam.gtsam cimport *" # extra imports for cython pxd
"${GTSAM_QUADRICS_CYTHON_INSTALL_PATH}" # install_path
"gtsam;${CONVENIENCE_LIB_NAME}" # libraries to link with
"wrap;gtsam;${CONVENIENCE_LIB_NAME}" # dependencies)
)
# install __init__.py so package can be loaded
# install_cython_files("${PROJECT_BINARY_DIR}/cython/gtsam_quadrics/__init__.py" "${GTSAM_QUADRICS_CYTHON_INSTALL_PATH}")
endif()
###################################################################################
# Build Doxygen documentation
# find doxygen
find_package(Doxygen)
# add subdirectory with custom make doc, doc_clean targets
if(DOXYGEN_FOUND)
add_subdirectory(doc)
endif()