-
Notifications
You must be signed in to change notification settings - Fork 18
/
CMakeLists.txt
206 lines (174 loc) · 6.37 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
cmake_minimum_required(VERSION 3.8)
project(ProgressiveX LANGUAGES CXX)
# indicate if OPENMP should be enabled
option(USE_OPENMP "Use OPENMP" ON)
# indicate if the sample project should be included
option(CREATE_SAMPLE_PROJECT "Create the Sample Project" ON)
# indicate if GFLags should be enabled
option(USE_GFLAGS "Enable Google Flags." ON)
# indicate if GLog should be enabled
option(USE_GLOG "Enable Google Log." ON)
SET (CMAKE_BUILD_TYPE "RELEASE")
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-strict-aliasing")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-write-strings")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -ansi")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ftree-vectorize -funroll-loops")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
# ==============================================================================
# Check C++17 support
# ==============================================================================
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# ==============================================================================
# Find OpenCV
# ==============================================================================
find_package(OpenCV)
if (OPENCV_FOUND)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenCV_CXX_FLAGS}")
add_definitions(-DUSE_OPENMP)
set(TRGT_LNK_LBS_ADDITIONAL OpenMP::OpenMP_CXX)
endif (OPENCV_FOUND)
# ==============================================================================
# Find Eigen
# ==============================================================================
find_package(Eigen3 REQUIRED)
set(EIGEN_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
# ==============================================================================
# Find GFlags
# ==============================================================================
find_package(gflags REQUIRED)
if(DEFINED gflags_VERSION_STRING OR DEFINED GFLAGS_VERSION_STRING)
# different cmake variable with lower or upper case exist
set(GFLAGS_INCLUDE_DIR ${GFLAGS_INCLUDE_DIR})
#set(GFLAGS_INCLUDE_DIR ${GFLAGS_INCLUDE_DIR} ${gflags_INCLUDE_DIR})
set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARIES})
#set(GFLAGS_LIBRARIES ${GFLAGS_LIBRARIES} ${gflags_LIBRARIES})
message( "Found Gflags ${GFLAGS_VERSION_STRING}" )
message( STATUS "> GFLAGS_INCLUDE_DIR: ${GFLAGS_INCLUDE_DIR}" )
message( STATUS "> GFLAGS_LIBRARIES: ${GFLAGS_LIBRARIES}" )
endif()
# ==============================================================================
# Find GLOG
# ==============================================================================
#include(FindPackageHandleStandardArgs)
#
#set(GLOG_ROOT_DIR "" CACHE PATH "Folder contains Google glog")
#
#find_path(GLOG_INCLUDE_DIR glog/logging.h
# PATHS
# ${GLOG_ROOT_DIR}
# PATH_SUFFIXES
# src)
#
#find_library(GLOG_LIBRARY glog libglog
# PATHS
# ${GLOG_ROOT_DIR}
# PATH_SUFFIXES
# .libs
# lib
# lib64)
#
#find_package_handle_standard_args(GLOG DEFAULT_MSG
# GLOG_INCLUDE_DIR GLOG_LIBRARY)
#
#if(GLOG_FOUND)
# set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
# set(GLOG_LIBRARIES ${GLOG_LIBRARY})
#endif()
#
find_package(glog REQUIRED)
if(NOT glog_FOUND)
message(FATAL_ERROR "Glog not found.")
endif()
# ==============================================================================
# Find OpenMP
# ==============================================================================
find_package(OpenMP)
if (USE_OPENMP)
if(NOT OPENMP_FOUND)
message(FATAL_ERROR "OPENMP not found.")
endif()
add_definitions(-DUSE_OPENMP)
set(TRGT_LNK_LBS_ADDITIONAL OpenMP::OpenMP_CXX)
endif (USE_OPENMP)
# ==============================================================================
# Includes
# ==============================================================================
SET(SOURCE_DIR "src/pyprogressivex")
include_directories (
${PROJECT_SOURCE_DIR}/graph-cut-ransac/src/pygcransac/include
${GLOG_INCLUDE_DIR}
)
# ==============================================================================
# Structure: Graph-Cut RANSAC Library
# ==============================================================================
# Set header files for the library
file(GLOB_RECURSE HDRS_GraphCutRANSAC
"graph-cut-ransac/src/pygcransac/include/*.h"
)
# Set source files to be added to the library
file(GLOB_RECURSE SRCS_GraphCutRANSAC
"graph-cut-ransac/src/pygcransac/include/*.cpp"
)
add_library(GraphCutRANSAC SHARED
${HDRS_GraphCutRANSAC}
${SRCS_GraphCutRANSAC}
)
target_link_libraries(GraphCutRANSAC
${OpenCV_LIBS}
Eigen3::Eigen)
# ==============================================================================
# Structure: Progressive-X Library
# ==============================================================================
# Tell cmake that headers are in alse in source_dir
include_directories(${SOURCE_DIR}/include)
# Set header files for the library
file(GLOB_RECURSE HDRS_PROGRESSIVEX
"${SOURCE_DIR}/include/*.h"
)
# Set source files to be added to the library
file(GLOB_RECURSE SRCS_PROGRESSIVEX
"${SOURCE_DIR}/include/*.cpp"
)
# ==============================================================================
# Structure: Python binding
# ==============================================================================
# Generate python module
add_subdirectory(lib/pybind11)
pybind11_add_module(pyprogressivex ${SOURCE_DIR}/src/bindings.cpp ${SOURCE_DIR}/src/progressivex_python.cpp ${HDRS_PROGRESSIVEX} ${SRCS_PROGRESSIVEX} )
target_link_libraries(pyprogressivex PRIVATE
${OpenCV_LIBS}
Eigen3::Eigen
glog::glog
gflags
GraphCutRANSAC)
add_library(${PROJECT_NAME} STATIC
${HDRS_PROGRESSIVEX}
${SRCS_PROGRESSIVEX}
)
target_link_libraries (${PROJECT_NAME}
${OpenCV_LIBS}
Eigen3::Eigen
glog::glog
gflags
GraphCutRANSAC)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
# ==============================================================================
# Structure: Applications
# ==============================================================================
if (CREATE_SAMPLE_PROJECT)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build)
add_executable(SampleProject
examples/cpp_example.cpp)
target_link_libraries(SampleProject PUBLIC
${OpenCV_LIBS}
${PROJECT_NAME}
Eigen3::Eigen
gflags
glog::glog
GraphCutRANSAC
)
add_dependencies(SampleProject ${PROJECT_NAME})
endif (CREATE_SAMPLE_PROJECT)