问题描述
由于不相关的原因,我想能够包括多个文件到工具链文件。让我说我的工具链包含以下:
消息(状态file1 is ok)
include(./ build / file2)
file2包含标识行:
消息(STATUSfile2 is ok)
CMakeLists.txt包含:
cmake_minimum_required 2.8.8)
project(pro)
消息(状态cmakelists.txt is ok)
使用以下命令调用它:
cmake -DCMAKE_TOOLCHAIN_FILE = .. / .. / build / file1 ../../
现在,我会期望以下输出:
- file1是ok
- file2是ok
- cmakelists.txt是ok
然而我变成这样:
- file1是ok
- file2是ok
- file1是ok
- file2是ok
- C编译器标识是Clang 5.0.0
- CXX编译器标识是Clang 5.0.0
- 检查工作C编译器:/ usr / bin / cc
CMake错误在/ fullpath / build / file1:2(包含):
include找不到加载文件:
./build/file2
调用堆栈(最近调用):
/fullpath/build/Mac/CMakeFiles/2.8.12/CMakeSystem.cmake:6(include)
CMakeLists .txt:2(PROJECT)
CMake错误:内部CMake错误,TryCompile配置cmake失败
- 检查工作C编译器:/ usr / bin / cc - broken
CMake错误在/ Applications / CMake 2.8-12.app/Contents/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61(message):
C编译器/ usr / bin / cc无法编译一个简单的测试程序。
它失败,并显示以下输出:
CMake将无法正确生成此项目。
调用堆栈(最近调用):
CMakeLists.txt:2(project)
- 配置不完整,发生错误
不仅cmake打印信息两次,它也声称它在第三次之后找不到包含的文件。
任何想法? / p>
解决方案这是正常的。在配置期间执行几个步骤。对每个步骤使用的工具链文件。
使用绝对路径。
For the reasons irrelevant to mention I would like to be able to include multiple files into toolchain file. Lets say my toolchain contains following:
message(STATUS "file1 is ok") include(./build/file2)the file2 contains identification line:
message(STATUS "file2 is ok")the CMakeLists.txt contains:
cmake_minimum_required (VERSION 2.8.8) project (pro) message(STATUS "cmakelists.txt is ok")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 okYet i become this:
-- 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!Not only cmake prints the information twice, it also claim it cannot find included files at third time after that.
Any ideas?
解决方案It's normal. During configuration several steps performed. On every step toolchain file used.
Use absolute path.
这篇关于cmake工具链包含多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!