-
-
Notifications
You must be signed in to change notification settings - Fork 816
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
Fix find_package
failed problem for CMake projects on Android platform
#5147
Fix find_package
failed problem for CMake projects on Android platform
#5147
Conversation
e19da02
to
0d2d893
Compare
尽可能保持最小改动,避免 break 现有包的风险,如果没法规避部分小概率 case 下让 cmake 找到库,那么就直接走 patch 直接去干掉 cmakelists.txt 的 FindXXX 然后 目前 xmake-repo 里面一些包就是这么干的。。
即使这种方式有效,也不用全局加,风险太大,可以在遇到此类问题包的时候,在这个包的 on_install 里面,单独开启 CMAKE_FIND_PACKAGE_PREFER_CONFIG 先看看行不行,如果这种情况很少见,就直接包里面配置就行了。。如果后面遇到的多了。。并且测试下来 都没啥副作用,那么再挪到全局也就无所谓了 |
这边暂时先 merge 了,我不确定是否会有什么副作用,你们自己多测试吧 |
I'm merging here for the time being. I'm not sure if there will be any side effects. You can test it yourself. |
记得下回提 patch 时候,提到 dev 分支 |
Remember to mention the dev branch next time when you mention patch |
提交时没仔细看😱,不好意思 |
我记得本来就有这个参数的,config/module的控制 #2576 |
那是 |
I didn’t read it carefully when I submitted it, sorry. |
That is a parameter of the |
相关issue: #2037
NDK环境设置了
CMAKE_FIND_ROOT_PATH
/CMAKE_SYSROOT_PATH
, 会导致CMake工程在find_package
时因CMAKE_PREFIX_PATH
策略变更, 从而安装失败.先前相关修改处理了其它交叉编译的平台, 但未处理Android平台. 且遗漏了
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
但目前的改法仍未解决一个问题:
CMake的Module mode比Config mode优先级更高, 导致CMake官方提供了Module脚本的库:
(即
CMAKE_PREFIX_PATH
被忽略了)这我能想到的有两种方案:
考虑全局设置
CMAKE_FIND_PACKAGE_PREFER_CONFIG
为TRUE
, 但这样的话xrepo需要大规模测试设置
CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH
为FALSE
. 这会导致系统环境变量的工具无法被找到 (如make
,ninja
). 应该需要单独配置CMAKE_MAKE_PROGRAM
的路径