Skip to content

Commit 0e5ba65

Browse files
committed
[cmake] Use CMAKE_CXX_SIMULATE_ID to distinguish MSVC ABI in Findzstd
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)).
1 parent 003686f commit 0e5ba65

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/cmake/modules/Findzstd.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# zstd::libzstd_shared
1111
# zstd::libzstd_static
1212

13-
if(WIN32)
13+
if(MSVC OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
1414
set(zstd_STATIC_LIBRARY_SUFFIX "_static\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
1515
else()
1616
set(zstd_STATIC_LIBRARY_SUFFIX "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
@@ -33,7 +33,7 @@ if(zstd_FOUND)
3333
set(zstd_STATIC_LIBRARY "${zstd_LIBRARY}")
3434
elseif (NOT TARGET zstd::libzstd_shared)
3535
add_library(zstd::libzstd_shared SHARED IMPORTED)
36-
if(WIN32)
36+
if(MSVC OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
3737
include(GNUInstallDirs) # For CMAKE_INSTALL_LIBDIR and friends.
3838
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library".
3939
get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY)

0 commit comments

Comments
 (0)