-
Notifications
You must be signed in to change notification settings - Fork 120
/
CMakeLists.txt
130 lines (111 loc) · 4.11 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(feh)
# Set operating system variables
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(IS_LINUX TRUE)
endif ()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(IS_MAC TRUE)
endif ()
message(STATUS "IS_LINUX ${IS_LINUX}")
message(STATUS "IS_MAC ${IS_MAC}")
option(BUILD_G2O "build with g2o support" OFF)
option(USE_GPERFTOOLS "use gperf for performance profiling" OFF)
if (USE_GPERFTOOLS)
add_definitions(-DUSE_GPERFTOOLS)
endif (USE_GPERFTOOLS)
if (BUILD_G2O)
add_definitions(-DUSE_G2O)
endif (BUILD_G2O)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -std=c++17 -Wno-narrowing -Wno-register -fPIC -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=native -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops")
# set(CMAKE_BUILD_TYPE "Debug")
# set(CMAKE_BUILD_TYPE "RelWithDebInfo")
set(CMAKE_BUILD_TYPE "Release")
#add_definitions(-DNDEBUG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
# disable logging whose severity level is below the given integer
add_definitions(-DGOOGLE_STRIP_LOG=1)
# add_definitions(-DEIGEN_DEFAULT_TO_ROW_MAJOR)
add_definitions(-DEIGEN_INITIALIZE_MATRICES_BY_ZERO)
find_package(OpenCV REQUIRED)
find_package(Python3 REQUIRED Interpreter Development)
link_directories(
${PROJECT_SOURCE_DIR}/lib
${PROJECT_SOURCE_DIR}/thirdparty/gflags/lib
${PROJECT_SOURCE_DIR}/thirdparty/glog/lib
${PROJECT_SOURCE_DIR}/thirdparty/Pangolin/lib
${PROJECT_SOURCE_DIR}/thirdparty/jsoncpp/lib
${PROJECT_SOURCE_DIR}/thirdparty/gperftools/lib
${PROJECT_SOURCE_DIR}/thirdparty/DBoW2/lib
${PROJECT_SOURCE_DIR}/thirdparty/pnp/build
${PROJECT_SOURCE_DIR}/thirdparty/ceres-solver/lib
/usr/local/lib
)
if (IS_LINUX)
link_directories(/usr/lib/x86_64-linux-gnu)
endif(IS_LINUX)
include_directories(
${PROJECT_SOURCE_DIR}/common
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/thirdparty/gflags/include
${PROJECT_SOURCE_DIR}/thirdparty/glog/include
${PROJECT_SOURCE_DIR}/thirdparty/Pangolin/include
${PROJECT_SOURCE_DIR}/thirdparty/jsoncpp/include
${PROJECT_SOURCE_DIR}/thirdparty/eigen/include/eigen3
${PROJECT_SOURCE_DIR}/thirdparty/gperftools/include
${PROJECT_SOURCE_DIR}/thirdparty/pybind11/include
${PROJECT_SOURCE_DIR}/thirdparty/DBoW2/include
${PROJECT_SOURCE_DIR}/thirdparty/pnp
${PROJECT_SOURCE_DIR}/thirdparty/sophus
${JSONCPP_INCLUDE_DIRS}
/usr/include/suitesparse
/usr/include
${OpenCV_INCLUDE_DIRS}
${Python3_INCLUDE_DIRS}
)
enable_testing()
add_subdirectory(thirdparty/googletest)
add_subdirectory(thirdparty/gflags)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/googletest/include)
# add_subdirectory(thirdparty/abseil-cpp)
if (BUILD_G2O)
link_directories(${PROJECT_SOURCE_DIR}/thirdparty/g2o/release/lib)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/g2o/release/include)
list(APPEND deps
g2o_core
g2o_solver_dense
g2o_solver_cholmod
g2o_solver_csparse
g2o_csparse_extension
g2o_types_slam3d
g2o_types_sba
g2o_stuff
cholmod
cxsparse
)
endif(BUILD_G2O)
# feh
add_subdirectory(common)
add_subdirectory(src)
########################################
# PYTHON BINDING
########################################
# NOTE: to build with a specific python version
# cmake -DPYTHON_EXECUTABLE=path/to/python ..
# By default, the python binding generated is only compatible with
# your default python interpreter, which you can check by typing
# "which python" in your terminal.
# If you see an error saying "Python.h: No such file or directory", you probably
# need to "sudo apt-get install python3-dev" assuming you are binding to python3.
set(PYBIND11_CPP_STANDARD -std=c++17)
add_subdirectory(thirdparty/pybind11)
pybind11_add_module(pyxivo MODULE pybind11/pyxivo.cpp)
set(libxivo common xest xapp)
if (BUILD_G2O)
list(APPEND libxivo xopt)
endif(BUILD_G2O)
target_link_libraries(pyxivo PRIVATE ${libxivo})