Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c96cd54
Add support for macOS X host to CMakePresets.json
Mar 28, 2022
0f36bfe
Shared presets for Unix-like OSes.
Mar 29, 2022
f37c1ab
Merge pull request #16 from oskidan/main
lefticus Apr 1, 2022
e51378d
upgrade to project_options v0.20.0
ClausKlein Apr 3, 2022
e95411b
Use an unsafe porject name in janitor for testing
LtdSauce Apr 3, 2022
05e8d93
Always use env variable for project name
LtdSauce Apr 3, 2022
f159cac
fix CI tests
ClausKlein Apr 3, 2022
9a5cb52
Add valid c++ identifier project name variable and use it
LtdSauce Apr 3, 2022
a919c66
Build the project during janitor to catch bugs
LtdSauce Apr 3, 2022
9203a2e
be strictly paranoid for Template Janitor github action!
ClausKlein Apr 3, 2022
c77d33f
Merge pull request #32 from LtdSauce/main
lefticus Apr 13, 2022
1586c65
Merge pull request #29 from ClausKlein/feature/modernize-cmake-projec…
lefticus Apr 13, 2022
f1dd7e0
Merge remote-tracking branch 'origin/main' into develop
lefticus Apr 13, 2022
f3937e6
Make sure tests have project names updated also by janitor
lefticus Apr 13, 2022
93968c5
Updates setup-cpp and adds missing tools
euripedesrocha Apr 14, 2022
333cadc
Merge pull request #36 from euripedesrocha/main
lefticus Apr 27, 2022
cde2c06
Merge pull request #35 from cpp-best-practices/develop
lefticus Apr 27, 2022
43842e9
Update README.md
lefticus Apr 27, 2022
235115d
Change Project Name - Update Dependencies
lefticus Apr 27, 2022
948679f
Disable difficult/unhelpful CppCheck warnings
lefticus Apr 27, 2022
cb63956
Change Template Name
Apr 27, 2022
e349691
Merge branch 'main' into develop
lefticus Apr 27, 2022
d1d60d3
Merge branch 'main' of github.com:cpp-best-practices/ftxui_template i…
lefticus Apr 27, 2022
3802856
Merge branch 'develop' of github.com:cpp-best-practices/ftxui_templat…
lefticus Apr 27, 2022
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
18 changes: 14 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
CONAN_SYSREQUIRES_MODE: enabled
CONAN_USER_HOME: "${{ github.workspace }}/conan-cache"
CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan-cache/short"
CLANG_TIDY_VERSION: "13.0.0"

jobs:
Test:
Expand Down Expand Up @@ -72,21 +73,25 @@ jobs:
gcov_executable: gcov
developer_mode: On

# Windows msvc builds
- os: windows-2022
compiler: msvc
generator: "Visual Studio 17 2022"
build_type: Debug
developer_mode: On

- os: windows-2022
compiler: msvc
generator: "Visual Studio 17 2022"
build_type: Release
developer_mode: On

- os: windows-2022
compiler: msvc
generator: "Visual Studio 17 2022"
build_type: Debug
developer_mode: Off

- os: windows-2022
compiler: msvc
generator: "Visual Studio 17 2022"
Expand All @@ -95,10 +100,14 @@ jobs:
package_generator: ZIP





steps:
- name: Check for llvm version mismatches
if: ${{ contains(matrix.compiler, 'llvm') && !contains(matrix.compiler, env.CLANG_TIDY_VERSION) }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('There is a mismatch between configured llvm compiler and clang-tidy version chosen')

- uses: actions/checkout@v2

- name: Setup Cache
Expand All @@ -120,7 +129,8 @@ jobs:
conan: true
vcpkg: false
ccache: true
clangtidy: true
clangtidy: ${{ env.CLANG_TIDY_VERSION }}


cppcheck: true

Expand Down
17 changes: 15 additions & 2 deletions .github/workflows/template-janitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,23 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Use testing variables if still a template
if: fromJson(steps.get_repo_meta.outputs.data).is_template == true
run: |
# This name is unsafe because it is not a valid C++ identifier
echo "NEW_PROJECT=my-unsafe.project" >> $GITHUB_ENV

- name: Add safe replacement variable versions
run: |
# hyphens and dots in c++ identifiers are forbidden. Use underscores instead.
NEW_SAFE_PROJECT=$(echo ${{ env.NEW_PROJECT }} | sed "s/-/_/g" | sed "s/\./_/g" )
echo "NEW_SAFE_PROJECT=$NEW_SAFE_PROJECT" >> $GITHUB_ENV

# Rename all cpp_starter_project occurences to current repository and remove this workflow
- name: Insert new org and project
run: |
# rename the CMake project to match the github project
sed -i "s/myproject/${{ github.event.repository.name }}/gi" CMakeLists.txt configured_files/config.hpp.in src/main.cpp
sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" CMakeLists.txt configured_files/config.hpp.in src/main.cpp test/CMakeLists.txt fuzz_test/CMakeLists.txt

# Update URL placeholders for project
sed -i "s|%%myurl%%|${{ fromJson(steps.get_repo_meta.outputs.data).html_url }}|gi" CMakeLists.txt
Expand Down Expand Up @@ -120,7 +132,8 @@ jobs:
- name: Test simple configuration to make sure nothing broke
run: |
cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -DENABLE_DEVELOPER_MODE:BOOL=${{ matrix.developer_mode }} -DOPT_ENABLE_COVERAGE:BOOL=OFF

# Build it because we may have broken something in the cpp/hpp files
cmake --build build

- uses: EndBug/add-and-commit@v4
# only commit and push if we are not a template project anymore!
Expand Down
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ stages:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F

.setup_cpp: &setup_cpp |
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.5.8/setup_cpp_linux"
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.10.0/setup_cpp_linux"
chmod +x setup_cpp_linux
./setup_cpp_linux --compiler $compiler --cmake true --ninja true --conan true --ccache true
./setup_cpp_linux --compiler $compiler --cmake true --ninja true --conan true --ccache true --clangtidy true --clangformat true --cppcheck true
source ~/.profile

.test: &test |
Expand All @@ -46,4 +46,4 @@ test_linux_gcc:
script:
- *setup_linux
- *setup_cpp
- *test
- *test
57 changes: 46 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.16...3.23)

