-
Notifications
You must be signed in to change notification settings - Fork 15k
Closed
Labels
cmakeBuild system in general and CMake in particularBuild system in general and CMake in particular
Description
When using find_package(llvm) on windows we get:
CMake Error at D:/bld/cppinterop_1709495262007/_h_env/Library/lib/cmake/llvm/Findzstd.cmake:39 (string):
2024-03-03T19:54:48.3232894Z string sub-command REGEX, mode REPLACE: regex "$" matched an empty string.
2024-03-03T19:54:48.3233394Z Call Stack (most recent call first):
2024-03-03T19:54:48.3233750Z D:/bld/cppinterop_1709495262007/_h_env/Library/lib/cmake/llvm/LLVMConfig.cmake:278 (find_package)
2024-03-03T19:54:48.3234068Z CMakeLists.txt:121 (find_package)
Our diagnosis is that find_package(LLVM REQUIRED CONFIG)
triggers LLVMConfig.cmake
to call find_package(zstd)
. In the MSVC branch we use string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}")
, however, CMAKE_INSTALL_LIBDIR
is not defined yet and we error out:
llvm-project/llvm/cmake/modules/Findzstd.cmake
Lines 36 to 47 in da5966e
if(MSVC) | |
# IMPORTED_LOCATION is the path to the DLL and IMPORTED_IMPLIB is the "library". | |
get_filename_component(zstd_DIRNAME "${zstd_LIBRARY}" DIRECTORY) | |
string(REGEX REPLACE "${CMAKE_INSTALL_LIBDIR}$" "${CMAKE_INSTALL_BINDIR}" zstd_DIRNAME "${zstd_DIRNAME}") | |
get_filename_component(zstd_BASENAME "${zstd_LIBRARY}" NAME) | |
string(REGEX REPLACE "\\${CMAKE_LINK_LIBRARY_SUFFIX}$" "${CMAKE_SHARED_LIBRARY_SUFFIX}" zstd_BASENAME "${zstd_BASENAME}") | |
set_target_properties(zstd::libzstd_shared PROPERTIES | |
INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}" | |
IMPORTED_LOCATION "${zstd_DIRNAME}/${zstd_BASENAME}" | |
IMPORTED_IMPLIB "${zstd_LIBRARY}") | |
unset(zstd_DIRNAME) | |
unset(zstd_BASENAME) |
Adding include(GNUInstallDirs)
which defines CMAKE_INSTALL_LIBDIR
in the calling cmake fixes the problem but it's difficult to debug and and far from optimal.
Full log is here: https://dev.azure.com/conda-forge/84710dde-1620-425b-80d0-4cf5baca359d/_apis/build/builds/888296/logs/24
Metadata
Metadata
Assignees
Labels
cmakeBuild system in general and CMake in particularBuild system in general and CMake in particular