CMake目标平台为iOS时find_package查找Boost失败的问题求助
CMake 3.30.2 iOS平台下FindBoost无法识别指定路径问题
使用CMake 3.30.2时,将目标平台指定为iOS后,FindBoost无法正常工作,OpenCV也存在同样问题,推测二者根源一致,故以Boost为例说明。
错误示例
Could not find a package configuration file provided by "Boost" (requested version 1.84.0) with any of the following names: BoostConfig.cmake boost-config.cmake
背景说明
我为多个平台(包括macOS)及ABI构建了结构完全一致的Boost库,所有必要文件均存在,其他平台使用相同的find_package命令均可正常找到Boost。
使用的find_package命令
find_package(Boost ${BOOST_VERSION} EXACT REQUIRED CONFIG COMPONENTS log program_options json PATHS ${BOOST_LIB_DIR}/cmake )
其中BOOST_LIB_DIR指向对应目标平台的Boost库目录。
Boost根目录结构
boost-<version> include/ ... <os>/<abi>/lib cmake/ ...
调试追踪信息
按照建议使用--debug-find后发现,CMake仅在SDK默认路径搜索,完全忽略了PATHS参数指定的路径:
Paths specified by the find_package PATHS option. <root dir>/boost-1.84.0/iOS/arm64/lib/cmake find_package considered the following locations for Boost's Config module: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/usr/BoostConfig.cmake /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/usr/boost-config.cmake /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/BoostConfig.cmake /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/boost-config.cmake /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/usr/BoostConfig.cmake /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/usr/boost-config.cmake /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/System/Library/Frameworks/BoostConfig.cmake /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/System/Library/Frameworks/boost-config.cmake /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/System/Library/Frameworks/BoostConfig.cmake /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.5.sdk/System/Library/Frameworks/boost-config.cmake The file was not found.
即使添加NO_DEFAULT_PATH标志禁用默认目录搜索,CMake仍然无法识别PATHS指定的路径:
Paths specified by the find_package PATHS option. <root dir>/boost-1.84.0/iOS/arm64/lib/cmake find_package considered the following locations for Boost's Config module: The file was not found.
请问这可能是什么问题?
内容的提问来源于stack exchange,提问作者thomas_f
相关产品推荐
相关产品推荐