# Not ideal to use this global variable, but necessary to make sure
# that tooling and projects use the same version
Expand All @@ -22,10 +22,10 @@ set(ENABLE_DEVELOPER_MODE
# Change this to false if you want to disable warnings_as_errors in developer mode
set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT TRUE)

# Add project_options v0.17.0
# Add project_options v0.20.0
# https://github.com/cpp-best-practices/project_options
FetchContent_Declare(_project_options
URL https://github.com/cpp-best-practices/project_options/archive/refs/tags/v0.17.0.zip)
include(FetchContent)
FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.20.0.zip)
FetchContent_MakeAvailable(_project_options)
include(${_project_options_SOURCE_DIR}/Index.cmake)

Expand All @@ -41,6 +41,18 @@ project(
HOMEPAGE_URL "%%myurl%%"
LANGUAGES CXX C)

# This variable is set by project() in CMake 3.21+
string(
COMPARE EQUAL
"${CMAKE_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}"
PROJECT_IS_TOP_LEVEL)
if(PROJECT_IS_TOP_LEVEL)
# Consider the CTest module, which creates targets and options!
# Only needed if you want to enable submissions to a CDash server.
include(CTest)
endif()

set(GIT_SHA
"Unknown"
CACHE STRING "SHA this build was generated from")
Expand Down Expand Up @@ -93,14 +105,28 @@ dynamic_project_options(
PCH_HEADERS
<vector>
<string> # This is a list of headers to pre-compile, here are some common ones
ENABLE_CONAN
# CONAN_OPTIONS # Extra options to pass to conan
# MSVC_WARNINGS # Override the defaults for the MSVC warnings
# CLANG_WARNINGS # Override the defaults for the CLANG warnings
# GCC_WARNINGS # Override the defaults for the GCC warnings
# CPPCHECK_OPTIONS # Override the defaults for CppCheck
CPPCHECK_OPTIONS
--enable=style,performance,warning,portability
--inline-suppr
# We cannot act on a bug/missing feature of cppcheck
--suppress=cppcheckError
--suppress=internalAstError
# if a file does not have an internalAstError, we get an unmatchedSuppression error
--suppress=unmatchedSuppression
--suppress=passedByValue
--suppress=syntaxError
--inconclusive
)

target_compile_features(project_options INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
# TODO: The INTERFACE library NAMESPACE ALIAS are missing! CK
add_library(myproject::project_options INTERFACE IMPORTED)
add_library(myproject::project_warnings INTERFACE IMPORTED)

# configure files based on CMake configuration options
add_subdirectory(configured_files)
Expand All @@ -109,33 +135,42 @@ add_subdirectory(configured_files)
add_subdirectory(src)

# Adding the tests:
option(ENABLE_TESTING "Enable the tests" ON)
option(ENABLE_TESTING "Enable the tests" ${PROJECT_IS_TOP_LEVEL})
if(ENABLE_TESTING)
enable_testing()
message("Building Tests. Be sure to check out test/constexpr_tests for constexpr
testing")
message(AUTHOR_WARNING "Building Tests. Be sure to check out test/constexpr_tests.cpp for constexpr testing")
add_subdirectory(test)
endif()

option(ENABLE_FUZZING "Enable the fuzz tests" OFF)
if(ENABLE_FUZZING)
message("Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html")
message(AUTHOR_WARNING "Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html")
add_subdirectory(fuzz_test)
endif()

# If MSVC is being used, and ASAN is enabled, we need to set the debugger environment
# so that it behaves well with MSVC's debugger, and we can run the target from visual studio
if(MSVC)
get_all_targets(all_targets)
get_all_installable_targets(all_targets)
message("all_targets=${all_targets}")
set_target_properties(${all_targets} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=$(VC_ExecutablePath_x64);%PATH%")
endif()

# set the startup project for the "play" button in MSVC
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT intro)

if(CMAKE_SKIP_INSTALL_RULES)
return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
return()
endif()

# Add other targets that you want installed here, be default we just package the one executable
# we know we want to ship
package_project(TARGETS intro)
package_project(TARGETS intro project_options project_warnings
# FIXME: this does not work! CK
# PRIVATE_DEPENDENCIES_CONFIGURED project_options project_warnings
)

# Experience shows that explicit package naming can help make it easier to sort
# out potential ABI related issues before they start, while helping you
Expand Down
61 changes: 32 additions & 29 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@
}
},
{
"name": "conf-linux-common",
"description": "Linux settings for gcc and clang toolchains",
"name": "conf-unixlike-common",
"description": "Unix-like OS settings for gcc and clang toolchains",
"hidden": true,
"inherits": "conf-common",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
"type": "inList",
"string": "${hostSystemName}",
"list": [
"Linux",
"Darwin"
]
},
"vendor": {
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
Expand Down Expand Up @@ -75,7 +78,7 @@
"CMAKE_CXX_COMPILER": "cl",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"ENABLE_DEVELOPER_MODE": "ON"
}
}
},
{
"name": "windows-msvc-debug-user-mode",
Expand All @@ -87,7 +90,7 @@
"CMAKE_CXX_COMPILER": "cl",
"CMAKE_BUILD_TYPE": "Debug",
"ENABLE_DEVELOPER_MODE": "OFF"
}
}
},
{
"name": "windows-msvc-release-user-mode",
Expand All @@ -99,7 +102,7 @@
"CMAKE_CXX_COMPILER": "cl",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"ENABLE_DEVELOPER_MODE": "OFF"
}
}
},
{
"name": "windows-clang-debug",
Expand Down Expand Up @@ -134,43 +137,43 @@
}
},
{
"name": "linux-gcc-debug",
"name": "unixlike-gcc-debug",
"displayName": "gcc Debug",
"description": "Target Linux with the gcc compiler, debug build type",
"inherits": "conf-linux-common",
"description": "Target Unix-like OS with the gcc compiler, debug build type",
"inherits": "conf-unixlike-common",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "linux-gcc-release",
"name": "unixlike-gcc-release",
"displayName": "gcc Release",
"description": "Target Linux with the gcc compiler, release build type",
"inherits": "conf-linux-common",
"description": "Target Unix-like OS with the gcc compiler, release build type",
"inherits": "conf-unixlike-common",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "linux-clang-debug",
"name": "unixlike-clang-debug",
"displayName": "clang Debug",
"description": "Target Linux with the clang compiler, debug build type",
"inherits": "conf-linux-common",
"description": "Target Unix-like OS with the clang compiler, debug build type",
"inherits": "conf-unixlike-common",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "linux-clang-release",
"name": "unixlike-clang-release",
"displayName": "clang Release",
"description": "Target Linux with the clang compiler, release build type",
"inherits": "conf-linux-common",
"description": "Target Unix-like OS with the clang compiler, release build type",
"inherits": "conf-unixlike-common",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
Expand Down Expand Up @@ -220,32 +223,32 @@
"configurePreset": "windows-clang-release"
},
{
"name": "test-linux-gcc-debug",
"name": "test-unixlike-gcc-debug",
"displayName": "Strict",
"description": "Enable output and stop on failure",
"inherits": "test-common",
"configurePreset": "linux-gcc-debug"
"configurePreset": "unixlike-gcc-debug"
},
{
"name": "test-linux-gcc-release",
"name": "test-unixlike-gcc-release",
"displayName": "Strict",
"description": "Enable output and stop on failure",
"inherits": "test-common",
"configurePreset": "linux-gcc-release"
"configurePreset": "unixlike-gcc-release"
},
{
"name": "test-linux-clang-debug",
"name": "test-unixlike-clang-debug",
"displayName": "Strict",
"description": "Enable output and stop on failure",
"inherits": "test-common",
"configurePreset": "linux-clang-debug"
"configurePreset": "unixlike-clang-debug"
},
{
"name": "test-linux-clang-release",
"name": "test-unixlike-clang-release",
"displayName": "Strict",
"description": "Enable output and stop on failure",
"inherits": "test-common",
"configurePreset": "linux-clang-release"
"configurePreset": "unixlike-clang-release"
}
]
}
}
7 changes: 3 additions & 4 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Docs at https://docs.conan.io/en/latest/reference/conanfile_txt.html

[requires]
catch2/2.13.8
docopt.cpp/0.6.3
#fmt/8.1.1
spdlog/1.9.2
catch2/2.13.9
cli11/2.2.0
spdlog/1.10.0
ftxui/2.0.0

[generators]
Expand Down
Loading