CMake: fix MSVC static library flags for Windows ARM64#218
CMake: fix MSVC static library flags for Windows ARM64#218ajelenak merged 1 commit intoHDFGroup:masterfrom
Conversation
BLOSC/config/zlib-CMakeLists.txt
Outdated
| add_library(zlibstat STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) | ||
| if (MSVC AND CMAKE_CL_64) | ||
| set_target_properties (zlibstat PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64") | ||
| if (MSVC) |
There was a problem hiding this comment.
Rather than just removing the checking of CMAKE_CL_64, it looks like the logic should be checking CMAKE_SIZEOF_VOID_P in this case
BLOSC/config/zlib-CMakeLists.txt
Outdated
| if (MSVC AND CMAKE_CL_64) | ||
| set_target_properties (zlibstat PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64") | ||
| if (MSVC) | ||
| if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(AMD64|x86_64)$") |
There was a problem hiding this comment.
Based on https://gitlab.kitware.com/cmake/cmake/-/issues/25466 and https://gitlab.kitware.com/cmake/cmake/-/issues/15170, it seems like using CMAKE_SYSTEM_PROCESSOR here may also not give the expected results.
There was a problem hiding this comment.
Thanks for the feedback. Based on the discussion in CMake Issue #15170, CMAKE_C_COMPILER_ARCHITECTURE_ID is suggested as the reliable alternative for Windows since it's set after the compiler probe.
I have updated the PR to use this variable along with the CMAKE_SIZEOF_VOID_P check. Could you please review the changes.
This PR fixes MSVC static library build issues on Windows ARM64.
Currently, the build forces
/machine:x64, which causes linker failures when compiling HDF5 natively on ARM64.Changes
Select /machine flag based on target architecture:
Important
Fixes MSVC static library build issue on Windows ARM64 by selecting appropriate
/machineflag based on architecture inzlib-CMakeLists.txtand LZFCMakeLists.txt./machineflag based on target architecture inzlib-CMakeLists.txtandCMakeLists.txtfor LZF./machine:x64for x64 and/machine:ARM64for ARM64.zlib-CMakeLists.txt: Adjustsset_target_propertiesforzlibstat.CMakeLists.txtfor LZF: Adjustsset_target_propertiesfor${LZF_LIB_TARGET}.This description was created by
for f9ce6b6. You can customize this summary. It will automatically update as commits are pushed.