Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost FetchContent Extraction Fails on Windows with tar.gz Archive #60

Closed
nobShinjo opened this issue Dec 2, 2024 · 0 comments
Closed

Comments

@nobShinjo
Copy link
Contributor

nobShinjo commented Dec 2, 2024

Description

When using CMake to build a project with Boost as a dependency via FetchContent, the extraction of the tar.gz archive fails on Windows. This issue appears to be related to Windows handling of empty pathnames in tar archives. Switching to the zip archive resolves the issue.

Steps to Reproduce

  1. Use the following FetchContent_Declare in a CMake project:

    cmake\boost.cmake

    FetchContent_Declare(
        boost
        URL https://github.com/boostorg/boost/releases/download/boost-1.81.0/boost-1.81.0.tar.gz
        URL_HASH MD5=ffac94fbdd92d6bc70a897052022eeba
    )
    FetchContent_MakeAvailable(boost)
  2. Run CMake configuration on a Windows system

    cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DOPENVDB_CORE_SHARED=OFF -DTBB_TEST=OFF -DCMAKE_CXX_FLAGS="/MT /EHsc" 
  3. Observe the extraction error.

Observed Behavior

CMake fails during the extraction step with the following error:

 -- extracting...
       src='C:/***/CoACD/build/_deps/boost-subbuild/boost-populate-prefix/src/boost-1.81.0.tar.gz'     
       dst='C:/***/CoACD/build/_deps/boost-src'
  -- extracting... [tar xfz]
CUSTOMBUILD : CMake error : Problem with archive_write_header(): Invalid empty pathname [C:\***\CoACD\build\_deps\boost-subbuild\boost-populate.vcxproj]
  -- extracting... [error clean up]
CUSTOMBUILD : CMake error : Current file: [C:\***\CoACD\build\_deps\boost-subbuild\boost-populate.vcxproj]
CUSTOMBUILD : CMake error : Problem extracting tar: C:/***/CoACD/build/_deps/boost-subbuild/boost-populate-prefix/src/boost-1.81.0.tar.gz

.
.
.
CMake Error at C:/Program Files/CMake/share/cmake-3.31/Modules/FetchContent.cmake:1918 (message):
  Build step for boost failed: 1
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.31/Modules/FetchContent.cmake:1609 (__FetchContent_populateSubbuild)
  C:/Program Files/CMake/share/cmake-3.31/Modules/FetchContent.cmake:2145:EVAL:2 (__FetchContent_doPopulation)
  C:/Program Files/CMake/share/cmake-3.31/Modules/FetchContent.cmake:2145 (cmake_language)
  C:/Program Files/CMake/share/cmake-3.31/Modules/FetchContent.cmake:2384 (__FetchContent_Populate)
  cmake/boost.cmake:24 (FetchContent_MakeAvailable)
  CMakeLists.txt:38 (include)


-- Configuring incomplete, errors occurred!

Expected Behavior

The tar.gz archive should extract without issues.

Workaround

Switching to the zip archive of Boost resolves the problem:

FetchContent_Declare(
    boost
    URL https://github.com/boostorg/boost/releases/download/boost-1.81.0/boost-1.81.0.zip
    URL_HASH MD5=375693214b89309d2003f5296422c0a8
)
FetchContent_MakeAvailable(boost)

Environment

  • Building for: Visual Studio 17 2022
  • OS: Windows 11 Pro 23H2
  • Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
  • CMake Version: 3.31
  • Compiler: MSVC 19.42.34435.0
  • Boost Version: 1.81.0

Additional Notes

This issue seems specific to the tar.gz archive format on Windows. Similar setups on Linux and macOS work correctly with the same tar.gz archive. A potential solution could be to provide platform-specific recommendations for the archive format or improve the handling of tar archives in CMake.

nobShinjo added a commit to nobShinjo/CoACD that referenced this issue Dec 2, 2024
- Updated FetchContent_Declare to use platform-specific archive formats.
- On Windows, switched to the zip archive to avoid extraction errors caused by empty pathnames in tar.gz files.
- For non-Windows platforms, the tar.gz archive remains the default.
- Ensures compatibility and smooth extraction across all platforms.
Related Issue: SarahWeiii#60
SarahWeiii pushed a commit that referenced this issue Jan 2, 2025
- Updated FetchContent_Declare to use platform-specific archive formats.
- On Windows, switched to the zip archive to avoid extraction errors caused by empty pathnames in tar.gz files.
- For non-Windows platforms, the tar.gz archive remains the default.
- Ensures compatibility and smooth extraction across all platforms.
Related Issue: #60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant