mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-08-30 13:41:13 +02:00
- Add CMake Workflow Presets
- Upgrade to gitup workflow action v3 - Prepare use of git-flow - Use CMake v3.21 variable PROJECT_IS_TOP_LEVEL - Use CMAKE_DEBUG_POSTFIX to prevent name clashes - Add more config files
This commit is contained in:
parent
fcbedfe9d8
commit
d81a42450c
22 changed files with 540 additions and 31 deletions
|
@ -22,7 +22,9 @@ parse:
|
|||
SVN_REPOSITORY: 1
|
||||
SVN_REVISION: 1
|
||||
SOURCE_DIR: 1
|
||||
SYSTEM: 1
|
||||
DOWNLOAD_COMMAND: 1
|
||||
EXCLUDE_FROM_ALL: 1
|
||||
FIND_PACKAGE_ARGUMENTS: 1
|
||||
NO_CACHE: 1
|
||||
GIT_SHALLOW: 1
|
||||
|
|
14
.envrc
Normal file
14
.envrc
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Define environment in this dir only with direnv.
|
||||
# On first usage enter: direnv allow
|
||||
# man direnv for more infos
|
||||
#
|
||||
# see too https://cmake.org/cmake/help/latest/manual/cmake-env-variables.7.html
|
||||
export CMAKE_PREFIX_PATH=${PWD}/stagedir
|
||||
export CMAKE_EXPORT_COMPILE_COMMANDS=YES
|
||||
export CTEST_OUTPUT_ON_FAILURE=YES
|
||||
|
||||
export CPM_USE_LOCAL_PACKAGES=YES
|
||||
export CPM_SOURCE_CACHE=${PWD}/.cache/CPM
|
||||
|
||||
export LD_LIBRARY_PATH=${CMAKE_PREFIX_PATH}/lib
|
||||
export BUILD_DIR=${PWD}/build
|
7
.github/workflows/install.yml
vendored
7
.github/workflows/install.yml
vendored
|
@ -1,14 +1,15 @@
|
|||
---
|
||||
name: Install
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
@ -33,7 +34,7 @@ jobs:
|
|||
rm -rf build
|
||||
|
||||
- name: configure
|
||||
run: cmake -Stest -Bbuild -DTEST_INSTALLED_VERSION=1
|
||||
run: cmake -S test -B build -D TEST_INSTALLED_VERSION=1
|
||||
|
||||
- name: build
|
||||
run: cmake --build build --config Debug -j4
|
||||
|
|
7
.github/workflows/macos.yml
vendored
7
.github/workflows/macos.yml
vendored
|
@ -1,14 +1,15 @@
|
|||
---
|
||||
name: MacOS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
@ -27,7 +28,7 @@ jobs:
|
|||
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
|
||||
|
||||
- name: configure
|
||||
run: cmake -Stest -Bbuild -DCMAKE_BUILD_TYPE=Debug
|
||||
run: cmake -S test -B build -D CMAKE_BUILD_TYPE=Debug
|
||||
|
||||
- name: build
|
||||
run: cmake --build build -j4
|
||||
|
|
7
.github/workflows/standalone.yml
vendored
7
.github/workflows/standalone.yml
vendored
|
@ -1,14 +1,15 @@
|
|||
---
|
||||
name: Standalone
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
|
||||
env:
|
||||
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules
|
||||
|
@ -26,7 +27,7 @@ jobs:
|
|||
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
|
||||
|
||||
- name: configure
|
||||
run: cmake -Sstandalone -Bbuild -DCMAKE_BUILD_TYPE=Debug
|
||||
run: cmake -S standalone -B build -D CMAKE_BUILD_TYPE=Debug
|
||||
|
||||
- name: build
|
||||
run: cmake --build build -j4
|
||||
|
|
7
.github/workflows/style.yml
vendored
7
.github/workflows/style.yml
vendored
|
@ -1,14 +1,15 @@
|
|||
---
|
||||
name: Style
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
|
||||
env:
|
||||
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules
|
||||
|
@ -29,7 +30,7 @@ jobs:
|
|||
run: pip3 install clang-format==14.0.6 cmake_format==0.6.11 pyyaml
|
||||
|
||||
- name: configure
|
||||
run: cmake -Stest -Bbuild
|
||||
run: cmake -S test -B build
|
||||
|
||||
- name: check style
|
||||
run: cmake --build build --target check-format
|
||||
|
|
7
.github/workflows/ubuntu.yml
vendored
7
.github/workflows/ubuntu.yml
vendored
|
@ -1,14 +1,15 @@
|
|||
---
|
||||
name: Ubuntu
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
@ -28,7 +29,7 @@ jobs:
|
|||
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
|
||||
|
||||
- name: configure
|
||||
run: cmake -Stest -Bbuild -DENABLE_TEST_COVERAGE=1 -DCMAKE_BUILD_TYPE=Debug
|
||||
run: cmake -S test -B build -D ENABLE_TEST_COVERAGE=1 -D CMAKE_BUILD_TYPE=Debug
|
||||
|
||||
- name: build
|
||||
run: cmake --build build -j4
|
||||
|
|
7
.github/workflows/windows.yml
vendored
7
.github/workflows/windows.yml
vendored
|
@ -1,14 +1,15 @@
|
|||
---
|
||||
name: Windows
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- develop
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: 1
|
||||
|
@ -27,7 +28,7 @@ jobs:
|
|||
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
|
||||
|
||||
- name: configure
|
||||
run: cmake -Stest -Bbuild
|
||||
run: cmake -S test -B build -G "Visual Studio 17 2022" -D BUILD_SHARED_LIBS=NO
|
||||
|
||||
- name: build
|
||||
run: cmake --build build --config Debug -j4
|
||||
|
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,4 +1,7 @@
|
|||
*~
|
||||
*.swp
|
||||
/build*
|
||||
/stagedir
|
||||
/.vscode
|
||||
/cpm_modules
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.14...3.27)
|
||||
cmake_minimum_required(VERSION 3.21...3.27)
|
||||
|
||||
# ---- Project ----
|
||||
|
||||
|
@ -18,18 +18,25 @@ if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(NOT PROJECT_IS_TOP_LEVEL)
|
||||
option(CMAKE_SKIP_INSTALL_RULES "Whether to disable generation of installation rules" YES)
|
||||
endif()
|
||||
|
||||
option(OPTION_ENABLE_UNITY "Enable Unity builds of project" ON)
|
||||
|
||||
# ---- Add dependencies via CPM ----
|
||||
# see https://github.com/TheLartians/CPM.cmake for more info
|
||||
|
||||
include(cmake/CPM.cmake)
|
||||
|
||||
# PackageProject.cmake will be used to make our target installable
|
||||
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.8.0")
|
||||
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.10.0")
|
||||
|
||||
CPMAddPackage(
|
||||
NAME fmt
|
||||
GIT_TAG 9.1.0
|
||||
GITHUB_REPOSITORY fmtlib/fmt
|
||||
SYSTEM ON # used in case of cmake v3.25
|
||||
OPTIONS "FMT_INSTALL YES" # create an installable target
|
||||
)
|
||||
|
||||
|
@ -46,12 +53,15 @@ file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/
|
|||
# target: add_library(${PROJECT_NAME} INTERFACE)
|
||||
add_library(${PROJECT_NAME} ${headers} ${sources})
|
||||
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ${OPTION_ENABLE_UNITY})
|
||||
|
||||
# enable compiler warnings
|
||||
include(cmake/WarningsAsErrors.cmake)
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
# enable compiler warnings
|
||||
include(cmake/WarningsAsErrors.cmake)
|
||||
|
||||
# being a cross-platform target, we enforce standards conformance on MSVC
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")
|
||||
# being a cross-platform target, we enforce standards conformance on MSVC
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")
|
||||
endif()
|
||||
|
||||
# Link dependencies
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC fmt::fmt)
|
||||
|
@ -79,3 +89,5 @@ packageProject(
|
|||
COMPATIBILITY SameMajorVersion
|
||||
DEPENDENCIES "fmt 9.1.0"
|
||||
)
|
||||
|
||||
include(CPack)
|
||||
|
|
97
CMakePresets.json
Normal file
97
CMakePresets.json
Normal file
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
"version": 6,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 25,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"displayName": "Default user Config",
|
||||
"description": "Default build using Ninja generator",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/default",
|
||||
"installDir": "${sourceDir}/stagedir",
|
||||
"cacheVariables": {
|
||||
"CMAKE_PREFIX_PATH": {
|
||||
"type": "path",
|
||||
"value": "${sourceDir}/stagedir"
|
||||
},
|
||||
"CMAKE_CXX_STANDARD": "20",
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_DEBUG_POSTFIX": "D",
|
||||
"BUILD_SHARED_LIBS": "NO"
|
||||
},
|
||||
"environment": {
|
||||
"CPM_USE_LOCAL_PACKAGES": "YES",
|
||||
"PATH": "$env{HOME}/.local/bin${pathListSep}$penv{PATH}"
|
||||
},
|
||||
"warnings": {
|
||||
"deprecated": true,
|
||||
"uninitialized": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ninja-multi",
|
||||
"inherits": "default",
|
||||
"displayName": "Ninja Multi-Config",
|
||||
"description": "Default build using Ninja Multi-Config generator",
|
||||
"generator": "Ninja Multi-Config"
|
||||
},
|
||||
{
|
||||
"name": "windows-only",
|
||||
"inherits": "default",
|
||||
"displayName": "Windows-only configuration",
|
||||
"description": "This build is only available on Windows",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default"
|
||||
},
|
||||
{
|
||||
"name": "install",
|
||||
"configurePreset": "default",
|
||||
"targets": ["install"]
|
||||
}
|
||||
],
|
||||
"packagePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"generators": [
|
||||
"TGZ"
|
||||
]
|
||||
}
|
||||
],
|
||||
"workflowPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "install"
|
||||
},
|
||||
{
|
||||
"type": "package",
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -27,6 +27,7 @@ This template is the result of learnings from many previous projects and should
|
|||
- Installable target with automatic versioning information and header generation via [PackageProject.cmake](https://github.com/TheLartians/PackageProject.cmake)
|
||||
- Automatic [documentation](https://thelartians.github.io/ModernCppStarter) and deployment with [Doxygen](https://www.doxygen.nl) and [GitHub Pages](https://pages.github.com)
|
||||
- Support for [sanitizer tools, and more](#additional-tools)
|
||||
- Supports [CMake Workflow Presets](https://cmake.org/cmake/help/v3.25/manual/cmake-presets.7.html#id10)
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -52,6 +53,8 @@ During development it is usually convenient to [build all subprojects at once](#
|
|||
Use the following command to build and run the executable target.
|
||||
|
||||
```bash
|
||||
cd standalone && cmake --workflow --preset=default
|
||||
# or
|
||||
cmake -S standalone -B build/standalone
|
||||
cmake --build build/standalone
|
||||
./build/standalone/Greeter --help
|
||||
|
@ -62,6 +65,8 @@ cmake --build build/standalone
|
|||
Use the following commands from the project's root directory to run the test suite.
|
||||
|
||||
```bash
|
||||
cd test && cmake --workflow --preset=default
|
||||
# or
|
||||
cmake -S test -B build/test
|
||||
cmake --build build/test
|
||||
CTEST_OUTPUT_ON_FAILURE=1 cmake --build build/test --target test
|
||||
|
@ -114,6 +119,8 @@ The project also includes an `all` directory that allows building all targets at
|
|||
This is useful during development, as it exposes all subprojects to your IDE and avoids redundant builds of the library.
|
||||
|
||||
```bash
|
||||
cd all && cmake --workflow --preset=default
|
||||
# or
|
||||
cmake -S all -B build
|
||||
cmake --build build
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# this script adds all subprojects to a single build to allow IDEs understand the full project
|
||||
# structure.
|
||||
|
||||
cmake_minimum_required(VERSION 3.14...3.27)
|
||||
cmake_minimum_required(VERSION 3.21...3.27)
|
||||
|
||||
project(BuildAll LANGUAGES CXX)
|
||||
|
||||
|
|
103
all/CMakePresets.json
Normal file
103
all/CMakePresets.json
Normal file
|
@ -0,0 +1,103 @@
|
|||
{
|
||||
"version": 6,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 23,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"displayName": "Default develop all Config",
|
||||
"description": "Default build using Ninja generator",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceParentDir}/build/all",
|
||||
"installDir": "${sourceParentDir}/stagedir",
|
||||
"cacheVariables": {
|
||||
"CMAKE_PREFIX_PATH": {
|
||||
"type": "path",
|
||||
"value": "${sourceParentDir}/stagedir"
|
||||
},
|
||||
"CMAKE_CXX_STANDARD": "20",
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"CMAKE_DEBUG_POSTFIX": "D",
|
||||
"CPM_USE_LOCAL_PACKAGES": "NO",
|
||||
"BUILD_SHARED_LIBS": "YES",
|
||||
"ENABLE_TEST_COVERAGE": "YES"
|
||||
},
|
||||
"environment": {
|
||||
"CPM_USE_LOCAL_PACKAGES": "YES",
|
||||
"PATH": "$env{HOME}/.local/bin${pathListSep}$penv{PATH}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ninja-multi",
|
||||
"inherits": "default",
|
||||
"displayName": "Ninja Multi-Config",
|
||||
"description": "Default build using Ninja Multi-Config generator",
|
||||
"generator": "Ninja Multi-Config"
|
||||
},
|
||||
{
|
||||
"name": "windows-only",
|
||||
"inherits": "default",
|
||||
"displayName": "Windows-only configuration",
|
||||
"description": "This build is only available on Windows",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default"
|
||||
},
|
||||
{
|
||||
"name": "format",
|
||||
"configurePreset": "default",
|
||||
"targets": ["fix-clang-format", "check-cmake-format"]
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"output": {"outputOnFailure": true},
|
||||
"execution": {"noTestsAction": "error", "stopOnFailure": true}
|
||||
}
|
||||
],
|
||||
"packagePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"generators": [
|
||||
"TGZ"
|
||||
]
|
||||
}
|
||||
],
|
||||
"workflowPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "format"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -6,6 +6,10 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 10.0)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wdeprecated-copy-dtor -Wnewline-eof)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 14.0)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-deprecated-declarations)
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.14...3.27)
|
||||
cmake_minimum_required(VERSION 3.21...3.27)
|
||||
|
||||
project(GreeterDocs)
|
||||
|
||||
|
|
19
gcovr.cfg
Normal file
19
gcovr.cfg
Normal file
|
@ -0,0 +1,19 @@
|
|||
root = .
|
||||
search-path = build
|
||||
|
||||
filter = src/*
|
||||
filter = include/*
|
||||
filter = standalone/*
|
||||
|
||||
exclude-directories = test
|
||||
exclude-directories = stagedir
|
||||
exclude-directories = build/_deps
|
||||
exclude-directories = .cache
|
||||
|
||||
gcov-ignore-parse-errors = yes
|
||||
print-summary = yes
|
||||
|
||||
html-details = build/gcovr.html
|
||||
|
||||
cobertura-pretty = yes
|
||||
cobertura = build/cobertura.xml
|
18
requirements.txt
Normal file
18
requirements.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
# =============================================================================
|
||||
# PYTHON PACKAGES (PIP)
|
||||
# =============================================================================
|
||||
# USE (python3): sudo pip3 install -r <THIS_FILE_NAME>
|
||||
# =============================================================================
|
||||
|
||||
PyYAML>=5.4.1,<6.0
|
||||
asyncio==3.4.3
|
||||
builddriver==0.9.0
|
||||
bumpversion>=0.6.0
|
||||
cmake-format>=0.6.13
|
||||
cmake>=3.25
|
||||
gcovr>=5.2
|
||||
ninja>=1.11
|
||||
pytest-asyncio==0.19.0
|
||||
pytest==7.1.3
|
||||
tftpy>=0.8.2
|
||||
wheel>=0.37.1
|
|
@ -1,7 +1,16 @@
|
|||
cmake_minimum_required(VERSION 3.14...3.27)
|
||||
cmake_minimum_required(VERSION 3.21...3.27)
|
||||
|
||||
project(GreeterStandalone LANGUAGES CXX)
|
||||
|
||||
if(PROJECT_IS_TOP_LEVEL AND CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(CMAKE_SKIP_INSTALL_RULES
|
||||
NO
|
||||
CACHE BOOL "Forced generation of installation rules" FORCE
|
||||
)
|
||||
endif()
|
||||
|
||||
option(OPTION_ENABLE_UNITY "Enable Unity builds of project" ON)
|
||||
|
||||
# --- Import tools ----
|
||||
|
||||
include(../cmake/tools.cmake)
|
||||
|
@ -13,6 +22,7 @@ include(../cmake/CPM.cmake)
|
|||
CPMAddPackage(
|
||||
GITHUB_REPOSITORY jarro2783/cxxopts
|
||||
VERSION 3.1.1
|
||||
SYSTEM ON # used in case of cmake v3.25
|
||||
OPTIONS "CXXOPTS_BUILD_EXAMPLES NO" "CXXOPTS_BUILD_TESTS NO" "CXXOPTS_ENABLE_INSTALL YES"
|
||||
)
|
||||
|
||||
|
@ -27,8 +37,22 @@ CPMAddPackage(
|
|||
file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${sources})
|
||||
if(CMAKE_DEBUG_POSTFIX)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||
endif()
|
||||
target_link_libraries(${PROJECT_NAME} Greeter::Greeter cxxopts::cxxopts)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ${OPTION_ENABLE_UNITY})
|
||||
|
||||
# TODO(CK): why is this needed?
|
||||
# TODO(CK): why is this used? This overrides the CMAKE_DEBUG_POSTFIX!
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME Greeter)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} Greeter::Greeter cxxopts::cxxopts)
|
||||
# --- Test it ---
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} --help)
|
||||
|
||||
# --- Install it ---
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} RUNTIME)
|
||||
|
||||
include(CPack)
|
||||
|
|
106
standalone/CMakePresets.json
Normal file
106
standalone/CMakePresets.json
Normal file
|
@ -0,0 +1,106 @@
|
|||
{
|
||||
"version": 6,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 23,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"displayName": "Default standalone Config",
|
||||
"description": "Default build using Ninja generator",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceParentDir}/build/standalone",
|
||||
"installDir": "${sourceParentDir}/stagedir",
|
||||
"cacheVariables": {
|
||||
"CMAKE_PREFIX_PATH": {
|
||||
"type": "path",
|
||||
"value": "${sourceParentDir}/stagedir"
|
||||
},
|
||||
"CMAKE_CXX_STANDARD": "20",
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_DEBUG_POSTFIX": "D",
|
||||
"CPM_USE_LOCAL_PACKAGES": "YES",
|
||||
"BUILD_SHARED_LIBS": "YES"
|
||||
},
|
||||
"environment": {
|
||||
"CPM_USE_LOCAL_PACKAGES": "YES",
|
||||
"PATH": "$env{HOME}/.local/bin${pathListSep}$penv{PATH}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ninja-multi",
|
||||
"inherits": "default",
|
||||
"displayName": "Ninja Multi-Config",
|
||||
"description": "Default build using Ninja Multi-Config generator",
|
||||
"generator": "Ninja Multi-Config"
|
||||
},
|
||||
{
|
||||
"name": "windows-only",
|
||||
"inherits": "default",
|
||||
"displayName": "Windows-only configuration",
|
||||
"description": "This build is only available on Windows",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default"
|
||||
},
|
||||
{
|
||||
"name": "install",
|
||||
"configurePreset": "default",
|
||||
"targets": ["install"]
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"output": {"outputOnFailure": true},
|
||||
"execution": {"noTestsAction": "error", "stopOnFailure": true}
|
||||
}
|
||||
],
|
||||
"packagePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"generators": [
|
||||
"TGZ"
|
||||
]
|
||||
}
|
||||
],
|
||||
"workflowPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "install"
|
||||
},
|
||||
{
|
||||
"type": "package",
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.14...3.27)
|
||||
cmake_minimum_required(VERSION 3.21...3.27)
|
||||
|
||||
project(GreeterTests LANGUAGES CXX)
|
||||
|
||||
|
|
94
test/CMakePresets.json
Normal file
94
test/CMakePresets.json
Normal file
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
"version": 6,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 23,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"displayName": "Default develop test Config",
|
||||
"description": "Default build using Ninja generator",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceParentDir}/build/test",
|
||||
"installDir": "${sourceParentDir}/stagedir",
|
||||
"cacheVariables": {
|
||||
"CMAKE_PREFIX_PATH": {
|
||||
"type": "path",
|
||||
"value": "${sourceParentDir}/stagedir"
|
||||
},
|
||||
"CMAKE_CXX_STANDARD": "20",
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_DEBUG_POSTFIX": "D",
|
||||
"CPM_USE_LOCAL_PACKAGES": "NO",
|
||||
"BUILD_SHARED_LIBS": "YES",
|
||||
"TEST_INSTALLED_VERSION": "YES"
|
||||
},
|
||||
"environment": {
|
||||
"CPM_USE_LOCAL_PACKAGES": "YES",
|
||||
"PATH": "$env{HOME}/.local/bin${pathListSep}$penv{PATH}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ninja-multi",
|
||||
"inherits": "default",
|
||||
"displayName": "Ninja Multi-Config",
|
||||
"description": "Default build using Ninja Multi-Config generator",
|
||||
"generator": "Ninja Multi-Config"
|
||||
},
|
||||
{
|
||||
"name": "windows-only",
|
||||
"inherits": "default",
|
||||
"displayName": "Windows-only configuration",
|
||||
"description": "This build is only available on Windows",
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"lhs": "${hostSystemName}",
|
||||
"rhs": "Windows"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default"
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"output": {"outputOnFailure": true},
|
||||
"execution": {"noTestsAction": "error", "stopOnFailure": true}
|
||||
}
|
||||
],
|
||||
"packagePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default",
|
||||
"generators": [
|
||||
"TGZ"
|
||||
]
|
||||
}
|
||||
],
|
||||
"workflowPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"steps": [
|
||||
{
|
||||
"type": "configure",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "build",
|
||||
"name": "default"
|
||||
},
|
||||
{
|
||||
"type": "test",
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue