【问题标题】:Calling CMake Makefile with another Makefile用另一个 Makefile 调用 CMake Makefile
【发布时间】:2018-04-02 17:13:35
【问题描述】:

我正在尝试使用 make 从 CMake 目录外部调用自动生成的 CMake makefile。

为了做到这一点,我在项目的父目录中创建了另一个 makefile。该文件应 cd 进入 CMake 目录并调用其中包含的 makefile。

很遗憾,我在使用外部 makefile 时遇到了问题。内容如下:

clean:
    cd cmake-build-debug && $(MAKE) clean

我在最后一行后面有一个选项卡,但仍然出现分离错误。

【问题讨论】:

  • “分离错误”是什么意思?你能发布一个完整(但最小)的例子,以及相应的错误信息吗?
  • 您声明“我在最后一行后面有一个标签”——cd cmake-build... 行应该开始tab 字符。

标签: makefile cmake


【解决方案1】:

来自make 手册页:

-C dir, --directory=dir
        Change to directory dir before reading the makefiles or doing 
        anything  else.   If multiple  -C  options  are specified, 
        each is interpreted relative to the previous one: 
        -C / -C etc is equivalent to -C /etc.  This is typically 
        used with  recursive invocations of make.

所以,你的干净规则可以是:

clean:
        $(MAKE) -C cmake-build-debug clean

【讨论】:

  • 虽然你说的肯定是正确的,但它并不能解释为什么cd cmake-build-debug && $(MAKE) clean 不起作用
  • 第二次看它应该可以工作。我想我们会看看@MillerR 是否将问题更新为问题/错误消息的确切内容。
  • 将 makefile 更改为这种样式是成功的 - 我不知道为什么。
猜你喜欢
  • 2011-01-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-29
  • 1970-01-01
  • 2012-10-31
相关资源
最近更新 更多