Merge topic 'find_library-msvc-libfoo.a'
c6efbd78d8 MSVC: Teach find_library to consider the 'libfoo.a' naming convention
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9173
diff --git a/Help/release/dev/find_library-msvc-libfoo.a.rst b/Help/release/dev/find_library-msvc-libfoo.a.rst
new file mode 100644
index 0000000..23ba226
--- /dev/null
+++ b/Help/release/dev/find_library-msvc-libfoo.a.rst
@@ -0,0 +1,7 @@
+find_library-msvc-libfoo.a
+--------------------------
+
+* On Windows, when targeting the MSVC ABI, the :command:`find_library` command
+ now accepts ``.a`` file names after first considering ``.lib``. This is
+ symmetric with existing behavior when targeting the GNU ABI, in which the
+ command accepts ``.lib`` file names after first considering ``.a``.
diff --git a/Modules/Platform/Windows.cmake b/Modules/Platform/Windows.cmake
index bc93caa..af7335b 100644
--- a/Modules/Platform/Windows.cmake
+++ b/Modules/Platform/Windows.cmake
@@ -13,10 +13,14 @@
set(CMAKE_DL_LIBS "")
set(CMAKE_EXTRA_LINK_EXTENSIONS ".targets")
-set(CMAKE_FIND_LIBRARY_PREFIXES "")
+set(CMAKE_FIND_LIBRARY_PREFIXES
+ "" # static or import library from MSVC tooling
+ "lib" # static library from Meson with MSVC tooling
+ )
set(CMAKE_FIND_LIBRARY_SUFFIXES
".dll.lib" # import library from Rust toolchain for MSVC ABI
".lib" # static or import library from MSVC tooling
+ ".a" # static library from Meson with MSVC tooling
)
# for borland make long command lines are redirected to a file
diff --git a/Tests/RunCMake/find_library/Windows-MSVC-stdout.txt b/Tests/RunCMake/find_library/Windows-MSVC-stdout.txt
index 598ede5..ef865a0 100644
--- a/Tests/RunCMake/find_library/Windows-MSVC-stdout.txt
+++ b/Tests/RunCMake/find_library/Windows-MSVC-stdout.txt
@@ -1,2 +1,3 @@
-- STATIC_LIBRARY='[^']*/Tests/RunCMake/find_library/Windows-MSVC/static.lib'
+-- MESON_STATIC_LIBRARY='[^']*/Tests/RunCMake/find_library/Windows-MSVC/libmeson_static.a'
-- RUSTC_IMPORT_LIBRARY='[^']*/Tests/RunCMake/find_library/Windows-MSVC/rustc_import.dll.lib'
diff --git a/Tests/RunCMake/find_library/Windows-MSVC.cmake b/Tests/RunCMake/find_library/Windows-MSVC.cmake
index 485952d..c25fd99 100644
--- a/Tests/RunCMake/find_library/Windows-MSVC.cmake
+++ b/Tests/RunCMake/find_library/Windows-MSVC.cmake
@@ -3,5 +3,8 @@
find_library(STATIC_LIBRARY NAMES static NO_DEFAULT_PATH PATHS ${CMAKE_CURRENT_SOURCE_DIR}/Windows-MSVC)
message(STATUS "STATIC_LIBRARY='${STATIC_LIBRARY}'")
+find_library(MESON_STATIC_LIBRARY NAMES meson_static NO_DEFAULT_PATH PATHS ${CMAKE_CURRENT_SOURCE_DIR}/Windows-MSVC)
+message(STATUS "MESON_STATIC_LIBRARY='${MESON_STATIC_LIBRARY}'")
+
find_library(RUSTC_IMPORT_LIBRARY NAMES rustc_import NO_DEFAULT_PATH PATHS ${CMAKE_CURRENT_SOURCE_DIR}/Windows-MSVC)
message(STATUS "RUSTC_IMPORT_LIBRARY='${RUSTC_IMPORT_LIBRARY}'")
diff --git a/Tests/RunCMake/find_library/Windows-MSVC/libmeson_static.a b/Tests/RunCMake/find_library/Windows-MSVC/libmeson_static.a
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_library/Windows-MSVC/libmeson_static.a