cpp project
1.0.0
這是用於C ++項目的鍋爐板。你得到的:
.
├── CMakeLists.txt
├── app
│ └── main.cpp
├── include
│ ├── example.h
│ └── exampleConfig.h.in
├── src
│ └── example.cpp
└── tests
├── dummy.cpp
└── main.cpp
源插入src/,include/,應用程序中的主要程序中的標題文件,測試進行/(默認情況下彙編為unit_tests )。
如果添加新的可執行文件,例如app/hello.cpp ,您只需要將以下兩行添加到cmakelists.txt:
add_executable (main app/main.cpp) # Name of exec. and location of file.
target_link_libraries (main PRIVATE ${LIBRARY_NAME} ) # Link the executable to lib built from src/*.cpp (if it uses it).您可以在cmakelists.txt中的Build部分下找到在app/main.cpp中構建main的示例源代碼。如果您製作的可執行文件不使用SRC/中的庫,則僅需要第一行。
通過製作構建目錄(IE build/ )來構建,在該DIR中運行cmake ,然後使用make來構建所需的目標。
例子:
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=[Debug | Coverage | Release]
make
./main
make test # Makes and runs the tests.
make coverage # Generate a coverage report.
make doc # Generate html documentation. .gitignore文件是github c ++。gitignore文件的副本,添加了忽略構建目錄( build/ )。
如果存儲庫被Travis-CI激活,則將在每個提交上構建和執行單位測試。如果使用Appveyor激活存儲庫,也是如此。
如果將存儲庫用Coveralls/codecov激活,那麼到Travis的部署還將計算代碼覆蓋範圍並將其上傳到Coveralls.io和/或Codecov.io
單擊Use this template按鈕從此模板中創建新的存儲庫。
啟動新項目時,您可能不希望此存儲庫的歷史記錄。要開始新鮮,您可以使用以下設置腳本:
git clone https://github.com/bsamseth/cpp-project # Or use ssh-link if you like.
cd cpp-project
bash setup.sh結果是一個新的git存儲庫,其中一個提交添加了鍋爐板上的所有文件。