11

我想在我自己的软件的 makefile 中包含来自外部库的 makefile。最简单的方法是找出 Makefile 等价物的 CMake 代码include ${dir}/makefile

但也许我应该提供一些背景信息。我正在尝试将 PETSc(和 SLEPc)集成到我的代码中。以下是使用 SLEPc 的示例中的一些代码(尽管 PETSc 几乎相同):

hello: hello.o chkopts
        -${CLINKER} -o hello hello.o ${SLEPC_LIB}
        ${RM} hello.o

include ${SLEPC_DIR}/conf/slepc_common

如您所见,它需要包含一个特定的 makefile,其中包含一堆其他的 makefile。这有点奇怪,因为似乎只有一个包含目录会更简单,但显然它比我理解的要多。无论如何,我的第一个解决方案是简单地包含它想要的生成文件,看看它是否有效。

4

1 回答 1

1

I believe this requirement doesn't fit CMake's design model at all as the Makefiles were generated during the generation phase and one of CMake's core principle is to make it cross platform, so the better idea might be:

  1. Rewrite the external build system in CMake scripts
  2. Include the CMake scripts in your project

If the effort is huge, you can try with add_custom_target/add_custom_command to do some out of box commands to tweak generated files, but those would also import considerable efforts - just read the manual and seek more opportunities.

于 2013-08-11T05:50:30.867 回答