diff --git a/Help/release/dev/find-rustc-importlibs.rst b/Help/release/dev/find-rustc-importlibs.rst new file mode 100644 index 0000000000..646affff4e --- /dev/null +++ b/Help/release/dev/find-rustc-importlibs.rst @@ -0,0 +1,6 @@ +find-rustc-importlibs +--------------------- + +* On Windows, when targeting the MSVC ABI, the :command:`find_library` command + now considers ``.dll.lib`` file names before ``.lib``. This is the default + suffix for DLL import libraries created by Rust toolchains for the MSVC ABI. diff --git a/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst b/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst index c2c2609dfc..d78dd1582b 100644 --- a/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst +++ b/Help/variable/CMAKE_FIND_LIBRARY_SUFFIXES.rst @@ -5,8 +5,8 @@ Suffixes to append when looking for libraries. This specifies what suffixes to add to library names when the :command:`find_library` command looks for libraries. On Windows systems this -is typically ``.lib`` and, depending on the compiler, ``.dll.a``, ``.a`` -(e.g. GCC and Clang), so when it tries to find the ``foo`` library, it will -look for ``[]foo.lib`` and/or ``[]foo[.dll].a``, depending on -the compiler used and the ```` specified in the -:variable:`CMAKE_FIND_LIBRARY_PREFIXES`. +is typically ``.lib`` and, depending on the compiler, ``.dll.lib``, ``.dll.a``, +``.a`` (e.g. rustc, GCC, or Clang), so when it tries to find the ``foo`` +library, it will look for ``[]foo[.dll].lib`` and/or +``[]foo[.dll].a``, depending on the compiler used and the ```` +specified in the :variable:`CMAKE_FIND_LIBRARY_PREFIXES`. diff --git a/Modules/Platform/Windows.cmake b/Modules/Platform/Windows.cmake index 1bf39cfa6d..bc93caacca 100644 --- a/Modules/Platform/Windows.cmake +++ b/Modules/Platform/Windows.cmake @@ -14,7 +14,10 @@ set(CMAKE_DL_LIBS "") set(CMAKE_EXTRA_LINK_EXTENSIONS ".targets") set(CMAKE_FIND_LIBRARY_PREFIXES "") -set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") +set(CMAKE_FIND_LIBRARY_SUFFIXES + ".dll.lib" # import library from Rust toolchain for MSVC ABI + ".lib" # static or import library from MSVC tooling + ) # for borland make long command lines are redirected to a file # with the following syntax, see Windows-bcc32.cmake for use diff --git a/Tests/RunCMake/find_library/Windows-MSVC-stdout.txt b/Tests/RunCMake/find_library/Windows-MSVC-stdout.txt index af5c30b7a0..598ede53dd 100644 --- a/Tests/RunCMake/find_library/Windows-MSVC-stdout.txt +++ b/Tests/RunCMake/find_library/Windows-MSVC-stdout.txt @@ -1 +1,2 @@ -- STATIC_LIBRARY='[^']*/Tests/RunCMake/find_library/Windows-MSVC/static.lib' +-- 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 212f2c4556..485952d7d3 100644 --- a/Tests/RunCMake/find_library/Windows-MSVC.cmake +++ b/Tests/RunCMake/find_library/Windows-MSVC.cmake @@ -2,3 +2,6 @@ enable_language(C) find_library(STATIC_LIBRARY NAMES static NO_DEFAULT_PATH PATHS ${CMAKE_CURRENT_SOURCE_DIR}/Windows-MSVC) message(STATUS "STATIC_LIBRARY='${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/rustc_import.dll.lib b/Tests/RunCMake/find_library/Windows-MSVC/rustc_import.dll.lib new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Tests/RunCMake/find_library/Windows-MSVC/rustc_import.lib b/Tests/RunCMake/find_library/Windows-MSVC/rustc_import.lib new file mode 100644 index 0000000000..e69de29bb2