diff --git a/.github/template/README.md b/.github/template/README.md index 989cade7..c7b5b7e4 100644 --- a/.github/template/README.md +++ b/.github/template/README.md @@ -4,10 +4,6 @@ [![codecov](https://codecov.io/gh/%%myorg%%/%%myproject%%/branch/main/graph/badge.svg)](https://codecov.io/gh/%%myorg%%/%%myproject%%) [![CodeQL](https://github.com/%%myorg%%/%%myproject%%/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/%%myorg%%/%%myproject%%/actions/workflows/codeql-analysis.yml) -LGTM Has to be set up manually after template is created: - -[![Language grade: C++](https://img.shields.io/lgtm/grade/cpp/github/%%myorg%%/%%myproject%%)](https://lgtm.com/projects/g/%%myorg%%/%%myproject%%/context:cpp) - ## About %%myproject%% %%description%% diff --git a/.github/workflows/template-janitor.yml b/.github/workflows/template-janitor.yml index 071ead0b..bc56ba05 100644 --- a/.github/workflows/template-janitor.yml +++ b/.github/workflows/template-janitor.yml @@ -7,10 +7,11 @@ on: release: types: [published] push: - tags: branches: - main - develop +permissions: + contents: write env: TEMPLATES_PATH: ".github/template" diff --git a/.gitignore b/.gitignore index a3f1df04..6eff7441 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Build directories and binary files build/ out/ +out/coverage/* cmake-build-*/ conan-cache/ @@ -15,6 +16,7 @@ CMakeUserPresets.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json +*.bak *.swp *~ _ReSharper* diff --git a/.lgtm.yml b/.lgtm.yml deleted file mode 100644 index 6b87f593..00000000 --- a/.lgtm.yml +++ /dev/null @@ -1,24 +0,0 @@ -# for full syntax documentation see: https://lgtm.com/help/lgtm/lgtm.yml-configuration-file -path_classifiers: - test: - - "*/fuzz_test/**/*" - - "*/test/**/*" -extraction: - cpp: - prepare: - packages: - - g++-10 - - ccache - script: - - mkdir ~/.conan - - cat /usr/local/share/ca-certificates/semmle-cache-ca/semmle-cache-ca.crt >> ~/.conan/cacert.pem - - python3 -m pip install --upgrade pip setuptools - - python3 -m pip install conan - - python3 -m pip install cmake - - source ~/.profile - configure: - command: - - mkdir build - - cmake -D OPT_ENABLE_COVERAGE:BOOL=TRUE -D CMAKE_BUILD_TYPE:STRING=Debug -D ENABLE_DEVELOPER_MODE:BOOL=FALSE -S . -B build - index: - build_command: cmake --build ./build -- -j2 diff --git a/Dependencies.cmake b/Dependencies.cmake index a84378d2..e286b59f 100644 --- a/Dependencies.cmake +++ b/Dependencies.cmake @@ -33,7 +33,7 @@ function(myproject_setup_dependencies) endif() if(NOT TARGET ftxui::screen) - cpmaddpackage("gh:ArthurSonzogni/FTXUI#e23dbc7473654024852ede60e2121276c5aab660") + cpmaddpackage("gh:ArthurSonzogni/FTXUI@5.0.0") endif() if(NOT TARGET tools::tools) diff --git a/ProjectOptions.cmake b/ProjectOptions.cmake index 2709aa1a..0b3dfdb1 100644 --- a/ProjectOptions.cmake +++ b/ProjectOptions.cmake @@ -132,7 +132,7 @@ macro(myproject_local_options) if(myproject_ENABLE_USER_LINKER) include(cmake/Linker.cmake) - configure_linker(myproject_options) + myproject_configure_linker(myproject_options) endif() include(cmake/Sanitizers.cmake) diff --git a/README.md b/README.md index bc766ae4..a860cb0b 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,10 @@ [![ci](https://github.com/cpp-best-practices/cmake_template/actions/workflows/ci.yml/badge.svg)](https://github.com/cpp-best-practices/cmake_template/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/cpp-best-practices/cmake_template/branch/main/graph/badge.svg)](https://codecov.io/gh/cpp-best-practices/cmake_template) -[![Language grade: C++](https://img.shields.io/lgtm/grade/cpp/github/cpp-best-practices/cmake_template)](https://lgtm.com/projects/g/cpp-best-practices/cmake_template/context:cpp) [![CodeQL](https://github.com/cpp-best-practices/cmake_template/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/cpp-best-practices/cmake_template/actions/workflows/codeql-analysis.yml) ## About cmake_template -**NOTE** This is undergoing a major overhaul on a new branch currently. - - This is a C++ Best Practices GitHub template for getting up and running with C++ quickly. By default (collectively known as `ENABLE_DEVELOPER_MODE`) @@ -23,7 +19,7 @@ It includes * a basic CLI example * examples for fuzz, unit, and constexpr testing - * large github action testing matrix + * large GitHub action testing matrix It requires @@ -36,15 +32,16 @@ This project gets you started with a simple example of using FTXUI, which happen ## Getting Started -### Use the Github template +### Use the GitHub template First, click the green `Use this template` button near the top of this page. -This will take you to Github's ['Generate Repository'](https://github.com/cpp-best-practices/cmake_template/generate) page. +This will take you to GitHub's ['Generate Repository'](https://github.com/cpp-best-practices/cmake_template/generate) +page. Fill in a repository name and short description, and click 'Create repository from template'. -This will allow you to create a new repository in your Github account, +This will allow you to create a new repository in your GitHub account, prepopulated with the contents of this project. After creating the project please wait until the cleanup workflow has finished -setting up your project and commited the changes. +setting up your project and committed the changes. Now you can clone the project locally and get to work! @@ -54,7 +51,6 @@ Now you can clone the project locally and get to work! * [Dependency Setup](README_dependencies.md) * [Building Details](README_building.md) - * [Troubleshooting](README_troubleshooting.md) * [Docker](README_docker.md) ## Testing diff --git a/README_dependencies.md b/README_dependencies.md index 42e4dab0..b0ea2c4c 100644 --- a/README_dependencies.md +++ b/README_dependencies.md @@ -2,7 +2,7 @@ Note about install commands: - for Windows, we use [choco](https://chocolatey.org/install). -- for MacOS, we use [brew](https://brew.sh/). +- for macOS, we use [brew](https://brew.sh/). - In case of an error in cmake, make sure that the dependencies are on the PATH. @@ -11,7 +11,7 @@ Note about install commands: This is a really long list of dependencies, and it's easy to mess up. That's why: #### Docker -We have a Docker image that's already set up for you. See the [Docker instructions](#docker-instructions). +We have a Docker image that's already set up for you. See the [Docker instructions](./README_docker.md). #### Setup-cpp @@ -103,7 +103,7 @@ The following compilers should work: -2. [CMake 3.15+](https://cmake.org/) +2. [CMake 3.21+](https://cmake.org/)
Install Command diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index 109297b3..281ea1b2 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -13,7 +13,7 @@ function( if("${MSVC_WARNINGS}" STREQUAL "") set(MSVC_WARNINGS /W4 # Baseline reasonable warnings - /w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data + /w14242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data /w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data /w14263 # 'function': member function does not override any base class virtual member function /w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not @@ -30,7 +30,7 @@ function( /w14555 # expression has no effect; expected expression with side- effect /w14619 # pragma warning: there is no warning number 'number' /w14640 # Enable warning on thread un-safe static member initialization - /w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior. + /w14826 # Conversion from 'type1' to 'type2' is sign-extended. This may cause unexpected runtime behavior. /w14905 # wide string literal cast to 'LPSTR' /w14906 # string literal cast to 'LPWSTR' /w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied @@ -67,6 +67,7 @@ function( -Wduplicated-branches # warn if if / else branches have duplicated code -Wlogical-op # warn about logical operations being used where bitwise were probably wanted -Wuseless-cast # warn if you perform a cast to the same type + -Wsuggest-override # warn if an overridden member function is not marked 'override' or 'final' ) endif() diff --git a/cmake/Cuda.cmake b/cmake/Cuda.cmake index d784a882..f6265aea 100644 --- a/cmake/Cuda.cmake +++ b/cmake/Cuda.cmake @@ -42,7 +42,7 @@ macro(myproject_target_link_cuda target) if(WIN32 AND "$ENV{VSCMD_VER}" STREQUAL "") message( WARNING - "Compiling Cuda on Windows outside the Visual Studio Commant prompt or without running `vcvarsall.bat x64` probably fails" + "Compiling CUDA on Windows outside the Visual Studio Command prompt or without running `vcvarsall.bat x64` probably fails" ) endif() endmacro() diff --git a/cmake/Linker.cmake b/cmake/Linker.cmake index 067aac68..c1c19ebe 100644 --- a/cmake/Linker.cmake +++ b/cmake/Linker.cmake @@ -18,7 +18,7 @@ macro(myproject_configure_linker project_name) "Using custom linker: '${USER_LINKER_OPTION}', explicitly supported entries are ${USER_LINKER_OPTION_VALUES}") endif() - if(NOT ENABLE_USER_LINKER) + if(NOT myproject_ENABLE_USER_LINKER) return() endif() diff --git a/cmake/StaticAnalyzers.cmake b/cmake/StaticAnalyzers.cmake index eb3674e0..904aff29 100644 --- a/cmake/StaticAnalyzers.cmake +++ b/cmake/StaticAnalyzers.cmake @@ -11,6 +11,8 @@ macro(myproject_enable_cppcheck WARNINGS_AS_ERRORS CPPCHECK_OPTIONS) if("${CPPCHECK_OPTIONS}" STREQUAL "") # Enable all warnings that are actionable by the user of this toolset # style should enable the other 3, but we'll be explicit just in case + set(SUPPRESS_DIR "*:${CMAKE_CURRENT_BINARY_DIR}/_deps/*.h") + message(STATUS "CPPCHECK_OPTIONS suppress: ${SUPPRESS_DIR}") set(CMAKE_CXX_CPPCHECK ${CPPCHECK} --template=${CPPCHECK_TEMPLATE} @@ -26,7 +28,8 @@ macro(myproject_enable_cppcheck WARNINGS_AS_ERRORS CPPCHECK_OPTIONS) # ignores code that cppcheck thinks is invalid C++ --suppress=syntaxError --suppress=preprocessorErrorDirective - --inconclusive) + --inconclusive + --suppress=${SUPPRESS_DIR}) else() # if the user provides a CPPCHECK_OPTIONS with a template specified, it will override this template set(CMAKE_CXX_CPPCHECK ${CPPCHECK} --template=${CPPCHECK_TEMPLATE} ${CPPCHECK_OPTIONS}) diff --git a/cmake/Utilities.cmake b/cmake/Utilities.cmake index 6fa78b28..e278f518 100644 --- a/cmake/Utilities.cmake +++ b/cmake/Utilities.cmake @@ -1,4 +1,4 @@ -# find a subtring from a string by a given prefix such as VCVARSALL_ENV_START +# find a substring from a string by a given prefix such as VCVARSALL_ENV_START function( find_substring_by_prefix output diff --git a/cmake/VCEnvironment.cmake b/cmake/VCEnvironment.cmake index a95cb467..2ed4d582 100644 --- a/cmake/VCEnvironment.cmake +++ b/cmake/VCEnvironment.cmake @@ -19,7 +19,7 @@ macro(detect_architecture) set(VCVARSALL_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR}) else() set(VCVARSALL_ARCH x64) - message(STATUS "Unkown architecture CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR_LOWER} - using x64") + message(STATUS "Unknown architecture CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR_LOWER} - using x64") endif() endif() endmacro() diff --git a/gcovr.cfg b/gcovr.cfg new file mode 100644 index 00000000..d248e096 --- /dev/null +++ b/gcovr.cfg @@ -0,0 +1,20 @@ +root = . +search-path = out + +filter = src/* +filter = include/* + +exclude-directories = install +exclude-directories = out/*/*/_deps +exclude-directories = test +exclude-directories = fuzz_test + +gcov-ignore-parse-errors = yes +print-summary = yes + +html-details = ./out/coverage/index.html + +cobertura-pretty = yes +cobertura = out/cobertura.xml + +#TBD delete-gcov-files = yes diff --git a/out/coverage/.keep b/out/coverage/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0739f424..50f8e633 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,7 +10,7 @@ if(PROJECT_IS_TOP_LEVEL OR TEST_INSTALLED_VERSION) find_package(myproject CONFIG REQUIRED) # for intro, project_options, ... if(NOT TARGET myproject_options) - message(FATAL_ERROR "Requiered config package not found!") + message(FATAL_ERROR "Required config package not found!") return() # be strictly paranoid for Template Janitor github action! CK endif() endif()