CMake 3.3.0 发布,自动化建构系统

jopen 9年前

CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。他能够输出各种各样的makefile或者project文件,能测试编译器所支持的C++特性,类似UNIX下的automake。

CMake 使用方法

CMake 的所有的语句都写在一个叫:CMakeLists.txt 的文件中。当CMakeLists.txt文件确定后,可以用ccmake命令对相关 的变量值进行配置。这个命令必须指向CMakeLists.txt所在的目录。配置完成之后,应用cmake命令生成相应的makefile(在Unix like系统下)或者 project文件(指定用window下的相应编程工具编译时)。

    其基本操作流程为:

  1. $> ccmake directory

  2. $> cmake directory

  3. $> make

  其中directory为CMakeList.txt所在目录;

  • 第一条语句用于配置编译选项,如VTK_DIR目录 ,一般这一步不需要配置,直接执行第二条语句即可,但当出现错误时,这里就需要认为配置了,这一步才真正派上用场;
  • 第二条命令用于根据CMakeLists.txt生成Makefile文件;
  • 第三条命令用于执行Makefile文件,编译程序,生成可执行文件;
CMake 3.3.0 发布,值得关注的特性如下:

  • * The "if()" command learned a new "IN_LIST" operator that evaluates  to true if a given element is contained in a named list.

  • * The "add_dependencies()" command learned to allow dependencies to  be added to *interface libraries*. Dependencies added to an  interface library are followed transitively in its place since the  target itself does not build.

  • * The "find_library()", "find_path()", and "find_file()" commands now search in installation prefixes derived from the "PATH" environment variable.

  • * The "<LANG>_VISIBILITY_PRESET" and "VISIBILITY_INLINES_HIDDEN"  target properties now affect compilation in sources of all target  types.  See policy "CMP0063".

  • * A "<LANG>_INCLUDE_WHAT_YOU_USE" target property and supporting "CMAKE_<LANG>_INCLUDE_WHAT_YOU_USE" variable were introduced to tell  the *Makefile Generators* and the "Ninja" generator to run "include-  what-you-use" along with the compiler for "C" and "CXX" languages.

更多内容请查看:发行说明