mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-08-30 21:51:12 +02:00
move includes into project directory and create version header
This commit is contained in:
parent
47f89bf102
commit
81fdc61cb1
6 changed files with 17 additions and 5 deletions
|
@ -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,14 @@ target_include_directories(Greeter
|
|||
# ---- Create an installable target ----
|
||||
# this allows users to install and find the library via `find_package()`.
|
||||
|
||||
string(TOLOWER ${PROJECT_NAME} LOWERCASE_PROJECT_NAME)
|
||||
|
||||
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 "${LOWERCASE_PROJECT_NAME}/version.h"
|
||||
DEPENDENCIES ""
|
||||
)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <greeter.h>
|
||||
#include <greeter/greeter.h>
|
||||
|
||||
using namespace greeter;
|
||||
|
||||
|
|
|
@ -38,4 +38,3 @@ set_target_properties(GreeterStandalone PROPERTIES
|
|||
)
|
||||
|
||||
target_link_libraries(GreeterStandalone Greeter cxxopts)
|
||||
target_compile_definitions(GreeterStandalone PRIVATE -DGREETER_VERSION=\"${Greeter_VERSION}\")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <greeter.h>
|
||||
#include <greeter/greeter.h>
|
||||
#include <greeter/version.h>
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
#include <iostream>
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include <doctest/doctest.h>
|
||||
#include <greeter.h>
|
||||
|
||||
#include <greeter/greeter.h>
|
||||
#include <greeter/version.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
TEST_CASE("Greeter") {
|
||||
using namespace greeter;
|
||||
|
@ -11,3 +15,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"));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue