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

      

  • 相关阅读:
    c# in deep 之LINQ简介(1)
    今天开通博客
    bzoj 4009 接水果 整体二分
    区间求mex的几种方法
    充分性,必要性,充分条件,必要条件的区别
    表达式求值(noip2015等价表达式)
    selenium-模拟鼠标
    selenium学习-ActionChains方法列表
    高手指导中手的书籍
    新生
  • 原文地址:https://www.cnblogs.com/wanghaiyang1930/p/10514603.html
Copyright © 2011-2022 走看看