Cmake Toolchain включает в себя несколько файлов

StackOverflow https://stackoverflow.com/questions/19854613

  •  29-07-2022
  •  | 
  •  

Вопрос

По причинам, не относящимся к упоминанию, я хотел бы иметь возможность включить несколько файлов в файл инструментов. Допустим, мой инструмент содержит следующее:

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

Файл2 содержит идентификационную строку:

message(STATUS "file2 is ok")

cmakelists.txt содержит:

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

Я называю это с помощью следующей команды:

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

Теперь я ожидаю следующего результата:

-- 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 печатает информацию дважды, он также утверждает, что не может найти включенные файлы в третий раз после этого.

Любые идеи?

Это было полезно?

Решение

Не только дважды Cmake печатает информацию

Это нормально: во время конфигурации выполняются несколько шагов. На каждом шаге используется файл инструмента.

Он также утверждает, что не может найти включенные файлы в третий раз после этого. Любые идеи?

Обеспечить абсолютный путь.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top