[cmake] Do not vendor 2 lzma versions, but download one single source tarball#21423
[cmake] Do not vendor 2 lzma versions, but download one single source tarball#21423dpiparo wants to merge 1 commit intoroot-project:masterfrom
Conversation
Test Results 22 files 22 suites 3d 6h 27m 34s ⏱️ Results for commit 4449de4. ♻️ This comment has been updated with latest results. |
ef735a9 to
cf211b6
Compare
cf211b6 to
4449de4
Compare
| set(LIBLZMA_CXXFLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${LIBLZMA_CXXFLAGS}") | ||
| set(LIBLZMA_CXXFLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${LIBLZMA_CXXFLAGS}") |
There was a problem hiding this comment.
We are composing here the default build flags for a given configuration of LIBLZMA out of the the default CXXFLAGS from ROOT and flags related to warnings or headers, which are build type independent. These should be better passed via CMAKE_CXX_FLAGS, and not CXX_BUILD_FLAGS_<config>. Because in the end, CMake will concatenate both anyway during the liblzma configuration.
| -DCMAKE_CXX_FLAGS_RELEASE=${LIBLZMA_CXXFLAGS_RELEASE} | ||
| -DCMAKE_CXX_FLAGS_DEBUG=${LIBLZMA_CXXFLAGS_RELEASE} | ||
| BUILD_COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG> --target liblzma | ||
| INSTALL_COMMAND ${CMAKE_COMMAND} --install . --config $<CONFIG> --component liblzma_Development |
There was a problem hiding this comment.
Different from MSVC, Ninja and Make are single-configuration generators, so the --config $<CONFIG> will not have no effect and is ignored. So the configuration (like Release, Debug, RelWithDebInfo) is not forwarded unless you use MSVC, which makes this code a bit misleading, considering also the DCMAKE_CXX_FLAGS_<config> flags above. I would rather put the --config $<CONFIG> in an extra-
| -DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${LIBLZMA_CXXFLAGS_RELWITHDEBINFO} | ||
| -DCMAKE_CXX_FLAGS_RELEASE=${LIBLZMA_CXXFLAGS_RELEASE} | ||
| -DCMAKE_CXX_FLAGS_DEBUG=${LIBLZMA_CXXFLAGS_RELEASE} |
There was a problem hiding this comment.
Forwarding these DCMAKE_CXX_FLAGS_<config> flags is unnecessary on Linux/macOS. We are not messing with these CMake variables to begin with, it only happens on Windows: https://github.com/dpiparo/root/blob/master/cmake/modules/SetUpWindows.cmake#L48
There was a problem hiding this comment.
Thank you very much! I think the code is a bit misleading though, because it reads as if the CMake build type is intended to be forwarded for all generators, but it only happened for Windows before. Also, it mixes configuration-type-depended CXX flags with other CXX flags. It's worth to clean this up a little to make the intent clearer. I'll make another PR showing what I mean, that should be the easiest way to understand it.
Also, the previous code on Linux/macOS changes the C flags and not the C++ flags, so there is a change in behavior now (losing the -O3 on the C-side of lzma might cause performance regressions).
|
Let me just comment here what I think would be a slightly more backwards compatible change: if(builtin_lzma)
set(lzma_version 5.8.2)
set(LZMA_TARGET LZMA)
message(STATUS "Downloading and building LZMA version ${lzma_version}")
set(LIBLZMA_LIBRARIES ${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}lzma${CMAKE_STATIC_LIBRARY_SUFFIX})
if(MSVC)
# In the MSVC case, we forward the default C++ configuration flags because
# they are changed by ROOT in SetUpWindows.cmake.
set(lzma_extra_cmake_args
-DCMAKE_CXXFLAGS_RELWITHDEBINFO="${CMAKE_CXX_FLAGS_RELWITHDEBINFO}"
-DCMAKE_CXXFLAGS_RELEASE="${CMAKE_CXX_FLAGS_RELEASE}"
-DCMAKE_CXXFLAGS_DEBUG="${CMAKE_CXX_FLAGS_DEBUG}")
else()
# In the Linux/macOS case, we forward the compilers and set unconditional
# flags for maximum optimization and suppression of warnings.
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(liblzma_flags "-Wno-format-nonliteral")
endif()
if(CMAKE_OSX_SYSROOT)
set(liblzma_flags "${liblzma_flags} -isysroot ${CMAKE_OSX_SYSROOT}")
endif()
set(liblzma_flags "${liblzma_flags} -O3")
set(lzma_extra_cmake_args
-DCMAKE_C_FLAGS="${liblzma_flags}"
-DCMAKE_C_COMPILER="${CMAKE_C_COMPILER}"
-DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}")
endif()
ExternalProject_Add(
LZMA
URL https://root.cern/download/xz-${lzma_version}.tar.gz
URL_HASH SHA256=f21fdf2c1ee004de30ca40377a273e3369186e6b7ab7b50a410eaa2e2bbefafb
INSTALL_DIR ${CMAKE_BINARY_DIR}
CMAKE_ARGS -G ${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
${lzma_extra_cmake_args}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG> --target liblzma
INSTALL_COMMAND ${CMAKE_COMMAND} --install . --config $<CONFIG> --component liblzma_Development
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${LIBLZMA_LIBRARIES}
TIMEOUT 600
)
set(LIBLZMA_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include)
add_library(LibLZMA STATIC IMPORTED GLOBAL)
add_library(LibLZMA::LibLZMA ALIAS LibLZMA)
target_include_directories(LibLZMA INTERFACE ${LIBLZMA_INCLUDE_DIR})
set_target_properties(LibLZMA PROPERTIES IMPORTED_LOCATION ${LIBLZMA_LIBRARIES})
endif() |
| --with-pic --disable-shared --quiet | ||
| --disable-scripts --disable-xz --disable-xzdec --disable-lzmadec --disable-lzmainfo --disable-lzma-links |
There was a problem hiding this comment.
Do all of these options have CMake equivalents? They were probably introduced for a reason, I think we need to keep them (unless looked into it in detail and we concluded they are not necessary).
There was a problem hiding this comment.
For windows, we never cared.
This PR updates the two vendored lzma versions to v5.8.2 downloading sources from the official GitHub repo.
For the moment, this is a test, to check whether the approach works for ROOT.