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

find_package Ignoring Boost_ROOT Due to Unset CMP0074 Policy #1107

Open
ugurmelihsurme opened this issue Feb 19, 2024 · 0 comments
Open

find_package Ignoring Boost_ROOT Due to Unset CMP0074 Policy #1107

ugurmelihsurme opened this issue Feb 19, 2024 · 0 comments

Comments

@ugurmelihsurme
Copy link

ugurmelihsurme commented Feb 19, 2024

Description
When configuring a project with CMake that depends on msgpack-cxx version 6.1.0 and Boost, CMake generates a warning indicating that policy CMP0074 is not set. As a result, CMake ignores the Boost_ROOT environment variable, potentially leading to configuration issues if Boost is installed in a custom location.

Environment

CMake Version: 3.28
msgpack-cxx Version: 6.1.0
Boost Version: 1.84.0
Operating System: Windows 10 Version (10.0.19045 Build 19045)
Compiler: MSVC 19.29.30153.0

Warning Message
CMake Warning (dev) at CMakeLists.txt:80 (FIND_PACKAGE):
Policy CMP0074 is not set: find_package uses _ROOT variables.
Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

Environment variable Boost_ROOT is set to:
C:\Users\Administrator\Documents\Workspace\Projects\XXX-3rd-party\boost

For compatibility, CMake is ignoring the variable.

Steps to Reproduce
Please follow the guidelines for creating a minimal reproducible example as outlined here: https://stackoverflow.com/help/minimal-reproducible-example

Set the Boost_ROOT environment variable to point to a custom Boost installation path.
Configure a CMake project that depends on msgpack-cxx 6.1.0 and Boost using FIND_PACKAGE(Boost REQUIRED).
Observe the warning related to policy CMP0074.

Expected Behavior
CMake should use the Boost_ROOT environment variable as a hint to find the Boost installation, without generating warnings related to policy CMP0074.

Proposed Solution
To address this warning and ensure Boost_ROOT is considered during configuration, add the following line to your CMakeLists.txt file before the call to FIND_PACKAGE(Boost):

cmake_policy(SET CMP0074 NEW)

This policy setting instructs CMake to use the _ROOT variables as hints when searching for packages, thereby respecting the Boost_ROOT variable and potentially resolving configuration issues related to locating Boost.

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