Finding Boost resets Boost CMAKE vars
@PhoebeHui is already working on this.
Since Apr 9, 2021.
- Dominant language
- CMake
- Stars
- 27.5k
- Forks
- 7.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 321
Description
**Is your feature request related to a problem? Please describe.**
I am using a project which depends upon Boost. It is able to use Boost either as a shared library or statically linked - it refers to the `Boost_USE_STATIC_LIBS` CMAKE variable to determine which. The problem is that with users using vcpkg, it will reset the values of Boost-related CMAKE vars during `find_package` due to the follow lines; https://github.com/microsoft/vcpkg/blob/fe2a6bb789e904520797ec229272c6c1a42e7e38/scripts/buildsystems/vcpkg.cmake#L818
This causes problems in cases where the user wants to statically link Boost. They would set their vcpkg triplet to `x64-windows-static` and `Boost_USE_STATIC_LIBS` to `ON`. Problems occur later in the build config script since vcpkg has located static libraries but also reset `Boost_USE_STATIC_LIBS` to `OFF`.
**Proposed solution**
`find_package` for Boost does not reset the state of Boost-related CMAKE vars if they are already defined, or at least makes them represent the types of library found.
**Describe alternatives you've considered**
Currently working around it by using this (i.e, storing and restoring the state of `Boost_USE_STATIC_LIBS`);
```
set(_Boost_USE_STATIC_LIBS ${Boost_USE_STATIC_LIBS})
find_package( Boost ${REQ_BOOST_MINIMUM_VERSION} REQUIRED COMPONENTS ${REQ_BOOST_LIBRARIES} )
set(Boost_USE_STATIC_LIBS ${_Boost_USE_STATIC_LIBS})
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.