Skip to content

CMake Config files don't provide deprecated Module variables #134258

Open
@bebuch

Description

@bebuch

I try to build LLVM on Windows via MSVC with zlib-ng (in compatability mode), zstd and libxml2.

I have build these 3rdparty projects including there CMake Config files. I use a custom include install path. Therefor the old CMake Modules can't work for my build. I build LLVM with CMAKE_FIND_PACKAGE_PREFER_CONFIG=ON to used the installed project Config files.

I looks like LLVM uses some old style CMake variables including:

  • ZLIB_INCLUDE_DIR=C:/usr/include/zlib_ng
  • ZLIB_INCLUDE_DIRS=C:/usr/include/zlib_ng
  • ZLIB_LIBRARY (missing, ZLIB_LIBRARIES is ZLIB::ZLIB)
  • zstd_INCLUDE_DIR (missing)
  • zstd_LIBRARY (missing)
  • LIBXML2_INCLUDE_DIR=C:/usr/include/libxml2/libxml2
  • LIBXML2_INCLUDE_DIRS=C:/usr/include/libxml2/libxml2
  • LIBXML2_LIBRARY=debug;C:/usr/lib/libxml2d.lib;optimized;C:/usr/lib/libxml2.lib
  • LIBXML2_LIBRARIES=debug;C:/usr/lib/libxml2d.lib;optimized;C:/usr/lib/libxml2.lib
  • LIBXML2_DEFINITIONS=

As you can see zstd doesn't set any these old variables at all. They don't work with Multi-Config anyway.

Config files support Multi-Config, so *_LIBRARIES can't be set to the Debug or the Release lib file. zlib-ng sets it to ZLIB::ZLIB. libxml2 sets it to debug;C:/usr/lib/libxml2d.lib;optimized;C:/usr/lib/libxml2.lib. I think both isn't what LLVM expects.

Also the ZLIB check is broken, because ZLIB_LIBRARY is not set, ZLIB_LIBRARIES would work here.

if(LLVM_ENABLE_ZLIB)
if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON)
find_package(ZLIB REQUIRED)
elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
find_package(ZLIB)
endif()
if(ZLIB_FOUND)
# Check if zlib we found is usable; for example, we may have found a 32-bit
# library on a 64-bit system which would result in a link-time failure.
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARY})
check_symbol_exists(compress2 zlib.h HAVE_ZLIB)
cmake_pop_check_state()
if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON AND NOT HAVE_ZLIB)
message(FATAL_ERROR "Failed to configure zlib")
endif()
endif()
set(LLVM_ENABLE_ZLIB "${HAVE_ZLIB}")
else()
set(LLVM_ENABLE_ZLIB 0)
endif()

The next problematic section seams to be:

set(DEFAULT_PASSTHROUGH_VARIABLES
LibEdit_INCLUDE_DIRS
LibEdit_LIBRARIES
ZLIB_INCLUDE_DIR
ZLIB_LIBRARY
zstd_INCLUDE_DIR
zstd_LIBRARY
LIBXML2_LIBRARY
LIBXML2_INCLUDE_DIR
CURL_INCLUDE_DIR
CURL_LIBRARY
HTTPLIB_INCLUDE_DIR
HTTPLIB_HEADER_PATH
Python3_EXECUTABLE
Python3_LIBRARIES
Python3_INCLUDE_DIRS
Python3_RPATH
)
foreach(variable ${DEFAULT_PASSTHROUGH_VARIABLES})
get_property(is_value_set CACHE ${variable} PROPERTY VALUE SET)
if(${is_value_set})
get_property(value CACHE ${variable} PROPERTY VALUE)
list(APPEND CMAKE_CACHE_DEFAULT_ARGS "-D${variable}:STRING=${value}")
endif()
endforeach()

This looks to me, like a forwarding of arguments to a subsequent call.

I think this may be the reason for this error in my build:

loading initial cache file C:/TechnoTeam/develop/usr/build/llvm/projects/runtimes/tmp/runtimes-cache-Release.cmake
-- Performing bootstrapping runtimes build.
-- Could NOT find ZLIB (missing: ZLIB_INCLUDE_DIR)
-- Could NOT find zstd (missing: zstd_INCLUDE_DIR)
-- Could NOT find LibXml2 (missing: LIBXML2_INCLUDE_DIR)
-- Could NOT find ZLIB (missing: ZLIB_INCLUDE_DIR)
-- Could NOT find zstd (missing: zstd_INCLUDE_DIR)
-- Could NOT find LibXml2 (missing: LIBXML2_INCLUDE_DIR)
CMake Error at C:/temp/tt/env/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find Python3 (missing: Python3_EXECUTABLE Interpreter)
Call Stack (most recent call first):
  C:/temp/tt/env/share/cmake-3.31/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  C:/temp/tt/env/share/cmake-3.31/Modules/FindPython/Support.cmake:4002 (find_package_handle_standard_args)
  C:/temp/tt/env/share/cmake-3.31/Modules/FindPython3.cmake:602 (include)
  CMakeLists.txt:180 (find_package)

I am investigating this further and will add to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cmakeBuild system in general and CMake in particular

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions