From 355553b0a6d32426ba4f4c8f1b0b701f62868d87 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 16 Aug 2017 22:49:17 +0000 Subject: [PATCH] cmake: CMP0026 NEW --- CMakeLists.txt | 5 ++--- cmake/OpenCVDetectAndroidSDK.cmake | 3 +-- cmake/OpenCVGenPkgconfig.cmake | 18 +++++++++--------- modules/java/CMakeLists.txt | 3 +-- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9269469869..36c8a0ca3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,8 +45,7 @@ else() endif() if(POLICY CMP0026) - # silence cmake 3.0+ warnings about reading LOCATION attribute - cmake_policy(SET CMP0026 OLD) + cmake_policy(SET CMP0026 NEW) endif() if (POLICY CMP0042) @@ -1017,7 +1016,7 @@ if(HAVE_OPENCL) set(__libs "") foreach(l ${OPENCL_LIBRARIES}) if(TARGET ${l}) - get_target_property(p ${l} LOCATION) + get_target_property(p ${l} IMPORTED_LOCATION) if(p MATCHES NOTFOUND) list(APPEND __libs "${l}") else() diff --git a/cmake/OpenCVDetectAndroidSDK.cmake b/cmake/OpenCVDetectAndroidSDK.cmake index 7a7053b381..d208f060fa 100644 --- a/cmake/OpenCVDetectAndroidSDK.cmake +++ b/cmake/OpenCVDetectAndroidSDK.cmake @@ -309,9 +309,8 @@ macro(add_android_project target path) LIBRARY_OUTPUT_DIRECTORY "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}" ) - get_target_property(android_proj_jni_location "${JNI_LIB_NAME}" LOCATION) if (NOT (CMAKE_BUILD_TYPE MATCHES "debug")) - add_custom_command(TARGET ${JNI_LIB_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${android_proj_jni_location}") + add_custom_command(TARGET ${JNI_LIB_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$") endif() endif() diff --git a/cmake/OpenCVGenPkgconfig.cmake b/cmake/OpenCVGenPkgconfig.cmake index c3a6b458fa..f6df095656 100644 --- a/cmake/OpenCVGenPkgconfig.cmake +++ b/cmake/OpenCVGenPkgconfig.cmake @@ -46,16 +46,16 @@ endif() set(OpenCV_LIB_COMPONENTS_) foreach(CVLib ${OpenCV_LIB_COMPONENTS}) - get_target_property(libloc ${CVLib} LOCATION_${CMAKE_BUILD_TYPE}) - if(libloc MATCHES "3rdparty") - set(libpath "\${exec_prefix}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}") - else() - set(libpath "\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}") + get_target_property(libname ${CVLib} OUTPUT_NAME_${CMAKE_BUILD_TYPE}) + if(NOT libname) + get_target_property(libname ${CVLib} OUTPUT_NAME) + endif() + if(NOT libname) + set(libname "${CVLib}") endif() - list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libpath}") - get_filename_component(libname ${CVLib} NAME_WE) - string(REGEX REPLACE "^lib" "" libname "${libname}") + set(libpath "\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}") + list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libpath}") list(APPEND OpenCV_LIB_COMPONENTS_ "-l${libname}") endforeach() @@ -66,7 +66,7 @@ if(OpenCV_EXTRA_COMPONENTS) if(TARGET "${extra_component}") get_target_property(extra_component_is_imported "${extra_component}" IMPORTED) if(extra_component_is_imported) - get_target_property(extra_component "${extra_component}" LOCATION) + get_target_property(extra_component "${extra_component}" IMPORTED_LOCATION) endif() endif() diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index f336c94f90..ccf96cda36 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -331,10 +331,9 @@ if(ANDROID) # force strip library after the build command # because samples and tests will make a copy of the library before install - get_target_property(__opencv_java_location ${the_module} LOCATION) # Turn off stripping in debug build if ( NOT (CMAKE_BUILD_TYPE MATCHES "Debug")) - add_custom_command(TARGET ${the_module} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${__opencv_java_location}") + add_custom_command(TARGET ${the_module} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$") endif() endif()