Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full revamp of the template #3

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
distribution/
profile.json
*-profile.json
*.log
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ add_library(project_warnings INTERFACE)
include(cmake/CompilerWarnings.cmake)
set_project_warnings(project_warnings)

include(cmake/Packaging.cmake)

enable_testing()

add_subdirectory(vendor)
add_subdirectory(src)
161 changes: 161 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{
"version": 6,
"configurePresets": [
{
"name": "debug",
"displayName": "Debug",
"generator": "Ninja",
"binaryDir": "build/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"displayName": "Release",
"generator": "Ninja",
"binaryDir": "build/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "xcode-debug",
"displayName": "Debug (Xcode)",
"generator": "Xcode",
"binaryDir": "build/xcode-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "xcode-release",
"displayName": "Release (Xcode)",
"generator": "Xcode",
"binaryDir": "build/xcode-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
}
],
"buildPresets": [
{
"name": "debug",
"displayName": "Build Debug",
"configurePreset": "debug",
"configuration": "Debug"
},
{
"name": "release",
"displayName": "Build Release",
"configurePreset": "release",
"configuration": "Release",
"targets": [
"App"
]
},
{
"name": "xcode-debug",
"displayName": "Build Debug (Xcode)",
"configurePreset": "xcode-debug",
"configuration": "Debug",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "xcode-release",
"displayName": "Build Release (Xcode)",
"configurePreset": "xcode-release",
"configuration": "Release",
"targets": [
"App"
],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
}
],
"packagePresets": [
{
"name": "release",
"displayName": "Distribute Release",
"configurePreset": "release",
"configurations": [
"Release"
]
},
{
"name": "xcode-release",
"displayName": "Distribute Release (Xcode)",
"configurePreset": "xcode-release",
"configurations": [
"Release"
],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
}
],
"testPresets": [
{
"name": "all",
"displayName": "Test All",
"configurePreset": "debug"
}
],
"workflowPresets": [
{
"name": "dist",
"displayName": "Distribution Workflow",
"steps": [
{
"type": "configure",
"name": "release"
},
{
"type": "build",
"name": "release"
},
{
"type": "package",
"name": "release"
}
]
},
{
"name": "xcode-dist",
"displayName": "Distribution Workflow (Xcode)",
"steps": [
{
"type": "configure",
"name": "xcode-release"
},
{
"type": "build",
"name": "xcode-release"
},
{
"type": "package",
"name": "xcode-release"
}
]
}
]
}
22 changes: 15 additions & 7 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand All @@ -111,13 +111,21 @@ the community.

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
at [https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html

[Mozilla CoC]: https://github.com/mozilla/diversity

[FAQ]: https://www.contributor-covenant.org/faq

[translations]: https://www.contributor-covenant.org/translations
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022-2023 Martin Helmut Fieber
Copyright (c) 2023 <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,16 @@ C++ project template.

The project uses [CMake](https://cmake.org) and [Ninja](https://ninja-build.org).

Build the application in debug mode:
Thanks to Cmake presets, a full distribution build can be created via:

```shell
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -B build/debug
ninja -C build/debug
cmake --workflow --preset dist
```

Run the application:
Also, running tests with CPack:

```shell
cd ./build/debug/src/app && ./App
```

### Using Litr

When using [Litr](https://github.com/krieselreihe/litr), the quick setup to build and run the application is:

```shell
litr build,start
ctest --preset all
```

## Disclaimer
Expand Down
13 changes: 13 additions & 0 deletions cmake/Packaging.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Base package settings
set(CPACK_PACKAGE_VENDOR ${PROJECT_COMPANY_NAME})
set(CPACK_PACKAGE_DIRECTORY distribution)
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_PROJECT_VERSION_PATCH})
set(CPACK_VERBATIM_VARIABLES YES)

set(CPACK_GENERATOR TGZ)

include(CPack)
24 changes: 0 additions & 24 deletions litr.toml

This file was deleted.

1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(tests)
add_subdirectory(app)
add_subdirectory(some_library)
4 changes: 1 addition & 3 deletions src/app/App/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/*
* Copyright (c) 2022 Martin Helmut Fieber <[email protected]>
*/
#include <exception>

#include "SomeLibrary/Core/Log.hpp"
#include "SomeLibrary/Debug/Instrumentor.hpp"
Expand Down
2 changes: 2 additions & 0 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ include(${PROJECT_SOURCE_DIR}/cmake/StaticAnalyzers.cmake)

add_executable(${NAME} App/Main.cpp)

install(TARGETS ${NAME} RUNTIME DESTINATION .)

target_include_directories(${NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(${NAME} PRIVATE cxx_std_20)
target_link_libraries(${NAME} PRIVATE project_warnings SomeLibrary)
2 changes: 2 additions & 0 deletions src/some_library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ add_library(${NAME} STATIC
target_include_directories(${NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_features(${NAME} PRIVATE cxx_std_20)
target_link_libraries(${NAME} PRIVATE project_warnings PUBLIC fmt spdlog)

add_subdirectory(Tests)
14 changes: 7 additions & 7 deletions src/some_library/SomeLibrary/Core/Log.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2022 Martin Helmut Fieber <[email protected]>
*/

#include "Log.hpp"

#include <vector>
#include <spdlog/common.h>
#include <spdlog/logger.h>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>

#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include <memory>
#include <vector>

namespace App {

Expand Down
10 changes: 3 additions & 7 deletions src/some_library/SomeLibrary/Core/Log.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/*
* Copyright (c) 2022 Martin Helmut Fieber <[email protected]>
*/

#pragma once

#include <memory>
#include <spdlog/fmt/ostr.h>
#include <spdlog/spdlog.h>

#include "spdlog/fmt/ostr.h"
#include "spdlog/spdlog.h"
#include <memory>

namespace App {

Expand Down
Loading