Skip to content

Commit 355553b

Browse files
committed
cmake: CMP0026 NEW
1 parent d25b041 commit 355553b

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ else()
4545
endif()
4646

4747
if(POLICY CMP0026)
48-
# silence cmake 3.0+ warnings about reading LOCATION attribute
49-
cmake_policy(SET CMP0026 OLD)
48+
cmake_policy(SET CMP0026 NEW)
5049
endif()
5150

5251
if (POLICY CMP0042)
@@ -1017,7 +1016,7 @@ if(HAVE_OPENCL)
10171016
set(__libs "")
10181017
foreach(l ${OPENCL_LIBRARIES})
10191018
if(TARGET ${l})
1020-
get_target_property(p ${l} LOCATION)
1019+
get_target_property(p ${l} IMPORTED_LOCATION)
10211020
if(p MATCHES NOTFOUND)
10221021
list(APPEND __libs "${l}")
10231022
else()

cmake/OpenCVDetectAndroidSDK.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,8 @@ macro(add_android_project target path)
309309
LIBRARY_OUTPUT_DIRECTORY "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}"
310310
)
311311

312-
get_target_property(android_proj_jni_location "${JNI_LIB_NAME}" LOCATION)
313312
if (NOT (CMAKE_BUILD_TYPE MATCHES "debug"))
314-
add_custom_command(TARGET ${JNI_LIB_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${android_proj_jni_location}")
313+
add_custom_command(TARGET ${JNI_LIB_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$<TARGET_FILE:${JNI_LIB_NAME}>")
315314
endif()
316315
endif()
317316

cmake/OpenCVGenPkgconfig.cmake

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ endif()
4646
set(OpenCV_LIB_COMPONENTS_)
4747
foreach(CVLib ${OpenCV_LIB_COMPONENTS})
4848

49-
get_target_property(libloc ${CVLib} LOCATION_${CMAKE_BUILD_TYPE})
50-
if(libloc MATCHES "3rdparty")
51-
set(libpath "\${exec_prefix}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}")
52-
else()
53-
set(libpath "\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}")
49+
get_target_property(libname ${CVLib} OUTPUT_NAME_${CMAKE_BUILD_TYPE})
50+
if(NOT libname)
51+
get_target_property(libname ${CVLib} OUTPUT_NAME)
52+
endif()
53+
if(NOT libname)
54+
set(libname "${CVLib}")
5455
endif()
55-
list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libpath}")
5656

57-
get_filename_component(libname ${CVLib} NAME_WE)
58-
string(REGEX REPLACE "^lib" "" libname "${libname}")
57+
set(libpath "\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}")
58+
list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libpath}")
5959
list(APPEND OpenCV_LIB_COMPONENTS_ "-l${libname}")
6060

6161
endforeach()
@@ -66,7 +66,7 @@ if(OpenCV_EXTRA_COMPONENTS)
6666
if(TARGET "${extra_component}")
6767
get_target_property(extra_component_is_imported "${extra_component}" IMPORTED)
6868
if(extra_component_is_imported)
69-
get_target_property(extra_component "${extra_component}" LOCATION)
69+
get_target_property(extra_component "${extra_component}" IMPORTED_LOCATION)
7070
endif()
7171
endif()
7272

modules/java/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,9 @@ if(ANDROID)
331331

332332
# force strip library after the build command
333333
# because samples and tests will make a copy of the library before install
334-
get_target_property(__opencv_java_location ${the_module} LOCATION)
335334
# Turn off stripping in debug build
336335
if ( NOT (CMAKE_BUILD_TYPE MATCHES "Debug"))
337-
add_custom_command(TARGET ${the_module} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${__opencv_java_location}")
336+
add_custom_command(TARGET ${the_module} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$<TARGET_FILE:${the_module}>")
338337
endif()
339338
endif()
340339

0 commit comments

Comments
 (0)