From 9c8626746b13f9792b1c4bdf5ec9fe4802695ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Wed, 15 May 2024 15:14:49 +0200 Subject: [PATCH 1/2] FindKLU.cmake: Avoid detecting MSVC libraries when targeting MinGW MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For MinGW, setting the library prefix is not necessary and setting the library suffix to d.lib is incorrect. The static library suffix is .a for MinGW. Prepending those values to the list of library prefixes and suffixes might not actually cause an issue if no libraries are found that match those patterns. But slight ABI differences between MSVC and MinGW could lead to unexpected behavior when mixing binaries of both targets. Signed-off-by: Markus Mützel --- cmake/tpl/FindKLU.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/tpl/FindKLU.cmake b/cmake/tpl/FindKLU.cmake index 96b9d7343b..cb2de58116 100644 --- a/cmake/tpl/FindKLU.cmake +++ b/cmake/tpl/FindKLU.cmake @@ -46,7 +46,7 @@ if (NOT (KLU_INCLUDE_DIR OR KLU_LIBRARY_DIR OR KLU_LIBRARY)) endif() # Set library prefixes for Windows -if(WIN32) +if(MSVC OR ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")) set(CMAKE_FIND_LIBRARY_PREFIXES lib ${CMAKE_FIND_LIBRARY_PREFIXES}) set(CMAKE_FIND_LIBRARY_SUFFIXES d.lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) elseif(APPLE) From 72db70fc7ad97779bedab5511f01d56148543ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Wed, 15 May 2024 18:44:07 +0200 Subject: [PATCH 2/2] FindKLU.cmake: Do not override `CMAKE_FIND_LIBRARY_PREFIXES` for MinGW. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only override `CMAKE_FIND_LIBRARY_PREFIXES` for MSVC. Don't do that for any MinGW target (not just for an MSYS toolchain). Signed-off-by: Markus Mützel --- cmake/tpl/FindKLU.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/tpl/FindKLU.cmake b/cmake/tpl/FindKLU.cmake index cb2de58116..a3d817d037 100644 --- a/cmake/tpl/FindKLU.cmake +++ b/cmake/tpl/FindKLU.cmake @@ -95,7 +95,7 @@ endif () if (NOT SUITESPARSECONFIG_LIBRARY) set(SUITESPARSECONFIG_LIBRARY_NAME suitesparseconfig) # NOTE: no prefix for this library on windows - if(WIN32 AND NOT MSYS) + if(MSVC OR ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")) set(CMAKE_FIND_LIBRARY_PREFIXES "") endif() find_library( SUITESPARSECONFIG_LIBRARY ${SUITESPARSECONFIG_LIBRARY_NAME} ${KLU_LIBRARY_DIR} NO_DEFAULT_PATH)