Linux中 cmake-3.x 編譯安裝以及man page添加

首先回顧一下 cmake-2.x 的編譯安裝。html

================ cmake-2.x編譯安裝說明 ================
編譯安裝的命令:git

./bootstrap --prefix=安裝目錄(默認爲/usr/local)
make
make install(根據安裝目錄的不一樣,可能須要root權限)

執行腳本文件bootstrap時加上參數「--qt-gui」,可編譯生成GUI版cmake程序。github

編譯、安裝完成後,編輯文件 /etc/profile ,將「安裝目錄/bin」加入環境變量PATH。bootstrap

安裝好的cmake自帶man文檔,只要將「安裝目錄/bin」加入環境變量PATH,便可使用man查看cmake的使用幫助,無需修改 /etc/man.config 。bash

echo "export PATH=$PATH:/usr/local/cmake/bin" >> /etc/bashrc

================ cmake-3.x編譯安裝說明 ================
安裝步驟基本同cmake-2.x,主要區別在於幫助文檔的構建方式。工具

cmake-2.x的幫助文檔實際上是嵌在源代碼中,並編譯進可執行文件,經過「--help-full、--help-html、--help-man」等參數分別輸出文本格式、html格式、man格式的幫助文檔。ui

cmake-3.x只保留了「--help-full」用於輸出文本格式的幫助文檔,另外兩種格式須要藉助文檔生成工具sphinx(一個Python插件)。spa

在執行腳本文件bootstrap時,經過以下參數指定要構建的幫助文檔:.net

--sphinx-man 構建man幫助文檔
--sphinx-html 構建html幫助文檔
--sphinx-qthelp 構建qch幫助文檔
--sphinx-build=/path/to/sphinx-build 設置sphinx-build程序的路徑插件

執行make前須要安裝sphinx。調用Python提供的pip命令(Python3中爲pip3)進行安裝:

詳見:https://github.com/sphinx-doc/sphinx/

README for Sphinx

This is the Sphinx documentation generator, see http://www.sphinx-doc.org/.

Installing

Install from PyPI to use stable version:

pip install -U sphinx
Install from PyPI to use beta version: pip
install -U --pre sphinx Install from newest dev version in stable branch: pip install git+https://github.com/sphinx-doc/sphinx@stable Install from newest dev version in master branch: pip install git+https://github.com/sphinx-doc/sphinx Install from cloned source: pip install . Install from cloned source as editable: pip install -e .

 

在安裝過程當中,pip須要聯網下載安裝一堆別的Python插件。爲了在沒法聯網的計算機上安裝cmake-3.x,建議先在一臺能訪問互聯網的計算機上安裝sphinx,構建cmake-3.x及其幫助文檔。執行make install後,將安裝好的文件部署到沒法聯網的計算機。

最後要將幫助文檔路徑寫到/etc/man_db.conf文件中。

 


cmake下載地址 https://cmake.org/files/

sphinx下載地址 https://github.com/sphinx-doc/sphinx/

---------------------------------------------------------------------------------------------

轉自:http://blog.csdn.net/zhawk/article/details/74276175

相關文章
相關標籤/搜索