Create version header and update readme (#44)
* add note on github pages * add version information to standalone. closes #35. * update version info * move includes into project directory and create version header * fix style * add comment for version header location
This commit is contained in:
parent
032e506c12
commit
92adf2db25
6 changed files with 25 additions and 7 deletions
|
@ -23,7 +23,7 @@ include(cmake/CPM.cmake)
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME PackageProject.cmake
|
NAME PackageProject.cmake
|
||||||
GITHUB_REPOSITORY TheLartians/PackageProject.cmake
|
GITHUB_REPOSITORY TheLartians/PackageProject.cmake
|
||||||
VERSION 1.2.1
|
VERSION 1.3
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---- Add source files ----
|
# ---- Add source files ----
|
||||||
|
@ -58,11 +58,16 @@ target_include_directories(Greeter
|
||||||
# ---- Create an installable target ----
|
# ---- Create an installable target ----
|
||||||
# this allows users to install and find the library via `find_package()`.
|
# this allows users to install and find the library via `find_package()`.
|
||||||
|
|
||||||
|
# the location where the project's version header will be placed
|
||||||
|
# should match the project's regular header paths
|
||||||
|
string(TOLOWER ${PROJECT_NAME}/version.h VERSION_HEADER_LOCATION)
|
||||||
|
|
||||||
packageProject(
|
packageProject(
|
||||||
NAME ${PROJECT_NAME}
|
NAME ${PROJECT_NAME}
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
BINARY_DIR ${PROJECT_BINARY_DIR}
|
BINARY_DIR ${PROJECT_BINARY_DIR}
|
||||||
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
|
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
|
||||||
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
|
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||||
|
VERSION_HEADER "${VERSION_HEADER_LOCATION}"
|
||||||
DEPENDENCIES ""
|
DEPENDENCIES ""
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,7 +25,7 @@ This template is the result of learnings from many previous projects and should
|
||||||
- Code formatting enforced by [clang-format](https://clang.llvm.org/docs/ClangFormat.html) via [Format.cmake](https://github.com/TheLartians/Format.cmake)
|
- Code formatting enforced by [clang-format](https://clang.llvm.org/docs/ClangFormat.html) via [Format.cmake](https://github.com/TheLartians/Format.cmake)
|
||||||
- Reproducible dependency management via [CPM.cmake](https://github.com/TheLartians/CPM.cmake)
|
- Reproducible dependency management via [CPM.cmake](https://github.com/TheLartians/CPM.cmake)
|
||||||
- Installable target with versioning information via [PackageProject.cmake](https://github.com/TheLartians/PackageProject.cmake)
|
- Installable target with versioning information via [PackageProject.cmake](https://github.com/TheLartians/PackageProject.cmake)
|
||||||
- Automatic documentation generation with [Doxygen](https://www.doxygen.nl)
|
- Automatic documentation generation and deployment with [Doxygen](https://www.doxygen.nl) and [GitHub Pages](https://pages.github.com)
|
||||||
- Support for [sanitizer tools, and more](#additional-tools)
|
- Support for [sanitizer tools, and more](#additional-tools)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
@ -84,7 +84,7 @@ See [Format.cmake](https://github.com/TheLartians/Format.cmake) for more options
|
||||||
|
|
||||||
### Build the documentation
|
### Build the documentation
|
||||||
|
|
||||||
The documentation is automatically built and updated after every [release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository).
|
The documentation is automatically built and [published](https://thelartians.github.io/ModernCppStarter) whenever a [GitHub Release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) is created.
|
||||||
To manually build documentation, call the following command.
|
To manually build documentation, call the following command.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include <greeter.h>
|
#include <greeter/greeter.h>
|
||||||
|
|
||||||
using namespace greeter;
|
using namespace greeter;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <greeter.h>
|
#include <greeter/greeter.h>
|
||||||
|
#include <greeter/version.h>
|
||||||
|
|
||||||
#include <cxxopts.hpp>
|
#include <cxxopts.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -21,6 +22,7 @@ int main(int argc, char** argv) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
options.add_options()
|
options.add_options()
|
||||||
("h,help", "Show help")
|
("h,help", "Show help")
|
||||||
|
("v,version", "Print the current version number")
|
||||||
("n,name", "Name to greet", cxxopts::value(name)->default_value("World"))
|
("n,name", "Name to greet", cxxopts::value(name)->default_value("World"))
|
||||||
("l,lang", "Language code to use", cxxopts::value(language)->default_value("en"))
|
("l,lang", "Language code to use", cxxopts::value(language)->default_value("en"))
|
||||||
;
|
;
|
||||||
|
@ -31,11 +33,14 @@ int main(int argc, char** argv) {
|
||||||
if (result["help"].as<bool>()) {
|
if (result["help"].as<bool>()) {
|
||||||
std::cout << options.help() << std::endl;
|
std::cout << options.help() << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if (result["version"].as<bool>()) {
|
||||||
|
std::cout << "Greeter, version " << GREETER_VERSION << std::endl;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto langIt = languages.find(language);
|
auto langIt = languages.find(language);
|
||||||
if (langIt == languages.end()) {
|
if (langIt == languages.end()) {
|
||||||
std::cout << "unknown language code: " << language << std::endl;
|
std::cerr << "unknown language code: " << language << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
#include <greeter.h>
|
#include <greeter/greeter.h>
|
||||||
|
#include <greeter/version.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
TEST_CASE("Greeter") {
|
TEST_CASE("Greeter") {
|
||||||
using namespace greeter;
|
using namespace greeter;
|
||||||
|
@ -11,3 +14,8 @@ TEST_CASE("Greeter") {
|
||||||
CHECK(greeter.greet(LanguageCode::ES) == "¡Hola Tests!");
|
CHECK(greeter.greet(LanguageCode::ES) == "¡Hola Tests!");
|
||||||
CHECK(greeter.greet(LanguageCode::FR) == "Bonjour Tests!");
|
CHECK(greeter.greet(LanguageCode::FR) == "Bonjour Tests!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Greeter version") {
|
||||||
|
static_assert(std::string_view(GREETER_VERSION) == std::string_view("1.0"));
|
||||||
|
CHECK(std::string(GREETER_VERSION) == std::string("1.0"));
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue