diff --git a/CMakeLists.txt b/CMakeLists.txt index 20ba77d..cb7fe9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ include(cmake/CPM.cmake) CPMAddPackage( NAME PackageProject.cmake GITHUB_REPOSITORY TheLartians/PackageProject.cmake - VERSION 1.2.1 + VERSION 1.3 ) # ---- Add source files ---- @@ -58,11 +58,16 @@ target_include_directories(Greeter # ---- Create an installable target ---- # 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( NAME ${PROJECT_NAME} VERSION ${PROJECT_VERSION} BINARY_DIR ${PROJECT_BINARY_DIR} INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION} + VERSION_HEADER "${VERSION_HEADER_LOCATION}" DEPENDENCIES "" ) diff --git a/README.md b/README.md index 2e82cc8..0ec6617 100644 --- a/README.md +++ b/README.md @@ -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) - 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) -- 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) ## Usage @@ -84,7 +84,7 @@ See [Format.cmake](https://github.com/TheLartians/Format.cmake) for more options ### 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. ```bash diff --git a/include/greeter.h b/include/greeter/greeter.h similarity index 100% rename from include/greeter.h rename to include/greeter/greeter.h diff --git a/source/greeter.cpp b/source/greeter.cpp index e75363f..b1c54a7 100644 --- a/source/greeter.cpp +++ b/source/greeter.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace greeter; diff --git a/standalone/source/main.cpp b/standalone/source/main.cpp index 70460ef..5464fa5 100644 --- a/standalone/source/main.cpp +++ b/standalone/source/main.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include #include @@ -21,6 +22,7 @@ int main(int argc, char** argv) { // clang-format off options.add_options() ("h,help", "Show help") + ("v,version", "Print the current version number") ("n,name", "Name to greet", cxxopts::value(name)->default_value("World")) ("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()) { std::cout << options.help() << std::endl; return 0; + } else if (result["version"].as()) { + std::cout << "Greeter, version " << GREETER_VERSION << std::endl; + return 0; } auto langIt = languages.find(language); if (langIt == languages.end()) { - std::cout << "unknown language code: " << language << std::endl; + std::cerr << "unknown language code: " << language << std::endl; return 1; } diff --git a/test/source/greeter.cpp b/test/source/greeter.cpp index eb12ab3..3d507e0 100644 --- a/test/source/greeter.cpp +++ b/test/source/greeter.cpp @@ -1,5 +1,8 @@ #include -#include +#include +#include + +#include TEST_CASE("Greeter") { using namespace greeter; @@ -11,3 +14,8 @@ TEST_CASE("Greeter") { CHECK(greeter.greet(LanguageCode::ES) == "¡Hola 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")); +} \ No newline at end of file