Skip to content

Commit 9e9fd28

Browse files
committed
Merge pull request opencv#8044 from alalek:opencv_world_with_contrib
2 parents 5c13ffb + 4b7c0b9 commit 9e9fd28

File tree

15 files changed

+79
-83
lines changed

15 files changed

+79
-83
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ if(POLICY CMP0022)
7676
cmake_policy(SET CMP0022 OLD)
7777
endif()
7878

79+
if(POLICY CMP0023)
80+
cmake_policy(SET CMP0023 NEW)
81+
endif()
82+
7983
if(POLICY CMP0026)
8084
# silence cmake 3.0+ warnings about reading LOCATION attribute
8185
cmake_policy(SET CMP0026 OLD)

cmake/FindCUDA/run_nvcc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ set(generated_cubin_file_internal "@generated_cubin_file@") # path
7272
set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path
7373
set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list
7474
@CUDA_NVCC_FLAGS_CONFIG@
75-
set(nvcc_flags @nvcc_flags@) # list
75+
set(nvcc_flags "@nvcc_flags@") # list
7676
set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") # list (needs to be in quotes to handle spaces properly).
7777
set(format_flag "@format_flag@") # string
7878

cmake/OpenCVDetectCXXCompiler.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,13 @@ elseif(MINGW)
172172
set(OpenCV_ARCH x86)
173173
endif()
174174
endif()
175+
176+
# Fix handling of duplicated files in the same static library:
177+
# https://public.kitware.com/Bug/view.php?id=14874
178+
if(CMAKE_VERSION VERSION_LESS "3.1")
179+
foreach(var CMAKE_C_ARCHIVE_APPEND CMAKE_CXX_ARCHIVE_APPEND)
180+
if(${var} MATCHES "^<CMAKE_AR> r")
181+
string(REPLACE "<CMAKE_AR> r" "<CMAKE_AR> q" ${var} "${${var}}")
182+
endif()
183+
endforeach()
184+
endif()

cmake/OpenCVGenABI.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ foreach(mod ${OPENCV_MODULES_BUILD})
3333
list(APPEND OPENCV_ABI_SKIP_HEADERS "${h}")
3434
endforeach()
3535
# libraries
36-
set(lib_name "")
37-
get_target_property(lib_name opencv_${mod} LOCATION)
38-
get_filename_component(lib_name "${lib_name}" NAME)
39-
list(APPEND OPENCV_ABI_SKIP_LIBRARIES "${lib_name}")
36+
if(TARGET opencv_${mod}) # opencv_world
37+
set(lib_name "")
38+
get_target_property(lib_name opencv_${mod} LOCATION)
39+
get_filename_component(lib_name "${lib_name}" NAME)
40+
list(APPEND OPENCV_ABI_SKIP_LIBRARIES "${lib_name}")
41+
endif()
4042
endif()
4143
endforeach()
4244
string(REPLACE ";" "\n " OPENCV_ABI_SKIP_HEADERS "${OPENCV_ABI_SKIP_HEADERS}")

cmake/OpenCVModule.cmake

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ macro(ocv_add_module _name)
182182
# add self to the world dependencies
183183
if((NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD
184184
AND NOT OPENCV_MODULE_${the_module}_CLASS STREQUAL "BINDINGS"
185-
AND NOT OPENCV_PROCESSING_EXTRA_MODULES
185+
AND (NOT OPENCV_PROCESSING_EXTRA_MODULES OR NOT OPENCV_WORLD_EXCLUDE_EXTRA_MODULES)
186186
AND (NOT BUILD_SHARED_LIBS OR NOT "x${OPENCV_MODULE_TYPE}" STREQUAL "xSTATIC"))
187187
OR OPENCV_MODULE_IS_PART_OF_WORLD
188188
)
@@ -233,7 +233,7 @@ macro(ocv_add_module _name)
233233
endmacro()
234234

235235
# excludes module from current configuration
236-
macro(ocv_module_disable module)
236+
macro(ocv_module_disable_ module)
237237
set(__modname ${module})
238238
if(NOT __modname MATCHES "^opencv_")
239239
set(__modname opencv_${module})
@@ -246,9 +246,12 @@ macro(ocv_module_disable module)
246246
# touch variable controlling build of the module to suppress "unused variable" CMake warning
247247
endif()
248248
unset(__modname)
249-
return() # leave the current folder
250249
endmacro()
251250

