zoukankan      html  css  js  c++  java
  • CMake 笔记

    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"
    )

      

  • 相关阅读:
    php 数据库练习之租房子
    php数据访问之查询关键字
    Objective-C代码学习大纲(3)
    Objective-C代码学习大纲(2)
    Objective-C代码学习大纲(1)
    简介Objective-C语言
    为什么Objective-C很难
    Swift之 ? 和 !
    使用Mac App Store更新、下载软件时出现未知错误的解决方法
    如何激励用户为你的app评分?
  • 原文地址:https://www.cnblogs.com/wanghaiyang1930/p/10514603.html
Copyright © 2011-2022 走看看