Skip to content

Commit 36b3446

Browse files
committed
cmake: include contrib modules into opencv_world
1 parent 9bb5d6c commit 36b3446

File tree

9 files changed

+41
-15
lines changed

9 files changed

+41
-15
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/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: 5 additions & 3 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
)
@@ -724,8 +724,10 @@ endmacro()
724724
# ocv_create_module(<extra link dependencies>)
725725
# ocv_create_module()
726726
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 "")
727+
ocv_debug_message("${the_module}: ocv_create_module(" ${ARGN} ")")
728+
if(NOT " ${ARGN}" STREQUAL " ")
729+
set(OPENCV_MODULE_${the_module}_LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "")
730+
endif()
729731
if(${BUILD_opencv_world} AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD)
730732
# nothing
731733
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/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

modules/ts/misc/run_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def setDummy(self, path):
193193
self.tests_dir = os.path.normpath(path)
194194

195195
def read(self, path, fname):
196-
rx = re.compile(r'^opencv_(\w+)_SOURCE_DIR:STATIC=(.*)$')
196+
rx = re.compile(r'^OPENCV_MODULE_opencv_(\w+)_LOCATION:INTERNAL=(.*)$')
197197
module_paths = {} # name -> path
198198
with open(fname, "rt") as cachefile:
199199
for l in cachefile.readlines():

modules/viz/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ if(NOT WITH_VTK OR NOT DEFINED HAVE_VTK OR NOT HAVE_VTK)
22
ocv_module_disable(viz)
33
endif()
44

5-
include(${VTK_USE_FILE})
65
set(the_description "Viz")
7-
ocv_define_module(viz opencv_core ${VTK_LIBRARIES} WRAP python)
6+
ocv_define_module(viz opencv_core WRAP python)
7+
8+
include(${VTK_USE_FILE})
9+
ocv_target_link_libraries(${the_module} ${VTK_LIBRARIES})
810

911
if(APPLE AND BUILD_opencv_viz)
10-
ocv_target_link_libraries(opencv_viz "-framework Cocoa")
12+
ocv_target_link_libraries(${the_module} "-framework Cocoa")
1113
endif()
1214

1315
if(TARGET opencv_test_viz)

modules/world/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ endif()
1111

1212
function(include_one_module m)
1313
include("${OPENCV_MODULE_${m}_LOCATION}/CMakeLists.txt")
14+
foreach(var
15+
CMAKE_CXX_FLAGS CMAKE_C_FLAGS # Propagate warnings settings
16+
)
17+
set(${var} "${${var}}" PARENT_SCOPE)
18+
endforeach()
1419
endfunction()
1520

1621
if(NOT OPENCV_INITIAL_PASS)
@@ -35,12 +40,14 @@ ocv_add_module(world opencv_core)
3540
set(headers_list "HEADERS")
3641
set(sources_list "SOURCES")
3742
set(link_deps "")
38-
foreach(m ${OPENCV_MODULE_${the_module}_DEPS})
43+
foreach(m ${OPENCV_MODULE_${the_module}_DEPS} opencv_world)
3944
if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
4045
set(headers_list "${headers_list};${OPENCV_MODULE_${m}_HEADERS}")
4146
set(sources_list "${sources_list};${OPENCV_MODULE_${m}_SOURCES}")
4247
endif()
43-
set(link_deps "${link_deps};${OPENCV_MODULE_${m}_LINK_DEPS}")
48+
if(NOT " ${OPENCV_MODULE_${m}_LINK_DEPS}" STREQUAL " ")
49+
list(APPEND link_deps ${OPENCV_MODULE_${m}_LINK_DEPS})
50+
endif()
4451
endforeach()
4552

4653
ocv_glob_module_sources(${headers_list} ${sources_list})

0 commit comments

Comments
 (0)