A simple, cross-platform, and continuously integrated C++14 project template
A simple, cross-platform, and continuously integrated C++14 project template.
Making cross platform C++ projects is widely known to be a troublesome ambition. This project attempts to demystify many of the common problems related to creating such a structure by providing a simple template that achieves this purpose.
(Unfortunately, a setup script isn’t currently available but is being worked on in #3. Until it is, however, these steps have to be followed manually.)
In order to use this project, all you have to do is follow a few (Ok, more than a few) simple steps:
git clone
this project into a directory of choice..codedocs
and replace the variables PROJECT_NAME
, PROJECT_NUMBER
, and PROJECT_NUMBER
with their corresponding values..travis.yml
, and replace the encrypted Coverity Scan token with the one for your project. In addition, modify the variables in the following section with their corresponding values:
project:
name: "arnavb/cpp14-project-template"
description: "A cross-platform C++14 project template"
notification_email: arnavborborah11@gmail.com
./CMakeLists.txt
, modify:Project-Name
to match your project name.Project-Name_VERSION_MAJOR
, Project-Name_VERSION_MINOR
, and Project-Name_VERSION_PATCH
to match the versioning of your project. Make sure to modify the names of the variables as well!PROJ_NAME
to be the name of your project.PROJECT_DESCRIPTION
.${CMAKE_SOURCE_DIR}/src/main.cpp
from COVERAGE_EXCLUDES
.LIBRARY_SOURCES
variable to match your project sources. Exclude main.cpp
, if it exists.And later on in the file, remove:
add_executable(Project-Name main.cpp) # The main executable
target_link_libraries(Project-Name Project-Name-lib) # Link our sources to the executable
# Install the built library and executable into the appropriate directory
install(TARGETS Project-Name DESTINATION bin)
Project-Name
and Project-Name-lib
to match your project name.to match the new folder name for your project, as described in step 8.
install(FILES ${CMAKE_BINARY_DIR}/include/project-abbr/config.hpp DESTINATION include/project-abbr) # Install our configuration file
LICENSE
to match your software license.README.md
) to match the details of your project. You may want to keep the build steps, however.doc
. Then:main_page.md
.include
. Then:project-abbr
to something that matches your project (name or abbreviation). Delete all the files except config.hpp.in
in this directory and replace them with your public include files, if they exist.src
. Then:.cpp
files in this folder and replace them with your source files and private includes.test
. Then:test_runner.cpp
with your doctest unit testing files.test/CMakeLists.txt
, change Project-Name-lib
to match the new name of your library. In addition, modify the TEST_SOURCES
variable to match your new test files..git
folder and then run git init
to get a new repository!For details on how to set up the various continuous integration tools used in this project, check the documentation.
The following tools must be preinstalled before using this template:
CMake
(At least v3.1): For building the code.Doxygen
: For generating documentation.LCOV
: For generating code coverage.In the snippets below, CONFIGURATION
needs to be a valid CMake configuration.
mkdir build && cd build
cmake -D<options> -DCMAKE_BUILD_TYPE=CONFIGURATION ..
make
make install
mkdir build && cd build
cmake -D<options> ..
cmake --build --config CONFIGURATION .
cmake --build --target INSTALL --config CONFIGURATION .
For more details on configuration options and build targets, see the documentation.
In order to run the tests, the option BUILD_TESTS
needs to be set to ON
during configuration. Then, invoking the tests is as simple as running:
ctest
In order to get the test coverage of the code, the option ENABLE_COVERAGE
needs to be set to ON
during configuration. In addition, CMAKE_BUILD_TYPE
should be set to Debug
(code coverage isn’t supported for multi-config generators yet). Then, a coverage report can be generated by running:
make coverage
The resulting coverage will be placed in a directory called coverage
in the build folder.
The documentation for this project (sample code and usage of this project) is hosted on codedocs.xyz.
Documentation about build targets, CMake options, the directory structure used, and documentation are all available in the link above.
To the extent possible under law, Arnav Borborah has waived all copyright and related or neighboring rights to C++14 Project Template. This work is published from: United States.
The above basically means that while you do not have to give me attribution for this template, it would be gladly appreciated!