summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_library/LibArchLink.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-02-28 18:51:35 (GMT)
committerBrad King <brad.king@kitware.com>2017-02-28 19:56:54 (GMT)
commit6f5aede71642b05a351d5cf92e0c884ed9b4fd3c (patch)
treef1f5686398ea5829717832deb516b749bc685a7c /Tests/RunCMake/find_library/LibArchLink.cmake
parente67963ed7316768bf0ebfbe42137d028c0d1d2a4 (diff)
downloadCMake-6f5aede71642b05a351d5cf92e0c884ed9b4fd3c.zip
CMake-6f5aede71642b05a351d5cf92e0c884ed9b4fd3c.tar.gz
CMake-6f5aede71642b05a351d5cf92e0c884ed9b4fd3c.tar.bz2
find_library: Skip 'lib => lib<arch>' searches if one symlinks the other
The `FIND_LIBRARY_USE_LIB<arch>_PATHS` global properties ask `find_library` to look in `lib<arch>` directories automatically before corresponding `lib` directories. However, if `lib<arch>` is just a symlink to `lib` (or vice-versa) then we should skip adding the `lib<arch>` path. Such symlinks typically only exist to satisfy software that expects the `lib<arch>` path to be available. Fixes: #16687
Diffstat (limited to 'Tests/RunCMake/find_library/LibArchLink.cmake')
-rw-r--r--Tests/RunCMake/find_library/LibArchLink.cmake24
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_library/LibArchLink.cmake b/Tests/RunCMake/find_library/LibArchLink.cmake
new file mode 100644
index 0000000..c91381d
--- /dev/null
+++ b/Tests/RunCMake/find_library/LibArchLink.cmake
@@ -0,0 +1,24 @@
+set(CMAKE_SIZEOF_VOID_P 4)
+set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS ON)
+list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
+list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)
+
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink lib ${CMAKE_CURRENT_BINARY_DIR}/lib32)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libtop.a" "top")
+find_library(TOP_LIBRARY
+ NAMES top
+ PATHS ${CMAKE_CURRENT_BINARY_DIR}/lib
+ NO_DEFAULT_PATH
+ )
+message("TOP_LIBRARY='${TOP_LIBRARY}'")
+
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/sub)
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink . ${CMAKE_CURRENT_BINARY_DIR}/lib/sub/32)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/sub/libsub.a" "sub")
+find_library(SUB_LIBRARY
+ NAMES sub
+ PATHS ${CMAKE_CURRENT_BINARY_DIR}/lib/sub
+ NO_DEFAULT_PATH
+ )
+message("SUB_LIBRARY='${SUB_LIBRARY}'")