CMake工具链包含多个文件 [英] CMake toolchain includes multiple files

查看:150
本文介绍了CMake工具链包含多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于无关的原因,我希望能够在工具链文件中包含多个文件。假设我的工具链包含以下内容:

For the reasons irrelevant to mention I would like to be able to include multiple files into toolchain file. Let's say my toolchain contains following:


message(STATUS "file1 is ok")
include(./build/file2)

文件2包含标识行:


message(STATUS "file2 is ok")

CMakeLists.txt包含:

the CMakeLists.txt contains:


cmake_minimum_required (VERSION 2.8.8)
project (pro)
message(STATUS "cmakelists.txt is ok")

I使用以下命令调用它:

I call it using following command:


cmake -DCMAKE_TOOLCHAIN_FILE=../../build/file1 ../../

现在,我希望得到以下输出:

Now, I would expect the following output:


-- file1 is ok
-- file2 is ok
-- cmakelists.txt is ok

我明白了:


-- file1 is ok
-- file2 is ok
-- file1 is ok
-- file2 is ok
-- The C compiler identification is Clang 5.0.0
-- The CXX compiler identification is Clang 5.0.0
-- Check for working C compiler: /usr/bin/cc
CMake Error at /fullpath/build/file1:2 (include):
  include could not find load file:
    ./build/file2
Call Stack (most recent call first):
  /fullpath/build/Mac/CMakeFiles/2.8.12/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:2 (PROJECT)
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /Applications/CMake 2.8-12.app/Contents/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/usr/bin/cc" is not able to compile a simple test program.
  It fails with the following output:
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!

CMake不仅将信息打印两次,还声称此后第三次找不到包含的文件。

Not only does CMake print the information twice, it also claim it cannot find included files at third time after that.

有什么想法吗?

推荐答案


不仅cmake两次打印信息

Not only cmake prints the information twice

这很正常:在配置过程中,执行了几个步骤。在每个步骤中,都会使用工具链文件。

It's normal: during configuration, several steps are performed. On every step the toolchain file used.


它还声称在此之后第三次找不到包含的文件。有任何想法吗?

it also claims it cannot find included files at a third time after that. Any ideas?

提供绝对路径。

这篇关于CMake工具链包含多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