首發於fxm5547的部落格
cmake_minimum_required(version 2.6)
project(itest)
# c++標準
set(cmake_cxx_standard 11)
# 指定參與編譯的原始檔
add_executable(itest src/main.cpp src/cal/calculator.cpp src/cal/calculator.h)
# 指定安裝路徑,make install 時運用
install (targets itest destination bin)
install(directory src/ destination include/itest files_matching pattern "*.h")
# 設定不同build類別時的編譯引數
#set(cmake_build_type "debug")
set(cmake_cxx_flags_debug "$env -o0 -wall -g -ggdb")
set(cmake_cxx_flags_release "$env -o3 -wall")
複製**
#!/bin/bash
# 父級目錄
base_dir=$(dirname $(pwd))
# 制定構建型別是debug
cmake $base_dir -dcmake_build_type=debug
# 編譯
make
複製**
cmake簡易教程
用cmake替代makefile,構建專案還是蠻簡單實用的。工程目錄下src放源 build儲存所有的編譯過程和結果。首先看看src目錄下的源 結構 最頂層cmakelists.txt內容如下 第一部分介紹了編譯的環境,工程的名字main project main cmake c compiler ...
CMake入門實戰
編寫cmake配置檔案cmakelists.txt。執行命令cmake path或者ccmake path生成makefile。其中,path是cmakelists.txt所在的目錄。使用make命令進行編譯。首先編寫 cmakelists.txt 檔案,並儲存在與main.cc原始檔同個目錄下 c...
cmake 學習入門
1.cmake 的學習入口 cmake 手冊文件一把一把的,就是不帶tutorial,ubuntu16 下的apt檔案就是這樣,無語了 我不需要讀那麼多,我只需要乙個tutorial就可以了,而tutorial只能從網上不能從man手冊或 apt檔案中得到了.不過github上有很多例子,也有tut...