251+
macro(ocv_module_disable module)
252+
ocv_module_disable_(${module})
253+
return() # leave the current folder
254+
endmacro()
252255

253256
# collect modules from specified directories
254257
# NB: must be called only once!
@@ -724,8 +727,10 @@ endmacro()
724727
# ocv_create_module(<extra link dependencies>)
725728
# ocv_create_module()
726729
macro(ocv_create_module)
727-
ocv_debug_message("ocv_create_module(" ${ARGN} ")")
728-
set(OPENCV_MODULE_${the_module}_LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "")
730+
ocv_debug_message("${the_module}: ocv_create_module(" ${ARGN} ")")
731+
if(NOT " ${ARGN}" STREQUAL " ")
732+
set(OPENCV_MODULE_${the_module}_LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "")
733+
endif()
729734
if(${BUILD_opencv_world} AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
730735
# nothing
731736
set(the_module_target opencv_world)

cmake/OpenCVPCHSupport.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,11 @@ ENDMACRO(ADD_PRECOMPILED_HEADER)
303303

304304
MACRO(GET_NATIVE_PRECOMPILED_HEADER _targetName _input)
305305

306+
if(ENABLE_PRECOMPILED_HEADERS)
306307
if(CMAKE_GENERATOR MATCHES "^Visual.*$")
307308
set(${_targetName}_pch ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch.cpp)
308309
endif()
310+
endif()
309311

310312
ENDMACRO(GET_NATIVE_PRECOMPILED_HEADER)
311313

cmake/OpenCVUtils.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,14 @@ function(ocv_target_link_libraries target)
887887
if(";${LINK_DEPS};" MATCHES ";${target};")
888888
list(REMOVE_ITEM LINK_DEPS "${target}") # prevent "link to itself" warning (world problem)
889889
endif()
890-
target_link_libraries(${target} ${LINK_DEPS})
890+
if(NOT TARGET ${target})
891+
if(NOT DEFINED OPENCV_MODULE_${target}_LOCATION)
892+
message(FATAL_ERROR "ocv_target_link_libraries: invalid target: '${target}'")
893+
endif()
894+
set(OPENCV_MODULE_${target}_LINK_DEPS ${OPENCV_MODULE_${target}_LINK_DEPS} ${LINK_DEPS} CACHE INTERNAL "" FORCE)
895+
else()
896+
target_link_libraries(${target} ${LINK_DEPS})
897+
endif()
891898
endfunction()
892899

893900
function(_ocv_append_target_includes target)

modules/python/CMakeLists.txt

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22
# CMake file for python support
33
# ----------------------------------------------------------------------------
44

5-
if((WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
6-
OR BUILD_opencv_world
7-
)
8-
ocv_module_disable(python2)
9-
ocv_module_disable(python3)
5+
if(ANDROID OR APPLE_FRAMEWORK OR WINRT)
6+
set(__disable_python2 ON)
7+
set(__disable_python3 ON)
8+
elseif(BUILD_opencv_world OR (WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug"))
9+
if(NOT DEFINED BUILD_opencv_python2)
10+
set(__disable_python2 ON)
11+
endif()
12+
if(NOT DEFINED BUILD_opencv_python3)
13+
set(__disable_python3 ON)
14+
endif()
1015
endif()
1116

12-
if(ANDROID OR APPLE_FRAMEWORK OR WINRT)
13-
ocv_module_disable(python2)
14-
ocv_module_disable(python3)
17+
if(__disable_python2)
18+
ocv_module_disable_(python2)
19+
endif()
20+
if(__disable_python3)
21+
ocv_module_disable_(python3)
22+
endif()
23+
if(__disable_python2 AND __disable_python3)
24+
return()
1525
endif()
1626

1727
add_subdirectory(python2)

modules/shape/src/precomp.cpp

Lines changed: 0 additions & 45 deletions
This file was deleted.

modules/stitching/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if(HAVE_CUDA)
55
endif()
66

77
set(STITCHING_CONTRIB_DEPS "opencv_xfeatures2d")
8-
if(BUILD_SHARED_LIBS AND BUILD_opencv_world)
8+
if(BUILD_SHARED_LIBS AND BUILD_opencv_world AND OPENCV_WORLD_EXCLUDE_EXTRA_MODULES)
99
set(STITCHING_CONTRIB_DEPS "")
1010
endif()
1111
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect

0 commit comments

Comments
 (0)