简体   繁体   English

为什么我可以在本地使用 CMake 提供的模块(特别是 CMakeDependentOption.cmake),而不是在 CI 或 Docker 上?

[英]Why can I use CMake supplied modules (CMakeDependentOption.cmake specifically) locally, but not on CI or Docker?

I have a cmake project that successfully builds locally but errors with我有一个在本地成功构建的 cmake 项目,但出现错误

  include could not find load file:

    CmakeDependentOption

when trying to build on a CI platform or in Docker.尝试在 CI 平台或 Docker 中构建时。 Note that CMakeDependentOption.cmake is a script that comes with cmake itself.请注意, CMakeDependentOption.cmake 是 cmake 本身附带的脚本。 So it should just be available.所以它应该是可用的。 On CI to install cmake, I wget the relevant cmake release from their downloads page, unzip it and add the bin directory to the PATH environment variable.在CI安装cmake的,我wget相关CMake的版本从他们的下载页面,将它解压缩,并添加bin目录到PATH环境变量。 Then I use the cmake command to build my library.然后我使用cmake命令来构建我的库。 The result is the above error.结果就是上面的错误。

I suspect this means that a CMake variable (such as "CMAKE_MODULE_PATH" but not, since this variable seems to be empty at the start of the cmake script) is messed up or not set somehow.我怀疑这意味着 CMake 变量(例如“CMAKE_MODULE_PATH”但不是,因为这个变量在 cmake 脚本开始时似乎是空的)被搞砸了或没有以某种方式设置。 The path to the correct file to include isinclude的正确文件的路径是

<cmake_root>/share/cmake-3.18/Modules/CMakeDependentOption.cmake

And I have verified that it exists manually.我已经验证它手动存在。 My question: is there a way to locate this directory from within cmake?我的问题:有没有办法从 cmake 中找到这个目录? Perhaps a cmake --config or cmake --libs mode (a bit like pkg-config?)也许是cmake --configcmake --libs模式(有点像 pkg-config?)

Failing that, does anybody have any suggestions as to why this is happening and how to get around it.如果做不到这一点,是否有人对为什么会发生这种情况以及如何解决它有任何建议。

You can locally because most likely you don't use a linux based platform, like windows or mac.您可以在本地使用,因为您很可能不使用基于 linux 的平台,例如 windows 或 mac。 This is because linux filesystem are case sensitive.这是因为 linux 文件系统区分大小写。 Which means CmakeDependentOption is different from CMakeDependentOption .这意味着CmakeDependentOptionCMakeDependentOption不同。

Docker runs containers in linux, so filenames are gonna be case sensitive, and the include is going to fail if the cases are different. Docker 在 linux 中运行容器,因此文件名将区分大小写,如果大小写不同,则包含将失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM