cmake: CMP0026 NEW

This commit is contained in:
Alexander Alekhin 2017-08-16 22:49:17 +00:00 committed by Alexander Alekhin
parent d25b04149a
commit 355553b0a6
4 changed files with 13 additions and 16 deletions

View File

@ -45,8 +45,7 @@ else()
endif() endif()
if(POLICY CMP0026) if(POLICY CMP0026)
# silence cmake 3.0+ warnings about reading LOCATION attribute cmake_policy(SET CMP0026 NEW)
cmake_policy(SET CMP0026 OLD)
endif() endif()
if (POLICY CMP0042) if (POLICY CMP0042)
@ -1017,7 +1016,7 @@ if(HAVE_OPENCL)
set(__libs "") set(__libs "")
foreach(l ${OPENCL_LIBRARIES}) foreach(l ${OPENCL_LIBRARIES})
if(TARGET ${l}) if(TARGET ${l})
get_target_property(p ${l} LOCATION) get_target_property(p ${l} IMPORTED_LOCATION)
if(p MATCHES NOTFOUND) if(p MATCHES NOTFOUND)
list(APPEND __libs "${l}") list(APPEND __libs "${l}")
else() else()

View File

@ -309,9 +309,8 @@ macro(add_android_project target path)
LIBRARY_OUTPUT_DIRECTORY "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}" 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")) 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 "$<TARGET_FILE:${JNI_LIB_NAME}>")
endif() endif()
endif() endif()

View File

@ -46,16 +46,16 @@ endif()
set(OpenCV_LIB_COMPONENTS_) set(OpenCV_LIB_COMPONENTS_)
foreach(CVLib ${OpenCV_LIB_COMPONENTS}) foreach(CVLib ${OpenCV_LIB_COMPONENTS})
get_target_property(libloc ${CVLib} LOCATION_${CMAKE_BUILD_TYPE}) get_target_property(libname ${CVLib} OUTPUT_NAME_${CMAKE_BUILD_TYPE})
if(libloc MATCHES "3rdparty") if(NOT libname)
set(libpath "\${exec_prefix}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}") get_target_property(libname ${CVLib} OUTPUT_NAME)
else() endif()
set(libpath "\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}") if(NOT libname)
set(libname "${CVLib}")
endif() endif()
list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libpath}")
get_filename_component(libname ${CVLib} NAME_WE) set(libpath "\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}")
string(REGEX REPLACE "^lib" "" libname "${libname}") list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libpath}")
list(APPEND OpenCV_LIB_COMPONENTS_ "-l${libname}") list(APPEND OpenCV_LIB_COMPONENTS_ "-l${libname}")
endforeach() endforeach()
@ -66,7 +66,7 @@ if(OpenCV_EXTRA_COMPONENTS)
if(TARGET "${extra_component}") if(TARGET "${extra_component}")
get_target_property(extra_component_is_imported "${extra_component}" IMPORTED) get_target_property(extra_component_is_imported "${extra_component}" IMPORTED)
if(extra_component_is_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()
endif() endif()

View File

@ -331,10 +331,9 @@ if(ANDROID)
# force strip library after the build command # force strip library after the build command
# because samples and tests will make a copy of the library before install # 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 # Turn off stripping in debug build
if ( NOT (CMAKE_BUILD_TYPE MATCHES "Debug")) 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 "$<TARGET_FILE:${the_module}>")
endif() endif()
endif() endif()