CMake 3.3.0 發布,自動化建構系統

jopen 9年前發布 | 6K 次閱讀 CMake

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.

更多內容請查看:發行說明

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!