Commit b6949c50 authored by Alexander Alekhin's avatar Alexander Alekhin

cmake: CMP0022 NEW

parent 870d9502
......@@ -77,14 +77,6 @@ if(WINRT)
endif()
endif()
if(POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
endif()
if(POLICY CMP0023)
cmake_policy(SET CMP0023 NEW)
endif()
if(POLICY CMP0026)
# silence cmake 3.0+ warnings about reading LOCATION attribute
cmake_policy(SET CMP0026 OLD)
......
......@@ -1556,7 +1556,7 @@ macro(CUDA_ADD_LIBRARY cuda_target)
# variable will have been defined.
CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}")
target_link_libraries(${cuda_target}
target_link_libraries(${cuda_target} LINK_PRIVATE
${CUDA_LIBRARIES}
)
......@@ -1600,7 +1600,7 @@ macro(CUDA_ADD_EXECUTABLE cuda_target)
# variable will have been defined.
CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}")
target_link_libraries(${cuda_target}
target_link_libraries(${cuda_target} LINK_PRIVATE
${CUDA_LIBRARIES}
)
......@@ -1675,9 +1675,9 @@ endmacro()
###############################################################################
macro(CUDA_ADD_CUFFT_TO_TARGET target)
if (CUDA_BUILD_EMULATION)
target_link_libraries(${target} ${CUDA_cufftemu_LIBRARY})
target_link_libraries(${target} LINK_PRIVATE ${CUDA_cufftemu_LIBRARY})
else()
target_link_libraries(${target} ${CUDA_cufft_LIBRARY})
target_link_libraries(${target} LINK_PRIVATE ${CUDA_cufft_LIBRARY})
endif()
endmacro()
......@@ -1688,9 +1688,9 @@ endmacro()
###############################################################################
macro(CUDA_ADD_CUBLAS_TO_TARGET target)
if (CUDA_BUILD_EMULATION)
target_link_libraries(${target} ${CUDA_cublasemu_LIBRARY})
target_link_libraries(${target} LINK_PRIVATE ${CUDA_cublasemu_LIBRARY})
else()
target_link_libraries(${target} ${CUDA_cublas_LIBRARY})
target_link_libraries(${target} LINK_PRIVATE ${CUDA_cublas_LIBRARY})
endif()
endmacro()
......
......@@ -290,7 +290,7 @@ macro(add_android_project target path)
add_library(${JNI_LIB_NAME} SHARED ${android_proj_jni_files})
ocv_target_include_modules_recurse(${JNI_LIB_NAME} ${android_proj_NATIVE_DEPS})
ocv_target_include_directories(${JNI_LIB_NAME} "${path}/jni")
ocv_target_link_libraries(${JNI_LIB_NAME} ${OPENCV_LINKER_LIBS} ${android_proj_NATIVE_DEPS})
ocv_target_link_libraries(${JNI_LIB_NAME} LINK_PRIVATE ${OPENCV_LINKER_LIBS} ${android_proj_NATIVE_DEPS})
set_target_properties(${JNI_LIB_NAME} PROPERTIES
OUTPUT_NAME "${JNI_LIB_NAME}"
......
......@@ -787,15 +787,12 @@ macro(_ocv_create_module)
endif()
set(sub_objs "")
set(sub_links "")
set(cuda_objs "")
if (OPENCV_MODULE_${the_module}_CHILDREN)
message(STATUS "Complex module ${the_module}")
foreach (m ${OPENCV_MODULE_${the_module}_CHILDREN})
if (BUILD_${m} AND TARGET ${m}_object)
get_target_property(_sub_links ${m} LINK_LIBRARIES)
list(APPEND sub_objs $<TARGET_OBJECTS:${m}_object>)
list(APPEND sub_links ${_sub_links})
message(STATUS " + ${m}")
else()
message(STATUS " - ${m}")
......@@ -837,38 +834,21 @@ macro(_ocv_create_module)
)
if (cuda_objs)
target_link_libraries(${the_module} ${cuda_objs})
endif()
# TODO: is it needed?
if (sub_links)
ocv_list_filterout(sub_links "^opencv_")
ocv_list_unique(sub_links)
target_link_libraries(${the_module} ${sub_links})
target_link_libraries(${the_module} LINK_PRIVATE ${cuda_objs})
endif()
unset(sub_objs)
unset(sub_links)
unset(cuda_objs)
set_target_properties(${the_module} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Module")
set_source_files_properties(${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES} ${${the_module}_pch}
PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Module")
if(NOT BUILD_SHARED_LIBS OR NOT INSTALL_CREATE_DISTRIB)
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
ocv_target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
if (HAVE_CUDA)
ocv_target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
endif()
else()
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
if (HAVE_CUDA)
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
endif()
ocv_target_link_libraries(${the_module} LINK_PUBLIC ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK})
ocv_target_link_libraries(${the_module} LINK_PUBLIC ${OPENCV_MODULE_${the_module}_DEPS_EXT})
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_LINKER_LIBS} ${OPENCV_HAL_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
if (HAVE_CUDA)
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
endif()
add_dependencies(opencv_modules ${the_module})
......@@ -1074,7 +1054,7 @@ function(ocv_add_perf_tests)
source_group("Src" FILES "${${the_target}_pch}")
ocv_add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch})
ocv_target_include_modules(${the_target} ${perf_deps} "${perf_path}")
ocv_target_link_libraries(${the_target} ${perf_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${perf_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
add_dependencies(opencv_perf_tests ${the_target})
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};PerfTest")
......@@ -1151,7 +1131,7 @@ function(ocv_add_accuracy_tests)
source_group("Src" FILES "${${the_target}_pch}")
ocv_add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch})
ocv_target_include_modules(${the_target} ${test_deps} "${test_path}")
ocv_target_link_libraries(${the_target} ${test_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${test_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
add_dependencies(opencv_tests ${the_target})
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};AccuracyTest")
......@@ -1208,7 +1188,7 @@ function(ocv_add_samples)
ocv_add_executable(${the_target} "${source}")
ocv_target_include_modules(${the_target} ${samples_deps})
ocv_target_link_libraries(${the_target} ${samples_deps})
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${samples_deps})
set_target_properties(${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name}")
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
......
......@@ -4,7 +4,6 @@ ocv_add_dispatched_file(mathfuncs_core SSE2 AVX AVX2)
ocv_add_dispatched_file(stat SSE4_2 AVX2)
ocv_add_module(core
"${OPENCV_HAL_LINKER_LIBS}"
OPTIONAL opencv_cudev
WRAP java python)
......@@ -57,10 +56,11 @@ endif()
ocv_create_module(${extra_libs})
ocv_target_link_libraries(${the_module}
ocv_target_link_libraries(${the_module} LINK_PRIVATE
"${ZLIB_LIBRARIES}" "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}"
"${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}"
"${ITT_LIBRARIES}"
"${OPENCV_HAL_LINKER_LIBS}"
)
ocv_add_accuracy_tests()
......
......@@ -16,7 +16,9 @@ if(OCV_DEPENDENCIES_FOUND)
ocv_cuda_filter_options()
CUDA_ADD_EXECUTABLE(${the_target} ${OPENCV_TEST_${the_module}_SOURCES})
ocv_target_link_libraries(${the_target} ${test_deps} ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES})
ocv_target_link_libraries(${the_target} LINK_PRIVATE
${test_deps} ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES}
)
add_dependencies(opencv_tests ${the_target})
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL}")
......
......@@ -147,11 +147,6 @@ if(MSVC)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()
if(NOT BUILD_opencv_world)
#stop automatic dependencies propagation for this module
set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
endmacro()
......
......@@ -123,9 +123,6 @@ if(MSVC)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()
#stop automatic dependencies propagation for this module
set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
endmacro()
......
......@@ -435,14 +435,14 @@ if(BUILD_FAT_JAVA_LIB)
endif()
if(APPLE)
foreach(_dep ${__deps})
ocv_target_link_libraries(${the_module} -Wl,-force_load "${_dep}")
ocv_target_link_libraries(${the_module} LINK_PRIVATE -Wl,-force_load "${_dep}")
endforeach()
else()
ocv_target_link_libraries(${the_module} -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive)
ocv_target_link_libraries(${the_module} LINK_PRIVATE -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive)
endif()
ocv_target_link_libraries(${the_module} ${__extradeps} ${OPENCV_LINKER_LIBS})
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${__extradeps} ${OPENCV_LINKER_LIBS})
else()
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
endif()
# Additional target properties
......@@ -451,12 +451,12 @@ set_target_properties(${the_module} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
LINK_INTERFACE_LIBRARIES ""
)
if(ANDROID)
ocv_target_link_libraries(${the_module} jnigraphics) # for Mat <=> Bitmap converters
ocv_target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_LINKER_LIBS} jnigraphics)
ocv_target_link_libraries(${the_module} LINK_PUBLIC jnigraphics) # for Mat <=> Bitmap converters
ocv_target_link_libraries(${the_module} LINK_PUBLIC log dl z)
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_LINKER_LIBS})
# force strip library after the build command
# because samples and tests will make a copy of the library before install
......
......@@ -72,12 +72,12 @@ if(APPLE)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
elseif(WIN32 OR OPENCV_FORCE_PYTHON_LIBS)
if(${PYTHON}_DEBUG_LIBRARIES AND NOT ${PYTHON}_LIBRARIES MATCHES "optimized.*debug")
ocv_target_link_libraries(${the_module} debug ${${PYTHON}_DEBUG_LIBRARIES} optimized ${${PYTHON}_LIBRARIES})
ocv_target_link_libraries(${the_module} LINK_PRIVATE debug ${${PYTHON}_DEBUG_LIBRARIES} optimized ${${PYTHON}_LIBRARIES})
else()
ocv_target_link_libraries(${the_module} ${${PYTHON}_LIBRARIES})
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${${PYTHON}_LIBRARIES})
endif()
endif()
ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS})
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS})
if(DEFINED ${PYTHON}_CVPY_SUFFIX)
set(CVPY_SUFFIX "${${PYTHON}_CVPY_SUFFIX}")
......
......@@ -261,11 +261,6 @@ if(MSVC)
endif()
endif()
#stop automatic dependencies propagation for this module
if(NOT BUILD_opencv_world)
set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
if(WIN32 AND HAVE_FFMPEG)
......
......@@ -25,10 +25,10 @@ if(NOT BUILD_SHARED_LIBS)
endif()
ocv_define_module(viz opencv_core WRAP python)
ocv_target_link_libraries(${the_module} ${VTK_LIBRARIES})
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${VTK_LIBRARIES})
if(APPLE AND BUILD_opencv_viz)
ocv_target_link_libraries(${the_module} "-framework Cocoa")
ocv_target_link_libraries(${the_module} LINK_PRIVATE "-framework Cocoa")
endif()
if(TARGET opencv_test_viz)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment