1. configure_file

configure_file()让你可以在代码文件中使用CMake中定义的变量。
configure_file(<input> <output>
[COPYONLY] [ESCAPE_QUOTES] [@ONLY]
[NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])
Copies an <input> file to an <output> file and substitutes variable values referenced as @VAR@ or ${VAR} in the input file content.
Each variable reference will be replaced with the current value of the variable, or the empty string if the variable is not defined.
Furthermore, input lines of the form: 拷贝一个 <input>(输入文件) 文件到 <output> (输出文件),并且替换输入文件中被 @VAR@ 或者 ${VAR} 引用的变量值。每一个变量将被替换成当前的变量值(注:CMake中的变量值)或者空串当变量未定义。
输入文件中的
#cmakedefine VAR ...
将被替换为
#define VAR ...
或者
/* #undef VAR */
Example

Consider a source tree containing a foo.h.in file:
#cmakedefine FOO_ENABLE
#cmakedefine FOO_STRING "@FOO_STRING@"
An adjacent CMakeLists.txt may use configure_file to configure the header:
option(FOO_ENABLE "Enable Foo" ON)
if(FOO_ENABLE)
set(FOO_STRING "foo")
endif()
configure_file(foo.h.in foo.h @ONLY)
This creates a foo.h in the build directory corresponding to this source directory. If the FOO_ENABLE option is on, the configured file will contain:
#define FOO_ENABLE
#define FOO_STRING "foo"
Otherwise it will contain:
/* #undef FOO_ENABLE */
/* #undef FOO_STRING */
One may then use the include_directories() command to specify the output directory as an include directory:
include_directories(${CMAKE_CURRENT_BINARY_DIR})
so that sources may include the header as #include <foo.h>.
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/config/config.h.in"
"${PROJECT_BINARY_DIR}/include/config/config.h"
)

  

CMake 笔记的更多相关文章

  1. [CMake笔记] CMake向解决方案添加源文件兼头文件

    回顾 在上一篇笔记里总结的时候说到,aux_source_directory这个函数在添加源码文件时,是不会把头文件添加进去的,这里就介经一下另外一个方法,也是我一直使用的. 添加文件*.cpp与*. ...

  2. [CMake笔记] 初识CMake

    与CMake相遇 做C/C++的人都应该经历过,以往拿到一个开源代码,想自己编译出来,总会因为VS的版本不同而出现各种各样的问题,使编译过程困难重重,更多时候就会放弃使用它了.而这个过程反过来,也会使 ...

  3. CMake笔记(一)

    CMake,比makefile更方便,虽然手写makefile同样重要 CMake的所有命令均出现在CMakeList.txt中,注意名字不要写错,并置于源代码目录中 # CMake 最低版本号要求 ...

  4. cmake笔记

    注:cmake .   当前文件夹(一个点)   cmake .. 父目录(两个点) 例子一 一个经典的C程序,如何用cmake来进行构建程序呢? //main.c #include <stdi ...

  5. GNU CMAKE 笔记

    最近在调试OJ, 忙了4天多, 最后的问题是judge模块不能正常工作. judge 模块就是两个C++源文件, 它的工作是 从数据库获取用户提交的源码 测评 将测评结果写到数据库 测评部分是与数据库 ...

  6. 《CMake实践》笔记一:PROJECT/MESSAGE/ADD_EXECUTABLE

    <CMake实践>笔记一:PROJECT/MESSAGE/ADD_EXECUTABLE <CMake实践>笔记二:INSTALL/CMAKE_INSTALL_PREFIX &l ...

  7. 《CMake实践》笔记二:INSTALL/CMAKE_INSTALL_PREFIX

    <CMake实践>笔记一:PROJECT/MESSAGE/ADD_EXECUTABLE <CMake实践>笔记二:INSTALL/CMAKE_INSTALL_PREFIX &l ...

  8. 《CMake实践》笔记三:构建静态库(.a) 与 动态库(.so) 及 如何使用外部共享库和头文件

    <CMake实践>笔记一:PROJECT/MESSAGE/ADD_EXECUTABLE <CMake实践>笔记二:INSTALL/CMAKE_INSTALL_PREFIX &l ...

  9. cmake学习笔记(五)

    在cmake 学习笔记(三) 中简单学习了 find_package 的 model 模式,在cmake 学习笔记(四)中了解一个CMakeCache相关的东西.但靠这些知识还是不能看懂PySide使 ...

随机推荐

  1. springboot使用fastjson中文乱码解决方法 【转载】

    以前使用fastjson替换jackson时,没有直接在页面打印过json,都是js使用没有出现乱码,偶然 打印出来出现了中文乱码 之前使用的配置方式 @Configuration public cl ...

  2. angular6 safe url pipe

    safe-url.pipe.ts import { Pipe, PipeTransform } from '@angular/core'; import { DomSanitizer } from ' ...

  3. hive -- 协同过滤sql语句

    hive -- 协同过滤sql语句 数据: *.3g.qq.com|腾讯应用宝|应用商店 *.91rb.com|91手机助手|应用商店 *.app.qq.com|腾讯应用宝|应用商店 *.haina. ...

  4. Centos 7 squid 用户认证

    一.安装安装过程十分简便,只需要安装一下squid,一条命令搞定yum install squidrpm -qa | grep squidsquid-3.5.20-2.el7_3.2.x86_64 二 ...

  5. VNPY 软件架构分析

    VNPY 架构设计文档 版本日志: 一. 引言 编写目的: 该软件概要设计说明书是“VNPY”开发中的重要文献资料,所完成的工作是将需求说明书中的数据流图转化成软件结构和数据结构,为后续进行详细设计说 ...

  6. idea springboot jrebel hotreloaded

    http://127.0.0.1:8888/88414687-3b91-4286-89ba-2dc813b107ce

  7. Vue.js学习过程

    打开各大论坛,看到好多Vue.js的话题,可以说现在是非常火的框架,看到一个人这样评论Vue:“Vue.js兼容angular.js和 react.js的优点,并剔除他们的缺点.”因为现在公司不用Vu ...

  8. jQuery.support属性

    jQuery.support 属性包含表示不同浏览器特性或漏洞的属性集. 此属性主要用于 jQuery 的内部使用 jQuery.support主要包括以下测试: boxModel: 如果这个页面和浏 ...

  9. Oracle 11g 测试ogg中断之后,重新同步操作

    测试ogg中断之后,重新同步操作 2018-06-07 17:11 779 1 原创 GoldenGate 本文链接:https://www.cndba.cn/leo1990/article/2839 ...

  10. Mysql数据字典导出

    1.phpmyadmin中自带的数据字典导出 2.利用下面的脚本: <?php /** * 生成mysql数据字典 */ header("Content-type: text/html ...