CMake并包括其他makefile

时间:2010-02-15 23:43:50

标签: build-process include makefile cmake

假设我有一个CMakeLists.txt并且我想在该文件中调用另一个包含另一个makefile(类似于C中的#include语法),我将如何实现这一目标?

1 个答案:

答案 0 :(得分:9)

来自CMake documentation

  • include :从给定文件中读取CMake列表文件代码。

    include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>]
                        [NO_POLICY_SCOPE])
    

使用示例:

的CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
include (Project.txt)

Project.txt:

project (Project)
add_executable(Project project.c)