Build error: Policy CMP0167 is not set: The FindBoost module is removed.
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 30.5k
- Forks
- 5.9k
- PR merge metrics
- No merged PRs in 30d
Description
I have been trying to use folly, I have folly, boost and all other deps installed via homebrew, see versions below
==> folly: stable 2025.04.14.00 (bottled), HEAD
==> boost: stable 1.88.0 (bottled), HEAD
==> glog: stable 0.6.0 (bottled), HEAD
==> fmt: stable 11.1.4 (bottled), HEAD
==> double-conversion: stable 3.3.1 (bottled), HEAD
==> gflags: stable 2.2.2 (bottled)
My Cmakelists.txt file
cmake_minimum_required(VERSION 3.10)
project(cppmove)
set(CMAKE_CXX_STANDARD 20)
# --- Global CMake Settings ---
# Hint CMake where to find packages installed by Homebrew
list(APPEND CMAKE_PREFIX_PATH "/opt/homebrew")
# Explicitly prefer config files (PackageConfig.cmake) over find modules (FindPackage.cmake)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
message(STATUS "CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}")
message(STATUS "CMAKE_FIND_PACKAGE_PREFER_CONFIG set to: ${CMAKE_FIND_PACKAGE_PREFER_CONFIG}")
message(STATUS "CMAKE_ROOT set to: ${CMAKE_ROOT}")
# --- Find Boost FIRST using CONFIG mode ---
message(STATUS "Attempting to find Boost package (preferring CONFIG mode)...")
find_package(Boost CONFIG REQUIRED) # Still use CONFIG explicitly here
if(Boost_FOUND)
message(STATUS "Boost package found.")
if(DEFINED Boost_DIR)
message(STATUS "Boost config directory (Boost_DIR): ${Boost_DIR}")
else()
message(WARNING "Boost_DIR variable is not defined after find_package.")
endif()
if(TARGET Boost::boost)
message(STATUS "Found Boost::boost target.")
else()
message(WARNING "Could not find Boost::boost target. Check Boost installation/components.")
endif()
else()
message(FATAL_ERROR "Boost package was not found by find_package.")
endif()
# List available targets *before* find_package(folly)
get_property(targets_before DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
message(STATUS "Available targets before find_package(folly): ${targets_before}")
# --- Find Folly ---
message(STATUS "Attempting to find Folly package (preferring CONFIG mode)...")
# Hopefully, Folly's find_dependency will now respect the already found Boost config
find_package(folly CONFIG REQUIRED)
# Check if Folly was found and where its config file is
if(folly_FOUND)
message(STATUS "Folly package found.")
if(DEFINED folly_DIR)
message(STATUS "Folly config directory (folly_DIR): ${folly_DIR}")
else()
message(WARNING "folly_DIR variable is not defined after find_package.")
endif()
else()
message(FATAL_ERROR "Folly package was not found by find_package.")
endif()
# Check if the folly::folly target was created
if(TARGET folly::folly)
message(STATUS "Found folly::folly target.")
else()
message(WARNING "Could not find folly::folly target after find_package. This suggests an issue within Folly's CMake configuration scripts.")
endif()
# List available targets *after* find_package(folly)
get_property(targets_after DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
message(STATUS "Available targets after find_package(folly): ${targets_after}")
add_executable(cppmove main.cpp)
# Link Folly and Boost
target_link_libraries(cppmove PRIVATE folly::folly Boost::boost)
Build logs:
/Applications/CLion.app/Contents/bin/cmake/mac/aarch64/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja -G Ninja -S /Users/jayshah/Documents/programming/cppwork/learningprojs/cppmove -B /Users/jayshah/Documents/programming/cppwork/learningprojs/cppmove/cmake-build-debug
-- The C compiler identification is AppleClang 16.0.0.16000026
-- The CXX compiler identification is AppleClang 16.0.0.16000026
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/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: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_PREFIX_PATH set to: /opt/homebrew
-- CMAKE_FIND_PACKAGE_PREFER_CONFIG set to: TRUE
-- CMAKE_ROOT set to: /Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.31
-- Attempting to find Boost package (preferring CONFIG mode)...
-- Boost package found.
-- Boost config directory (Boost_DIR): /opt/homebrew/lib/cmake/Boost-1.88.0
-- Found Boost::boost target.
-- Available targets before find_package(folly):
-- Attempting to find Folly package (preferring CONFIG mode)...
CMake Warning (dev) at /Applications/CLion.app/Contents/bin/cmake/mac/aarch64/share/cmake-3.31/Modules/CMakeFindDependencyMacro.cmake:76 (find_package):
Policy CMP0167 is not set: The FindBoost module is removed. Run "cmake
--help-policy CMP0167" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
Call Stack (most recent call first):
/opt/homebrew/lib/cmake/folly/folly-config.cmake:59 (find_dependency)
CMakeLists.txt:43 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found Boost: /opt/homebrew/lib/cmake/Boost-1.88.0/BoostConfig.cmake (found suitable version "1.88.0", minimum required is "1.51.0") found components: context filesystem program_options regex system thread
-- Found folly: /opt/homebrew
-- Folly package found.
-- Folly config directory (folly_DIR): /opt/homebrew/lib/cmake/folly
CMake Warning at CMakeLists.txt:61 (message):
Could not find folly::folly target after find_package. This suggests an
issue within Folly's CMake configuration scripts.
-- Available targets after find_package(folly):
-- Configuring done (0.8s)
CMake Error at CMakeLists.txt:74 (target_link_libraries):
Target "cppmove" links to:
folly::folly
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
CMake Error:
Running
'/Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja' '-C' '/Users/jayshah/Documents/programming/cppwork/learningprojs/cppmove/cmake-build-debug' '-t' 'recompact'
failed with:
ninja: error: build.ninja:35: loading 'CMakeFiles/rules.ninja': No such file or directory
include CMakeFiles/rules.ninja
^ near here
-- Generating done (0.0s)
CMake Generate step failed. Build files cannot be regenerated correctly.
[Finished]
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.
Research direction
Start by rerunning the CMake configure command from the issue with the shown CMakeLists.txt and inspect /opt/homebrew/lib/cmake/folly/folly-config.cmake, especially its find_dependency call. Compare the imported targets exposed by the Folly package with the requested folly::folly target; done means the project configures and generates successfully with the documented Folly target.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100