Open Werni2A opened 1 year ago
shouldn't boost-iostream know about it's own dependencies and pull them in?
The port does correctly pull bzip2
and zlib
dependencies, so you don't have to add them to your vcpkg.json
.
The problem is that you link statically and CMake's FindBoost.cmake
does not call find_package(BZip2)
for you (and it probably just doesn't know whether boost-iostream was build with bzip2 support or not).
I see. In the command line output there are a few lines that show how to include the library into my CMake project. For Boost it's:
The package boost is compatible with built-in CMake targets:
find_package(Boost REQUIRED [COMPONENTS <libs>...])
target_link_libraries(main PRIVATE Boost::boost Boost::<lib1> Boost::<lib2> ...)
Maybe it's possible to check if boost-iostreams
was specified as component and extend the output with the include directives for it's dependencies.
The package boost is compatible with built-in CMake targets:
find_package(Boost REQUIRED [COMPONENTS <libs>...])
target_link_libraries(main PRIVATE Boost::boost Boost::<lib1> Boost::<lib2> ...)
Note that `boost-iostream` requires one of or a combination of the targets [bzip2, lzma, zlib, zstd].
The package zstd provides CMake targets:
find_package(zstd CONFIG REQUIRED)
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>)
The package zlib is compatible with built-in CMake targets:
find_package(ZLIB REQUIRED)
target_link_libraries(main PRIVATE ZLIB::ZLIB)
liblzma is compatible with built-in CMake targets:
find_package(LibLZMA REQUIRED)
target_link_libraries(main PRIVATE LibLZMA::LibLZMA)
liblzma provides CMake targets:
find_package(liblzma CONFIG REQUIRED)
target_link_libraries(main PRIVATE liblzma::liblzma)
The package bzip2 is compatible with built-in CMake targets:
find_package(BZip2 REQUIRED)
target_link_libraries(main PRIVATE BZip2::BZip2)
Just an idea. Feel free to close this issue.
extend the output with the include directives for it's dependencies.
No, the user should not need to do anything else. This must be handled with patches and/or wrappers.
No, the user should not need to do anything else. This must be handled with patches and/or wrappers.
IMO this is an upstream issue and must be reported in CMake repo first.
@Werni2A, thanks for posting this issue, I followed your steps to reproduce and building boost-iostreams also failed, but I got a different error than yours:
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR iostreams)
Call Stack (most recent call first):
vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/share/cmake-3.25/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
vcpkg/scripts/buildsystems/vcpkg.cmake:855 (_find_package)
CMakeLists.txt:8 (find_package)
-- Configuring incomplete, errors occurred!
@JonLiu1993 I tried again with the latest vcpkg version and the attached reproducer where I get the same error report as mentioned above. I have no idea why CMake behaves differently in you case. Our application versions seem pretty much the same:
$ gcc --version
gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
$ cmake --version
cmake version 3.25.1
$ vcpkg --version
vcpkg package management program version 2023-06-22-f19f3d9939100085fe2f7e41502d60b08e2083b6
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
@Werni2A, thanks for the double confirmation, I git cloned a new vcpkg and following your steps I successfully built boost-iostreams:
test@test001:~/build$ /home/test/vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/bin/cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/test/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DVCPKG_BUILD_TYPE=debug
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: iostreams
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
VCPKG_BUILD_TYPE
-- Build files have been written to: /home/test/build
test@test001:~/build$ ls
CMakeCache.txt CMakeFiles Makefile cmake_install.cmake
test@test001:~/build$ /home/test/vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/bin/cmake --build .
[ 50%] Building CXX object CMakeFiles/reproducer.dir/main.cpp.o
[100%] Linking CXX executable reproducer
[100%] Built target reproducer
The port does correctly pull the bzip2
and zlib
dependencies.
thanks for the double confirmation, I git cloned a new vcpkg and following your steps I successfully built boost-iostreams
-DVCPKG_TARGET_TRIPLET=x64-windows -DVCPKG_BUILD_TYPE=debug
Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake
What exactly did you do? o_O
@JonLiu1993 thanks for trying to reproduce. I'm not sure how you got it working with the -DVCPKG_TARGET_TRIPLET=x64-windows
flag. On my Linux machine this fails with error: in triplet x64-windows: Use of Visual Studio's Developer Prompt is unsupported on non-Windows hosts.
. Probably you use WSL? Anyway I can't test on Windows or WSL, could therefore be a Linux only issue.
@Osyotr @Werni2A , Full steps to reproduce are here:
test@test001:~$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(reproducer)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Boost COMPONENTS iostreams REQUIRED)
add_executable(reproducer main.cpp)
target_include_directories(reproducer PRIVATE
${Boost_INCLUDE_DIRS}
)
target_link_libraries(reproducer PRIVATE
Boost::boost
Boost::iostreams
)
test@test001:~$ cat main.cpp
#include <boost/iostreams/filter/bzip2.hpp>
int main()
{
boost::iostreams::bzip2_decompressor();
return 0;
}
test@test001:~$ cat vcpkg/vcpkg.json
{
"name": "reproducer",
"version": "0.0.1",
"dependencies": [
"boost-iostreams"
],
"builtin-baseline": "64adda19c86e89526b5e27703a193c14477cce07"
}
test@test001:~$ cd vcpkg/
test@test001:~/vcpkg$ ./vcpkg install
Detecting compiler hash for triplet x64-linux...
All requested packages are currently installed.
Total install time: 600 ns
The package boost is compatible with built-in CMake targets:
find_package(Boost REQUIRED [COMPONENTS <libs>...])
target_link_libraries(main PRIVATE Boost::boost Boost::<lib1> Boost::<lib2> ...)
test@test001:~/vcpkg$ cd ../build/
test@test001:~/build$ /home/test/vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/bin/cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/test/vcpkg/scripts/buildsystems/vcpkg.cmake
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: iostreams
-- Configuring done
-- Generating done
-- Build files have been written to: /home/test/build
test@test001:~/build$ /home/test/vcpkg/downloads/tools/cmake-3.25.1-linux/cmake-3.25.1-linux-x86_64/bin/cmake --build .
[ 50%] Building CXX object CMakeFiles/reproducer.dir/main.cpp.o
[100%] Linking CXX executable reproducer
[100%] Built target reproducer
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0") found components: iostreams
Still not finding vcpkg boost.
This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.
This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.
Can it be reproduced now when vcpkg builds boost with CMake?
Can it be reproduced now when vcpkg builds boost with CMake?
This error can still be reproduced:
test@docker:~/Jon$ ./build.sh
-- Running vcpkg install
-- Running vcpkg install - done
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /usr/share/cmake-3.16/Modules/FindBoost.cmake:1161 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindBoost.cmake:1283 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.16/Modules/FindBoost.cmake:1921 (_Boost_MISSING_DEPENDENCIES)
build/vcpkg_installed/x64-linux/share/boost/vcpkg-cmake-wrapper.cmake:11 (_find_package)
vcpkg/scripts/buildsystems/vcpkg.cmake:813 (include)
CMakeLists.txt:8 (find_package)
CMake Warning at /usr/share/cmake-3.16/Modules/FindBoost.cmake:1161 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindBoost.cmake:1283 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.16/Modules/FindBoost.cmake:1921 (_Boost_MISSING_DEPENDENCIES)
build/vcpkg_installed/x64-linux/share/boost/vcpkg-cmake-wrapper.cmake:11 (_find_package)
vcpkg/scripts/buildsystems/vcpkg.cmake:813 (include)
CMakeLists.txt:8 (find_package)
-- Found Boost: /home/test/Jon/build/vcpkg_installed/x64-linux/include (found version "1.82.0") found components: iostreams regex
-- Configuring done
-- Generating done
-- Build files have been written to: /home/test/Jon/build
Scanning dependencies of target reproducer
[ 50%] Building CXX object CMakeFiles/reproducer.dir/main.cpp.o
[100%] Linking CXX executable reproducer
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::do_init(bool, void* (*)(void*, int, int), void (*)(void*, void*), void*)':
/home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:156: undefined reference to `BZ2_bzCompressInit'
/usr/bin/ld: /home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:160: undefined reference to `BZ2_bzDecompressInit'
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::end(bool, std::nothrow_t)':
/home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:119: undefined reference to `BZ2_bzCompressEnd'
/usr/bin/ld: /home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:119: undefined reference to `BZ2_bzDecompressEnd'
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::compress(int)':
/home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:131: undefined reference to `BZ2_bzCompress'
/usr/bin/ld: vcpkg_installed/x64-linux/lib/libboost_iostreams.a(bzip2.o): in function `boost::iostreams::detail::bzip2_base::decompress()':
/home/test/Jon/vcpkg/buildtrees/boost-iostreams/src/ost-1.82.0-b7275d973f.clean/build/../src/bzip2.cpp:136: undefined reference to `BZ2_bzDecompress'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/reproducer.dir/build.make:86: reproducer] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/reproducer.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
This error can still be reproduced
Try with boost's cmake config. It does have required add_dependency
and target_link_libraries
calls.
Operating system
Linux
Compiler
GCC
Steps to reproduce the behavior
Failure logs
reproducer.zip
Additional context
Probably a variant/regression of https://github.com/microsoft/vcpkg/issues/22817
Duplicate of https://github.com/microsoft/vcpkg/issues/27938, there it's mentioned that I need to install the
bzip2
and/orzlib
dependencies. Adding them tovcpkg.json
and adding them toCMakeLists.txt
solves my issue but shouldn'tboost-iostream
know about it's own dependencies and pull them in?