Closed hwhsu1231 closed 1 year ago
Your step 1 only downloads the "boostorg/boost" repository, but not its submodules. You have to use git clone -b boost-1.79.0 --recurse-submodules https://github.com/boostorg/boost
instead.
In addition, step 5 needs to be cmake ..
instead of cmake ../cmake
.
@pdimov
I followed what you said to git clone
the repository, and then use CMake to compile the source code. It WORKED.
However, how do I use it with find_package()
command in CONFIG mode?
The followings are my example code of CMakeLists.txt
and the error messages:
CMakeLists.txt
Logs of configuring CMake project
I think the reason why find_package()
failed is because there didn't exist the boost-config.cmake
file.
Take Qt for reference. There is a C:/Qt/6.3.1/msvc2019_64/lib/cmake/Qt6/Qt6Config.cmake
. Therefore, we can use it with:
find_package(Qt6 CONFIG REQUIRED
COMPONENTS Core Widget Gui
)
Our CMake build does not have a master BoostConfig, so instead of find_package(Boost 1.79.0 CONFIG REQUIRED COMPONENTS filesystem regex asio)
you will need
find_package(boost_filesystem 1.79.0 CONFIG REQUIRED)
find_package(boost_regex 1.79.0 CONFIG REQUIRED)
find_package(boost_asio 1.79.0 CONFIG REQUIRED)
We may add support for find_package(Boost)
at some later date.
@pdimov
Moreover, after downloading and unzipping the boost_1_79_0.zip provided in the Download page, I found that there doesn't exist CMakeLists.txt
in the root directory. Does Boost official miss it?
We may add support for
find_package(Boost)
at some later date.
I hope this feature supported as soon as possible.
The Boost release archive has a slightly different layout - all headers from libs/<libname>/include/boost/
are moved into boost/
and deleted from their original location - so the CMake build doesn't support it, which is why we remove CMakeLists.txt from the release archive in order to not mislead people that it works.
Why not use the same layout?
For me, I prefer to download the zipped source codes of the specific version. Therefore, I hope that Boost can be compiled with CMake and be used with find_package()
in CONFIG mode, instead of MODULE mode.
We now provide CMake-compatible archives on Github: https://github.com/boostorg/boost/releases. Release 1.81 does not support find_package(Boost)
yet, but 1.82 will.
just for information:
BoostRoot.cmake
is in folder of tools/cmake
, after git submodule is initialized.
Descriptions
I tried to use CMake to compile the source codes. However, it failed with the following errors:
Therefore, I went to check the project folder, but didn't find
BoostRoot.cmake
.Besides, I found that all of folders inside the
tools
folder are EMPTY, too.What happened? What do I miss?
Steps of Installation
Click to expand
1. Download and unzip the source code. [boost-1.79.0.zip](https://github.com/boostorg/boost/archive/refs/tags/boost-1.79.0.zip) 2. Open Windows Terminal (`cmd.exe`) and change to the project folder. ``` cd boost-1.79.0 ``` 3. call `vcvarsall.bat x64` to preload the MSVC environment. ``` vcvarsall x64 ``` 4. Create the build folder and change into it. ``` md build-msvc16-x64 cd build-msvc16-x64 ``` 5. Configure the project with the generator `Ninja Multi-Config`. ``` cmake ../cmake -G"Ninja Multi-Config" ```Logs
Click to expand
```cmd C:\ccxxpkgs\source\boost-1.79.0>md build-msvc16-x64 C:\ccxxpkgs\source\boost-1.79.0>cd build-msvc16-x64 C:\ccxxpkgs\source\boost-1.79.0\build-msvc16-x64>vcvarsall x64 ********************************************************************** ** Visual Studio 2019 Developer Command Prompt v16.11.16 ** Copyright (c) 2021 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' C:\ccxxpkgs\source\boost-1.79.0\build-msvc16-x64>cmake .. -G"Ninja Multi-Config" -- The CXX compiler identification is MSVC 19.29.30145.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:20 (include): include could not find requested file: BoostRoot -- Configuring incomplete, errors occurred! See also "C:/ccxxpkgs/source/boost-1.79.0/build-msvc16-x64/CMakeFiles/CMakeOutput.log". ```Screenshots