@@ -3,23 +3,56 @@ set(the_description "SFM algorithms")
3
3
4
4
5
5
### LIBMV LIGHT EXTERNAL DEPENDENCIES ###
6
- list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /cmake" )
7
- find_package (Gflags QUIET )
6
+
8
7
find_package (Ceres QUIET )
9
- if (NOT Ceres_FOUND) # Looks like Ceres find glog on the own, so separate search isn't necessary
8
+
9
+ if (NOT Gflags_FOUND) # Ceres find gflags on the own, so separate search isn't necessary
10
+ find_package (Gflags QUIET )
11
+ endif ()
12
+ if (NOT Glog_FOUND) # Ceres find glog on the own, so separate search isn't necessary
10
13
find_package (Glog QUIET )
11
14
endif ()
12
15
13
- if ((gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS))
14
- set (_fname "${CMAKE_CURRENT_BINARY_DIR} /test_sfm_deps.cpp" )
15
- file (WRITE "${_fname} " "#include <glog/logging.h>\n #include <gflags/gflags.h>\n int main() { (void)(0); return 0; }\n " )
16
- try_compile (SFM_DEPS_OK "${CMAKE_BINARY_DIR} " "${_fname} "
17
- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${GLOG_INCLUDE_DIRS} ;${GFLAGS_INCLUDE_DIRS} "
18
- LINK_LIBRARIES ${GLOG_LIBRARIES} ${GFLAGS_LIBRARIES}
19
- OUTPUT_VARIABLE OUTPUT
20
- )
21
- file (REMOVE "${_fname} " )
22
- message (STATUS "Checking SFM deps... ${SFM_DEPS_OK} " )
16
+ if (NOT Gflags_FOUND OR NOT Glog_FOUND)
17
+ # try local search scripts
18
+ list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /cmake" )
19
+ if (NOT Gflags_FOUND)
20
+ find_package (Gflags QUIET )
21
+ endif ()
22
+ if (NOT Glog_FOUND)
23
+ find_package (Glog QUIET )
24
+ endif ()
25
+ endif ()
26
+
27
+ if (NOT DEFINED GFLAGS_INCLUDE_DIRS AND DEFINED GFLAGS_INCLUDE_DIR)
28
+ set (GFLAGS_INCLUDE_DIRS "${GFLAGS_INCLUDE_DIR} " )
29
+ endif ()
30
+ if (NOT DEFINED GLOG_INCLUDE_DIRS AND DEFINED GLOG_INCLUDE_DIR)
31
+ set (GLOG_INCLUDE_DIRS "${GLOG_INCLUDE_DIR} " )
32
+ endif ()
33
+
34
+ if ((gflags_FOUND OR Gflags_FOUND OR GFLAGS_FOUND OR GFLAGS_INCLUDE_DIRS) AND (glog_FOUND OR Glog_FOUND OR GLOG_FOUND OR GLOG_INCLUDE_DIRS))
35
+ set (__cache_key "${GLOG_INCLUDE_DIRS} ~ ${GFLAGS_INCLUDE_DIRS} ~ ${GLOG_LIBRARIES} ~ ${GFLAGS_LIBRARIES} " )
36
+ if (NOT DEFINED SFM_GLOG_GFLAGS_TEST_CACHE_KEY OR NOT (SFM_GLOG_GFLAGS_TEST_CACHE_KEY STREQUAL __cache_key))
37
+ set (__fname "${CMAKE_CURRENT_LIST_DIR} /cmake/checks/check_glog_gflags.cpp" )
38
+ try_compile (
39
+ SFM_GLOG_GFLAGS_TEST "${CMAKE_BINARY_DIR} " "${__fname} "
40
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${GLOG_INCLUDE_DIRS} ;${GFLAGS_INCLUDE_DIRS} "
41
+ LINK_LIBRARIES ${GLOG_LIBRARIES} ${GFLAGS_LIBRARIES}
42
+ OUTPUT_VARIABLE __output
43
+ )
44
+ if (NOT SFM_GLOG_GFLAGS_TEST)
45
+ file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY} /CMakeError.log
46
+ "Failed compilation check: ${__fname} \n "
47
+ "${__output} \n\n "
48
+ )
49
+ endif ()
50
+ set (SFM_GLOG_GFLAGS_TEST "${SFM_GLOG_GFLAGS_TEST} " CACHE INTERNAL "" )
51
+ set (SFM_GLOG_GFLAGS_TEST_CACHE_KEY "${__cache_key} " CACHE INTERNAL "" )
52
+ message (STATUS "Checking SFM glog/gflags deps... ${SFM_GLOG_GFLAGS_TEST} " )
53
+ endif ()
54
+ unset (__cache_key)
55
+ set (SFM_DEPS_OK "${SFM_GLOG_GFLAGS_TEST} " )
23
56
else ()
24
57
set (SFM_DEPS_OK FALSE )
25
58
endif ()
@@ -57,23 +90,14 @@ set(LIBMV_LIGHT_LIBS
57
90
if (Ceres_FOUND)
58
91
add_definitions ("-DCERES_FOUND=1" )
59
92
list (APPEND LIBMV_LIGHT_LIBS simple_pipeline)
60
- list (APPEND LIBMV_LIGHT_INCLUDES "${CERES_INCLUDE_DIR} " )
93
+ if (Ceres_VERSION VERSION_LESS 2.0.0)
94
+ list (APPEND LIBMV_LIGHT_INCLUDES "${CERES_INCLUDE_DIRS} " )
95
+ endif ()
61
96
else ()
62
97
add_definitions ("-DCERES_FOUND=0" )
63
98
message (STATUS "CERES support is disabled. Ceres Solver for reconstruction API is required." )
64
99
endif ()
65
100
66
- ### COMPILE WITH C++11 IF CERES WAS COMPILED WITH C++11
67
-
68
- if (Ceres_FOUND)
69
- list (FIND CERES_COMPILED_COMPONENTS "C++11" _index)
70
- if (${_index} GREATER -1)
71
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
72
- endif ()
73
- endif ()
74
-
75
- ### DEFINE OPENCV SFM MODULE DEPENDENCIES ###
76
-
77
101
### CREATE OPENCV SFM MODULE ###
78
102
79
103
ocv_add_module(sfm
@@ -85,6 +109,7 @@ ocv_add_module(sfm
85
109
WRAP python
86
110
)
87
111
112
+ add_definitions (/DGLOG_NO_ABBREVIATED_SEVERITIES) # avoid ERROR macro conflict in glog (ceres dependency)
88
113
89
114
ocv_warnings_disable(CMAKE_CXX_FLAGS
90
115
-Wundef
@@ -97,12 +122,6 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS
97
122
-Wsuggest-override
98
123
)
99
124
100
- if (UNIX )
101
- if (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
102
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
103
- endif ()
104
- endif ()
105
-
106
125
ocv_include_directories( ${LIBMV_LIGHT_INCLUDES} )
107
126
ocv_module_include_directories()
108
127
@@ -117,14 +136,16 @@ ocv_set_module_sources(HEADERS ${OPENCV_SFM_HDRS}
117
136
118
137
ocv_create_module()
119
138
120
- # build libmv_light
139
+
140
+ ### BUILD libmv_light ###
141
+
121
142
if (NOT CMAKE_VERSION VERSION_LESS 2.8.11) # See ocv_target_include_directories() implementation
122
143
if (TARGET ${the_module} )
123
144
get_target_property (__include_dirs ${the_module} INCLUDE_DIRECTORIES )
124
145
include_directories (${__include_dirs} )
125
146
endif ()
126
147
endif ()
127
- include_directories (${OCV_TARGET_INCLUDE_DIRS_${the_module} })
148
+ # include_directories(${OCV_TARGET_INCLUDE_DIRS_${the_module}})
128
149
add_subdirectory ("${CMAKE_CURRENT_LIST_DIR} /src/libmv_light" "${CMAKE_CURRENT_BINARY_DIR} /src/libmv" )
129
150
130
151
ocv_target_link_libraries(${the_module} ${LIBMV_LIGHT_LIBS} )
@@ -133,6 +154,9 @@ ocv_target_link_libraries(${the_module} ${LIBMV_LIGHT_LIBS})
133
154
### CREATE OPENCV SFM TESTS ###
134
155
135
156
ocv_add_accuracy_tests()
157
+ if (Ceres_FOUND AND TARGET opencv_test_sfm)
158
+ ocv_target_link_libraries(opencv_test_sfm ${CERES_LIBRARIES} )
159
+ endif ()
136
160
137
161
138
162
### CREATE OPENCV SFM SAMPLES ###
0 commit comments