cmake執行工程
參考文獻:
c++構建工具之cmake使用小結_數學物理方法-CSDN部落格
使用cmake的過程先是要編寫一個cmakelists.txt的文字,然後使用cmake命令生成對應平臺的工程。
在windows下命令列或者使用cmake gui工具,生成vs工程,然後使用vs編譯。
在linux下則是根據cmakelists.txt生成makefile,然後使用make命令呼叫編譯。
1.cmake命令編譯指定目錄下的cmakelists.txt,具體選項使用cmake makelist.txt生成makefile,
2.然後執行make就可以進行程式碼編譯了。(非常好使)
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
-
Usage
-
cmake [options] <path-to-source>
-
cmake [options] <path-to-existing-build>
-
Specify a source directory to (re-)generate a build system for it in the
-
current working directory. Specify an existing build directory to
-
re-generate its build system.
-
Options
-
-C <initial-cache> = Pre-load a script to populate the cache.
-
-D <var>[:<type>]=<value> = Create a cmake cache entry.
-
-U <globbing_expr> = Remove matching entries from CMake cache.
-
-G <generator-name> = Specify a build system generator.
-
-T <toolset-name> = Specify toolset name if supported by
-
generator.
-
-A <platform-name> = Specify platform name if supported by
-
generator.
-
-Wdev = Enable developer warnings.
-
-Wno-dev = Suppress developer warnings.
-
-Werror=dev = Make developer warnings errors.
-
-Wno-error=dev = Make developer warnings not errors.
-
-Wdeprecated = Enable deprecation warnings.
-
-Wno-deprecated = Suppress deprecation warnings.
-
-Werror=deprecated = Make deprecated macro and function warnings
-
errors.
-
-Wno-error=deprecated = Make deprecated macro and function warnings
-
not errors.
-
-E = CMake command mode.
-
-L[A][H] = List non-advanced cached variables.
-
--build <dir> = Build a CMake-generated project binary tree.
-
-N = View mode only.
-
-P <file> = Process script mode.
-
--find-package = Run in pkg-config like mode.
-
--graphviz=[file] = Generate graphviz of dependencies, see
-
CMakeGraphVizOptions.cmake for more.
-
--system-information [file] = Dump information about this system.
-
--debug-trycompile = Do not delete the try_compile build tree.
-
Only useful on one try_compile at a time.
-
--debug-output = Put cmake in a debug mode.
-
--trace = Put cmake in trace mode.
-
--trace-expand = Put cmake in trace mode with variable
-
expansion.
-
--warn-uninitialized = Warn about uninitialized values.
-
--warn-unused-vars = Warn about unused variables.
-
--no-warn-unused-cli = Don't warn about command line options.
-
--check-system-vars = Find problems with variable usage in system
-
files.
-
--help,-help,-usage,-h,-H,/? = Print usage information and exit.
-
--version,-version,/V [<f>] = Print version number and exit.
-
--help-full [<f>] = Print all help manuals and exit.
-
--help-manual <man> [<f>] = Print one help manual and exit.
-
--help-manual-list [<f>] = List help manuals available and exit.
-
--help-command <cmd> [<f>] = Print help for one command and exit.
-
--help-command-list [<f>] = List commands with help available and exit.
-
--help-commands [<f>] = Print cmake-commands manual and exit.
-
--help-module <mod> [<f>] = Print help for one module and exit.
-
--help-module-list [<f>] = List modules with help available and exit.
-
--help-modules [<f>] = Print cmake-modules manual and exit.
-
--help-policy <cmp> [<f>] = Print help for one policy and exit.
-
--help-policy-list [<f>] = List policies with help available and exit.
-
--help-policies [<f>] = Print cmake-policies manual and exit.
-
--help-property <prop> [<f>] = Print help for one property and exit.
-
--help-property-list [<f>] = List properties with help available and
-
exit.
-
--help-properties [<f>] = Print cmake-properties manual and exit.
-
--help-variable var [<f>] = Print help for one variable and exit.
-
--help-variable-list [<f>] = List variables with help available and exit.
-
--help-variables [<f>] = Print cmake-variables manual and exit.
-
Generators
-
The following generators are available on this platform:
-
Unix Makefiles = Generates standard UNIX makefiles.
-
Ninja = Generates build.ninja files.
-
Watcom WMake = Generates Watcom WMake makefiles.
-
CodeBlocks - Ninja = Generates CodeBlocks project files.
-
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
-
CodeLite - Ninja = Generates CodeLite project files.
-
CodeLite - Unix Makefiles = Generates CodeLite project files.
-
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
-
Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
-
KDevelop3 = Generates KDevelop 3 project files.
-
KDevelop3 - Unix Makefiles = Generates KDevelop 3 project files.
-
Kate - Ninja = Generates Kate project files.
-
Kate - Unix Makefiles = Generates Kate project files.
-
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
-
Sublime Text 2 - Unix Makefiles
-
= Generates Sublime Text 2 project files.
1.生成執行程式
-
project(HELLO)
-
set(SRC_LIST main.c hello.c)
-
add_executable(hello ${SRC_LIST})
2.生成動態庫
-
project(HELLO)
-
set(LIB_SRC hello.c)
-
add_library(libhello STATIC ${LIB_SRC})
3.生成靜態庫
-
project(HELLO)
-
set(LIB_SRC hello.c)
-
add_library(libhello SHARED ${LIB_SRC})
相關文章
- CMake VS工程總結
- cmake配置VS工程配置使用dll
- c++ Cmake工程(4) opevslam ros工程模式C++SLAMROS模式
- 使用CMake構建Android JNI工程Android
- CMake生成eclipse的工程並匯入Eclipse
- CMake編譯Qt工程時的問題編譯QT
- c++ Cmake工程(1)同級目錄C++
- c++ Cmake工程(3)平行目錄 opevslam工程模式C++SLAM模式
- 從cmake解決clion編譯生成的可執行檔案(.exe)不可執行的問題編譯
- clion 《cmake自定義靜態庫後,生成的exe無法執行》
- 【經驗分享】win10 cmake 構建 Tengine 工程Win10
- 王廣帥IM工程執行記錄
- c++ Cmake工程(2)平行上級目錄 常用模式C++模式
- 【CMake】掌握CMake基本操作
- 工程總承包管理執行探討(轉)
- cmake報錯CMake Error: Could not find CMAKE_ROOTError
- CMake 簡介和 CMake 模板
- cmake
- CMake構建學習筆記16-使用VS進行CMake專案的開發筆記
- cmake 模板
- cmake cuda
- cmake + JNI
- CMake 使用
- Cmake用法
- MySQL 5.7.17 安裝報錯CMake Error at cmake/boost.cmake:81 (MESSAGE)MySqlError
- <<Modern CMake>> 翻譯 2. CMake 基礎
- <<Modern CMake>> 翻譯 2.2 CMake 程式設計程式設計
- (CMake):CMake安裝及快速入門案例
- CMake Error at cmake/readline.cmake:85 (MESSAGE): Curses library not found.Error
- Cmake 入門
- make與cmake
- cmake筆記筆記
- 軟體工程實踐專案學習與執行日誌軟體工程
- redhat 6.8升級預設cmake 2.8到cmake 3.9Redhat
- cmake的使用(cmake不是內部或外部命令)
- 保證執行緒在主執行緒執行執行緒
- CMAKE工具學習
- ubuntu安裝CMakeUbuntu