@@ -787,15 +787,12 @@ macro(_ocv_create_module)
787
787
endif ()
788
788
789
789
set (sub_objs "" )
790
- set (sub_links "" )
791
790
set (cuda_objs "" )
792
791
if (OPENCV_MODULE_${the_module}_CHILDREN )
793
792
message (STATUS "Complex module ${the_module} " )
794
793
foreach (m ${OPENCV_MODULE_${the_module}_CHILDREN} )
795
794
if (BUILD_${m} AND TARGET ${m} _object )
796
- get_target_property (_sub_links ${m} LINK_LIBRARIES )
797
795
list (APPEND sub_objs $< TARGET_OBJECTS:${m} _object> )
798
- list (APPEND sub_links ${_sub_links} )
799
796
message (STATUS " + ${m} " )
800
797
else ()
801
798
message (STATUS " - ${m} " )
@@ -837,38 +834,21 @@ macro(_ocv_create_module)
837
834
)
838
835
839
836
if (cuda_objs )
840
- target_link_libraries (${the_module} ${cuda_objs} )
841
- endif ()
842
-
843
- # TODO: is it needed?
844
- if (sub_links )
845
- ocv_list_filterout (sub_links "^opencv_" )
846
- ocv_list_unique (sub_links )
847
- target_link_libraries (${the_module} ${sub_links} )
837
+ target_link_libraries (${the_module} LINK_PRIVATE ${cuda_objs} )
848
838
endif ()
849
839
850
840
unset (sub_objs )
851
- unset (sub_links )
852
841
unset (cuda_objs )
853
842
854
843
set_target_properties (${the_module} PROPERTIES LABELS "${OPENCV_MODULE_${the_module} _LABEL};Module" )
855
844
set_source_files_properties (${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES} ${${the_module}_pch}
856
845
PROPERTIES LABELS "${OPENCV_MODULE_${the_module} _LABEL};Module" )
857
846
858
- if (NOT BUILD_SHARED_LIBS OR NOT INSTALL_CREATE_DISTRIB )
859
- ocv_target_link_libraries (${the_module} ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK} )
860
- ocv_target_link_libraries (${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK} )
861
- ocv_target_link_libraries (${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN} )
862
- if (HAVE_CUDA )
863
- ocv_target_link_libraries (${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY} )
864
- endif ()
865
- else ()
866
- ocv_target_link_libraries (${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK} )
867
- ocv_target_link_libraries (${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK} )
868
- ocv_target_link_libraries (${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN} )
869
- if (HAVE_CUDA )
870
- ocv_target_link_libraries (${the_module} LINK_PRIVATE ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY} )
871
- endif ()
847
+ ocv_target_link_libraries (${the_module} LINK_PUBLIC ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK} )
848
+ ocv_target_link_libraries (${the_module} LINK_PUBLIC ${OPENCV_MODULE_${the_module}_DEPS_EXT} )
849
+ ocv_target_link_libraries (${the_module} LINK_PRIVATE ${OPENCV_LINKER_LIBS} ${OPENCV_HAL_LINKER_LIBS} ${IPP_LIBS} ${ARGN} )
850
+ if (HAVE_CUDA )
851
+ ocv_target_link_libraries (${the_module} LINK_PRIVATE ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY} )
872
852
endif ()
873
853
874
854
add_dependencies (opencv_modules ${the_module} )
@@ -1074,7 +1054,7 @@ function(ocv_add_perf_tests)
1074
1054
source_group ("Src" FILES "${${the_target} _pch}" )
1075
1055
ocv_add_executable (${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch} )
1076
1056
ocv_target_include_modules (${the_target} ${perf_deps} "${perf_path} " )
1077
- ocv_target_link_libraries (${the_target} ${perf_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS} )
1057
+ ocv_target_link_libraries (${the_target} LINK_PRIVATE ${perf_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS} )
1078
1058
add_dependencies (opencv_perf_tests ${the_target} )
1079
1059
1080
1060
set_target_properties (${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module} _LABEL};PerfTest" )
@@ -1151,7 +1131,7 @@ function(ocv_add_accuracy_tests)
1151
1131
source_group ("Src" FILES "${${the_target} _pch}" )
1152
1132
ocv_add_executable (${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch} )
1153
1133
ocv_target_include_modules (${the_target} ${test_deps} "${test_path} " )
1154
- ocv_target_link_libraries (${the_target} ${test_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS} )
1134
+ ocv_target_link_libraries (${the_target} LINK_PRIVATE ${test_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS} )
1155
1135
add_dependencies (opencv_tests ${the_target} )
1156
1136
1157
1137
set_target_properties (${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module} _LABEL};AccuracyTest" )
@@ -1208,7 +1188,7 @@ function(ocv_add_samples)
1208
1188
1209
1189
ocv_add_executable (${the_target} "${source} " )
1210
1190
ocv_target_include_modules (${the_target} ${samples_deps} )
1211
- ocv_target_link_libraries (${the_target} ${samples_deps} )
1191
+ ocv_target_link_libraries (${the_target} LINK_PRIVATE ${samples_deps} )
1212
1192
set_target_properties (${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name} " )
1213
1193
1214
1194
set_target_properties (${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module} _LABEL};Sample" )
0 commit comments