-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCMakeLists.txt
161 lines (139 loc) · 5.1 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
#
# By downloading, copying, installing or using the software you agree to this license.
# If you do not agree to this license, do not download, install,
# copy or use the software.
#
# License Agreement
# For Open Source Flow Visualization Library
#
# Copyright 2013-2018 Abhishek Bajpayee
#
# This file is part of OpenFV.
#
# OpenFV is free software: you can redistribute it and/or modify it under the terms of the
# GNU General Public License version 2 as published by the Free Software Foundation.
#
# OpenFV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License version 2 for more details.
#
# You should have received a copy of the GNU General Public License version 2 along with
# OpenFV. If not, see https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
cmake_minimum_required (VERSION 2.8)
project (openfv)
set (PROJECT_VERSION_MAJOR 0)
set (PROJECT_VERSION_MINOR 1)
# Build Directories
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Options
option(BUILD_PYTHON "BUILD_PYTHON" OFF)
option(BUILD_TRACKING "BUILD_TRACKING" OFF)
option(WITH_CUDA "WITH_CUDA" OFF)
set(EIGEN_INC_DIR "/usr/include/eigen3" CACHE PATH "Path to Eigen Directory")
#set(PYTHON_EXEC "python2.7" CACHE PATH "Python executable (used to find which dir to install python bindings in)")
set(PROJECT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include/openfv" CACHE PATH "Project Include Directory")
#set(NUMPY_INC_DIR "" CACHE PATH "Path to numpy include directory")
if(POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
endif()
# FIND REQUIRED PACKAGES
# Python
if (BUILD_PYTHON)
set(Python_ADDITIONAL_VERSIONS "2.7")
find_package(PythonLibs REQUIRED)
message("---PYTHON---")
message("Python Libraries: " ${PYTHON_LIBRARIES})
message("Python Include Dirs: " ${PYTHON_INCLUDE_DIRS})
if (NOT PYTHONLIBS_FOUND)
message("Python not found! Python components will not be built.")
set(BUILD_PYTHON OFF)
elseif(PYTHONLIBS_FOUND)
add_definitions(-DWITH_PYTHON)
endif()
set(BOOST_PYTHON_VERSION "python" CACHE PATH "Boost Python Version [python or python3]")
endif()
# CUDA
if(WITH_CUDA)
find_package(CUDA)
message("---CUDA---")
message("CUDA Libraries: " ${CUDA_LIBRARIES})
message("CUDA Include Dirs: " ${CUDA_INCLUDE_DIRS})
if(NOT CUDA_FOUND)
message("CUDA not found! CUDA components will not be built.")
add_definitions(-DWITHOUT_CUDA)
set(WITH_CUDA OFF)
endif()
endif()
if (NOT WITH_CUDA)
message("WITH_CUDA set of OFF. CUDA components will not be built.")
add_definitions(-DWITHOUT_CUDA)
endif()
# Find OpenCV
find_package(OpenCV)
message("---OpenCV---")
message("OpenCV Libraries: " ${OpenCV_LIBS})
message("OpenCV Include Dirs: " ${OpenCV_INCLUDE_DIRS})
if(NOT OpenCV_FOUND)
message("OpenCV not found!")
endif()
# Boost Libraries
find_package(Boost)
if(Boost_FOUND)
find_package(Boost COMPONENTS program_options filesystem system serialization chrono REQUIRED)
set(Boost_GENERAL ${Boost_LIBRARIES})
if(BUILD_PYTHON)
find_package(Boost COMPONENTS ${BOOST_PYTHON_VERSION} REQUIRED)
set(Boost_PY ${Boost_LIBRARIES})
endif()
elseif(NOT Boost_FOUND)
message("Boost not found!")
endif()
# Tiff Library
find_package(TIFF REQUIRED)
if(NOT TIFF_FOUND)
message("libtiff not found!")
endif()
message("---Ceres Solver---")
find_package(Ceres REQUIRED)
if(Ceres_FOUND)
message("Ceres Libraries: " ${CERES_LIBRARIES})
message("Ceres Include Dirs: " ${CERES_INCLUDES})
else()
message("Ceres Solver not found!")
endif()
# Include directories
include_directories( ${PROJECT_INCLUDE_DIR} )
include_directories( ${Boost_INCLUDE_DIR} )
#include_directories( ${PYTHON_INCLUDE_DIRS} )
include_directories( ${EIGEN_INC_DIR} )
include_directories( ${OpenCV_INCLUDE_DIRS} )
include_directories( ${CUDA_INCLUDE_DIRS} )
include_directories( ${CERES_INCLUDES} )
#include_directories( ${NUMPY_INC_DIR} )
# Don't think these are needed because OpenFV
# doesn't link to Qt
# include_directories( "/opt/Qt/5.4/gcc_64/include" )
set(OTHER_LIBS ${TIFF_LIBRARIES} ${Boost_GENERAL} ${Boost_PY} yaml-cpp glog gflags)
if(WITH_CUDA)
set(OTHER_LIBS ${OTHER_LIBS})
set (OFV_LIBS openfv cuda_openfv)
else()
set (OFV_LIBS openfv)
endif()
if(BUILD_PYTHON)
set (OTHER_LIBS ${OTHER_LIBS} ${PYTHON_LIBRARIES})
endif()
set(PROF_LIB profiler)
set(CERES_LIBS ${CERES_LIBRARIES} cholmod cxsparse blas lapack gomp)
set(LIBS ${PROF_LIBS} ${OTHER_LIBS} ${CERES_LIBS} ${OpenCV_LIBS})
# fPIC flags, needed?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
# Subdirectories
add_subdirectory(src)
add_executable(sa_reconstruct ${PROJECT_SOURCE_DIR}/src/tools/sa_reconstruct.cpp)
target_link_libraries(sa_reconstruct ${LIBS} ${OFV_LIBS})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/openfv/ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/openfv)