-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
160 lines (130 loc) · 4.96 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
cmake_minimum_required(VERSION 3.8)
project(AffineGuideline LANGUAGES C CXX)
# indicate if OPENMP should be enabled
option(USE_OPENMP "Use OPENMP" ON)
# indicate if OPENMP should be enabled
option(CREATE_SAMPLE_PROJECT "Create the Sample Project" 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 -fPIC")
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)
set(CMAKE_CXX_FLAGS "-fpermissive")
# ==============================================================================
# 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_PACKAGE(Threads REQUIRED)
# ==============================================================================
# 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)
# ==============================================================================
# Find Eigen
# ==============================================================================
find_package(Eigen3 REQUIRED)
set(EIGEN_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})
# ==============================================================================
# VLFeat
# ==============================================================================
add_subdirectory(lib)
# ==============================================================================
# Includes
# ==============================================================================
SET(SOURCE_DIR "src/pyrobustac")
include_directories (
${PROJECT_SOURCE_DIR}/lib/graph-cut-ransac/src/pygcransac/include
${PROJECT_SOURCE_DIR}/lib
)
# ==============================================================================
# Structure: Graph-Cut RANSAC Library
# ==============================================================================
# Set header files for the library
file(GLOB_RECURSE HDRS_GraphCutRANSAC
"lib/graph-cut-ransac/src/pygcransac/include/*.h"
)
# Set source files to be added to the library
file(GLOB_RECURSE SRCS_GraphCutRANSAC
"lib/graph-cut-ransac/src/pygcransac/include/*.cpp"
)
add_library(GraphCutRANSAC STATIC
${HDRS_GraphCutRANSAC}
${SRCS_GraphCutRANSAC}
)
target_link_libraries(GraphCutRANSAC
${OpenCV_LIBS}
Eigen3::Eigen ${CMAKE_THREAD_LIBS_INIT}
)
# ==============================================================================
# Structure: Affine Guideline 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_AffineGuideline
"${SOURCE_DIR}/include/*.h"
)
# Set header files for the library
file(GLOB_RECURSE SRCS_AffineGuideline
"${SOURCE_DIR}/include/*.cpp"
)
# ==============================================================================
# Structure: Python binding
# ==============================================================================
# Generate python module
add_subdirectory(lib/graph-cut-ransac/lib/pybind11)
pybind11_add_module(pyrobustac
${SOURCE_DIR}/src/bindings.cpp
${SOURCE_DIR}/src/robustac_python.cpp
${HDRS_AffineGuideline}
${SRCS_AffineGuideline})
target_link_libraries(pyrobustac PRIVATE
${OpenCV_LIBS}
Eigen3::Eigen
vlfeat
GraphCutRANSAC ${CMAKE_THREAD_LIBS_INIT})
add_library(${PROJECT_NAME} STATIC
${HDRS_AffineGuideline}
${SRCS_AffineGuideline}
)
target_link_libraries (${PROJECT_NAME}
${OpenCV_LIBS}
Eigen3::Eigen
vlfeat
GraphCutRANSAC ${CMAKE_THREAD_LIBS_INIT})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/build/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}
Eigen3::Eigen
vlfeat
GraphCutRANSAC
)
add_dependencies(SampleProject ${PROJECT_NAME})
endif (CREATE_SAMPLE_PROJECT)