cmake config_error ai_generated true

CMake错误:导入的目标'Boost::filesystem'包含不存在的路径'/usr/local/include/boost_1_82'

CMake Error: Imported target 'Boost::filesystem' includes non-existent path '/usr/local/include/boost_1_82'

ID: cmake/imported-target-missing-interface-include-dirs

其他格式: JSON · Markdown 中文 · English
85%修复率
88%置信度
1证据数
2023-09-20首次发现

版本兼容性

版本状态引入弃用备注
CMake 3.26 active
CMake 3.27 active
Boost 1.82 active
Boost 1.84 active

根因分析

导入目标的INTERFACE_INCLUDE_DIRECTORIES属性引用了不再存在的目录,通常是由于Boost安装被移动或删除。

English

An imported target's INTERFACE_INCLUDE_DIRECTORIES property references a directory that no longer exists, often due to a moved or removed Boost installation.

generic

官方文档

https://cmake.org/cmake/help/latest/command/add_library.html#imported-libraries

解决方案

  1. Delete CMakeCache.txt and rebuild from scratch to refresh imported target properties
  2. Set the missing path to an existing dummy directory using target_include_directories on the imported target
  3. Reinstall Boost to the original location or symlink the missing directory

无效尝试

常见但无效的做法:

  1. Manually delete the Boost CMake config files and reinstall 40% 失败

    The config files may be cached; deletion without clearing CMake cache leads to stale references.

  2. Set BOOST_ROOT to a new path without updating the imported target 60% 失败

    BOOST_ROOT only affects find_package; the imported target's properties are cached after first configuration.

  3. Use add_definitions(-DBOOST_ALL_NO_LIB) to bypass library checks 80% 失败

    This only disables auto-linking, not the include directory validation.