Skip to content

Commit

Permalink
[cmake] Use CMAKE_CXX_SIMULATE_ID to distinguish MSVC ABI in Findzstd
Browse files Browse the repository at this point in the history
Instead of unconditionally assuming MSVC-alike behavior for WIN32 that
could negatively impact MSVC, use `CMAKE_CXX_SIMULATE_ID` to detect
Clang using MSVC ABI.  Note that this variable is unset for MSVC itself,
so use it alternatively to MSVC.  Thanks to @isuruf for the suggestion
(conda-forge/llvmdev-feedstock#306 (comment)).
  • Loading branch information
mgorny committed Jan 2, 2025
1 parent 003686f commit 0e5ba65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/cmake/modules/Findzstd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# zstd::libzstd_shared
# zstd::libzstd_static

if(WIN32)
if(MSVC OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
set(zstd_STATIC_LIBRARY_SUFFIX "_static\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
else()
set(zstd_STATIC_LIBRARY_SUFFIX "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
Expand All @@ -33,7 +33,7 @@ if(zstd_FOUND)
set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
elseif (NOT TARGET zstd::libzstd_shared)
add_library(zstd::libzstd_shared SHARED IMPORTED)
if(WIN32)
if(MSVC OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
include(GNUInstallDirs) # For CMAKE_INSTALL_LIBDIR and friends.
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY)
Expand Down

0 comments on commit 0e5ba65

Please sign in to comment.