Skip to content

find_package Ignoring Boost_ROOT Due to Unset CMP0074 Policy #1107

@ugurmelihsurme

Description

@ugurmelihsurme

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions