diff --git a/.github/workflows/cmake-linux-pack-nost.yml b/.github/workflows/cmake-linux-pack-nost.yml index d9ad7b5..0aa17ca 100644 --- a/.github/workflows/cmake-linux-pack-nost.yml +++ b/.github/workflows/cmake-linux-pack-nost.yml @@ -59,6 +59,7 @@ jobs: - name: Pack working-directory: ${{ steps.strings.outputs.build-output-dir }} run: | + cpack -G TXZ cpack -G DEB cpack -G RPM diff --git a/.github/workflows/cmake-linux-pack-st.yml b/.github/workflows/cmake-linux-pack-st.yml index d0998ea..3715090 100644 --- a/.github/workflows/cmake-linux-pack-st.yml +++ b/.github/workflows/cmake-linux-pack-st.yml @@ -60,6 +60,7 @@ jobs: - name: Pack working-directory: ${{ steps.strings.outputs.build-output-dir }} run: | + cpack -G TXZ cpack -G DEB cpack -G RPM diff --git a/.github/workflows/cmake-multi-platform-st.yml b/.github/workflows/cmake-multi-platform-st.yml index 489bcb2..ae70bf8 100644 --- a/.github/workflows/cmake-multi-platform-st.yml +++ b/.github/workflows/cmake-multi-platform-st.yml @@ -74,6 +74,7 @@ jobs: run: | cpack --config CPackConfig.cmake -C ${{ matrix.build_type }} cpack --config CPackConfig.cmake -C ${{ matrix.build_type }} -G ZIP + cpack --config CPackConfig.cmake -C ${{ matrix.build_type }} -G 7Z - name: 'Artifact Storage' uses: actions/upload-artifact@v4 diff --git a/.github/workflows/cmake-static-analysis.yml b/.github/workflows/cmake-static-analysis.yml index 5df1015..408b296 100644 --- a/.github/workflows/cmake-static-analysis.yml +++ b/.github/workflows/cmake-static-analysis.yml @@ -18,16 +18,15 @@ jobs: steps: - uses: actions/checkout@v4 - - - name: Run static analysis - uses: JacobDomagala/StaticAnalysis@master + - name: Static analysis for C++(Clang-19)/Python project + uses: eljonny/StaticAnalysis@clang-19 with: language: c++ - # Exclude any issues found in ${Project_root_dir}/lib - exclude_dir: lib + # Exclude any issues found in ${Project_root_dir}/3rdparty + exclude_dir: 3rdparty use_cmake: true cmake_args: -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -Wno-dev - cppcheck_args: --enable=all --suppress=missingIncludeSystem --suppress=unusedFunction --std=c++11 --inline-suppr + cppcheck_args: --quiet --enable=all --inconclusive --suppress=missingIncludeSystem --suppress=unusedFunction --suppress=checkersReport --suppress='*:3rdparty/*' --std=c++11 --inline-suppr --force --check-level=exhaustive diff --git a/.github/workflows/cmake-windows-pack-nost.yml b/.github/workflows/cmake-windows-pack-nost.yml new file mode 100644 index 0000000..b150bca --- /dev/null +++ b/.github/workflows/cmake-windows-pack-nost.yml @@ -0,0 +1,66 @@ +name: TestCPP CMake WIX Pack - No Stacktraces + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + # Set up a matrix to run the following 3 configurations: + # 1. + # 2. + # 3. + # + # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. + matrix: + os: [windows-latest] + build_type: [Release, Debug] + c_compiler: [cl] + include: + - os: windows-latest + c_compiler: cl + cpp_compiler: cl + + steps: + - uses: actions/checkout@v4 + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -S ${{ github.workspace }} + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Pack + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: | + cpack -G WIX -C ${{ matrix.build_type }} + + - name: 'Artifact Storage' + uses: actions/upload-artifact@v4 + with: + name: linux-packages-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }} + path: ${{ github.workspace }}/_packages/** + overwrite: true diff --git a/.github/workflows/cmake-windows-pack-st.yml b/.github/workflows/cmake-windows-pack-st.yml new file mode 100644 index 0000000..6148184 --- /dev/null +++ b/.github/workflows/cmake-windows-pack-st.yml @@ -0,0 +1,67 @@ +name: TestCPP CMake WIX Pack + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + # Set up a matrix to run the following 3 configurations: + # 1. + # 2. + # 3. + # + # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. + matrix: + os: [windows-latest] + build_type: [Release, Debug] + c_compiler: [cl] + include: + - os: windows-latest + c_compiler: cl + cpp_compiler: cl + + steps: + - uses: actions/checkout@v4 + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: > + cmake -B ${{ steps.strings.outputs.build-output-dir }} + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} + -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DTESTCPP_STACKTRACE_ENABLED=1 + -S ${{ github.workspace }} + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Pack + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: | + cpack -G WIX -C ${{ matrix.build_type }} + + - name: 'Artifact Storage' + uses: actions/upload-artifact@v4 + with: + name: linux-packages-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }} + path: ${{ github.workspace }}/_packages/** + overwrite: true diff --git a/LICENSE.rtf b/LICENSE.rtf new file mode 100644 index 0000000..c6d5184 --- /dev/null +++ b/LICENSE.rtf @@ -0,0 +1,62 @@ +{\rtf1\ansi\deff3\adeflang1025 +{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Liberation Serif{\*\falt Times New Roman};}{\f4\fswiss\fprq2\fcharset0 Liberation Sans{\*\falt Arial};}{\f5\fnil\fprq2\fcharset0 Cascadia Mono;}{\f6\fnil\fprq2\fcharset0 Microsoft YaHei;}{\f7\fnil\fprq2\fcharset0 Lucida Sans;}{\f8\fswiss\fprq0\fcharset128 Lucida Sans;}} +{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;\red0\green136\blue0;\red163\green21\blue21;} +{\stylesheet{\s0\snext0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052 Normal;} +{\s15\sbasedon0\snext16\rtlch\af7\afs28 \ltrch\hich\af4\loch\sb240\sa120\keepn\f4\fs28\dbch\af6 Heading;} +{\s16\sbasedon0\snext16\loch\sl276\slmult1\sb0\sa140 Body Text;} +{\s17\sbasedon16\snext17\rtlch\af8 \ltrch\loch\sl276\slmult1\sb0\sa140 List;} +{\s18\sbasedon0\snext18\rtlch\af8\afs24\ai \ltrch\loch\sb120\sa120\noline\fs24\i caption;} +{\s19\sbasedon0\snext19\rtlch\af8 \ltrch\loch\noline Index;} +}{\*\generator LibreOffice/24.8.4.2$Windows_X86_64 LibreOffice_project/bb3cfa12c7b1bf994ecc5649a80400d06cd71002}{\info{\creatim\yr0\mo0\dy0\hr0\min0}{\revtim\yr2025\mo2\dy17\hr14\min55}{\printim\yr0\mo0\dy0\hr0\min0}}{\*\userprops}\deftab709 +\hyphauto1\viewscale140\formshade\paperh15840\paperw12240\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\sftnnar\saftnnrlc\sectunlocked1\pgwsxn12240\pghsxn15840\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\fet\aftnrstcont\aftnstart1\aftnnrlc +{\*\ftnsep\chftnsep}\pgndec\pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +This is free and unencumbered software released into the public domain.} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar\hich\af5\loch\cf1\fs19\highlight8\f5\loch + +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +Anyone is free to copy, modify, publish, use, compile, sell, or} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +distribute this software, either in source code form or as a compiled} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +binary, for any purpose, commercial or non-commercial, and by any} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +means.} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar\hich\af5\loch\cf1\fs19\highlight8\f5\loch + +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +In jurisdictions that recognize copyright laws, the author or authors} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +of this software dedicate any and all copyright interest in the} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +software to the public domain. We make this dedication for the benefit} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +of the public at large and to the detriment of our heirs and} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +successors. We intend this dedication to be an overt act of} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +relinquishment in perpetuity of all present and future rights to this} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +software under copyright law.} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar\hich\af5\loch\cf1\fs19\highlight8\f5\loch + +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +OTHER DEALINGS IN THE SOFTWARE.} +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar\hich\af5\loch\cf1\fs19\highlight8\f5\loch + +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar{\hich\af5\loch\cf1\fs19\highlight8\f5\loch +For more information, please refer to } +\par \pard\plain \s0\rtlch\af7\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af9\langfe2052\ql\ltrpar\loch + +\par } \ No newline at end of file diff --git a/README.md b/README.md index 4c2acd3..01969c8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ [![Test-NoStacktraces](https://github.com/eljonny/TestCPP/actions/workflows/cmake-build-test-nost.yml/badge.svg?event=push)](https://github.com/eljonny/TestCPP/actions/workflows/cmake-build-test-nost.yml) [![RPM_DEB-Packaging-WithStacktraces](https://github.com/eljonny/TestCPP/actions/workflows/cmake-linux-pack-st.yml/badge.svg?event=push)](https://github.com/eljonny/TestCPP/actions/workflows/cmake-linux-pack-st.yml) [![RPM_DEB-Packaging-NoStacktraces](https://github.com/eljonny/TestCPP/actions/workflows/cmake-linux-pack-nost.yml/badge.svg?event=push)](https://github.com/eljonny/TestCPP/actions/workflows/cmake-linux-pack-nost.yml) +[![WIX-Packaging-WithStacktraces](https://github.com/eljonny/TestCPP/actions/workflows/cmake-windows-pack-st.yml/badge.svg?event=push)](https://github.com/eljonny/TestCPP/actions/workflows/cmake-windows-pack-st.yml) +[![WIX-Packaging-NoStacktraces](https://github.com/eljonny/TestCPP/actions/workflows/cmake-windows-pack-nost.yml/badge.svg?event=push)](https://github.com/eljonny/TestCPP/actions/workflows/cmake-windows-pack-nost.yml) [![Coverage](https://github.com/eljonny/TestCPP/actions/workflows/cmake-build-cov-st.yml/badge.svg?event=push)](https://github.com/eljonny/TestCPP/actions/workflows/cmake-build-cov-st.yml) [![Security](https://github.com/eljonny/TestCPP/actions/workflows/codeql.yml/badge.svg?event=push)](https://github.com/eljonny/TestCPP/actions/workflows/codeql.yml) [![StaticAnalysis](https://github.com/eljonny/TestCPP/actions/workflows/cmake-static-analysis.yml/badge.svg?event=push)](https://github.com/eljonny/TestCPP/actions/workflows/cmake-static-analysis.yml) @@ -14,8 +16,8 @@ This is an implementation of a very simple test framework. It can be built with no dependencies (other than the C++ standard library) and can rely on only C++11 features. -It supports stack traces on test failures as of 0.2.1-beta.3, which uses - Boost.StackTrace, but this is not required to use the framework. +It supports stack traces on test failures as of 0.2.1-beta.3, which + uses Boost.StackTrace, but this is not required to use the framework. The library is most useful for educational projects or small personal/internal projects, as many features required for @@ -211,12 +213,66 @@ In the Custom Targets... context menu option there are also, depending causes the library to have link-time dependencies as explained in other elements of this README. +## Building in Visual Studio + +I have been able to successfully configure and build the project in + [Visual Studio 2022 Community](https://visualstudio.microsoft.com/vs/community/) + using the built-in CMake project integration, so this does work if you + would like to proceed this way. + +There are a number of CMake Presets defined in CMakePresets.json that + align with different build configurations and analysis profiles, + including all build feature variations (with/without the Demo project, + with/without the tests, and subsequently with/without stacktrace + support via Boost.StackTrace). + +To get started, open the root project folder in Visual Studio 2022 and + select the desired CMake Preset from the Build Configurations dropdown + which will be populated with all applicable buildPresets once the + project has fully loaded. Visual Studio automatically detects the + presence of the CMakePresets.json and CMakeLists.txt files and will + configure the project with the lexicographically-first build preset. +Subsequently, you can build the project from the Build menu or by + pressing F7 after successful configuration. + ## CMake build structure and variables The CMake build is split into components that get included into the main build file to make modifying each piece more logical and manageable. +The top-level components are as follows: +- CMake Build File: + The main build file that includes all the other components + (CMakeLists.txt). +- Code Analysis: + Configuring code analysis tools (Analysis.cmake). + Currently, this includes clang-tidy in the build process. + - CPPCheck is also included in the build process, but it is + not included in the Analysis.cmake file because it is + run as part of the static analysis GitHub Action (see + .github/workflows/cmake-static-analysis.yml). +- Build Type Handling: + Handling the build type which sets compile options for the platform + on which the build is being run based on the build type (Debug, + Release, I still need to work on getting RelWithDebugInfo + configured properly) (BuildTypeHandling.cmake). +- Target Includes: + Which includes should be applied to which targets (Includes.cmake). +- Installing: + Configuring installation of the library (Installing.cmake). +- Target Link Libraries: + Which libraries need to be linked in which build targets, based on + the result of VarChecks in terms of code coverage (Linking.cmake). +- Packaging: + Configuring library packaging parameters, enable CPack + (Packing.cmake). +- Build Targets Configuration: + Setting up the build targets (Targets.cmake). + Lists each translation unit that applies to each target. +- Testing: + Testing configuration, based on the result of VarChecks + (Testing.cmake). - Variable Checks: Checking the variables to enable or disable certain sections of the build (VarChecks.cmake). @@ -260,38 +316,62 @@ The CMake build is split into components that get included into the - dbgeng - Non-Windows - libdl -- Build Targets Configuration: - Setting up the build targets (Targets.cmake). - Lists each translation unit that applies to each target. -- Build Type Handling: - Handling the build type which sets compile options for the platform - on which the build is being run based on the build type (Debug, - Release, I still need to work on getting RelWithDebugInfo - configured properly) (BuildTypeHandling.cmake). -- Target Includes: - Which includes should be applied to which targets (Includes.cmake). -- Target Link Libraries: - Which libraries need to be linked in which build targets, based on - the result of VarChecks in terms of code coverage (Linking.cmake). -- Testing: - Testing configuration, based on the result of VarChecks - (Testing.cmake). -- Installing: - Configuring installation of the library (Installing.cmake). -- Packaging: - Configuring library packaging parameters, enable CPack - (Packing.cmake). + +There are a number of CMake modules in the cmake directory, including + the following: +- Build definitions: + - CompileDefs.cmake + Defines compile definitions for all configurations of the project. + - DebugCompileDefs.cmake + Defines compile definitions specific to the Debug configuration of + the project. + - GCCClangDebug.cmake + Defines compiler flags specific to the Debug configuration of the + project when building with GCC or Clang. + - GCCClangRelease.cmake + Defines compiler flags specific to the Release configuration of the + project when building with GCC or Clang. + - GCCCoverage.cmake + Defines compiler flags specific to the Debug configuration of the + project when building with GCC and generating code coverage data. + - MSVCDebug.cmake + Defines compiler flags specific to the Debug configuration of the + project when building with MSVC. + - MSVCRelease.cmake + Defines compiler flags specific to the Release configuration of the + project when building with MSVC. +- Linking definitions: + - Demo.cmake + Defines the linking for the demo targets. + - TestCPPWithCoverage.cmake + Defines the linking for the TestCPP library when code coverage is + enabled. + - Tests.cmake + Defines the linking for the test targets. + - TestsWithCoverage.cmake + Defines the linking for the test targets when code coverage is + enabled. +- Toolchain files: + - Windows + - Windows.Clang.toolchain.cmake + Toolchain file for Visual Studio-installed Clang on Windows. + - Windows.MSVC.toolchain.cmake + Toolchain file for MSVC on Windows. + - Windows.Kits.cmake + Toolchain file for Windows SDKs. + - VSWhere.cmake + Toolchain file for finding Visual Studio installations. ## Building outside the IDE To build outside of the CodeLite IDE, you can run the following commands, after cloning the repo, for the debug build: ``` - cd TestCPP - mkdir build-debug - cd build-debug - cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 - make +cd TestCPP +mkdir build-debug +cd build-debug +cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 +make ``` The Debug configuration supports testing and code coverage. To enable those in the build, add one or both of the following flags to `cmake`: @@ -300,11 +380,11 @@ The Debug configuration supports testing and code coverage. To enable For the release build: ``` - cd TestCPP - mkdir build-release - cd build-release - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 - make +cd TestCPP +mkdir build-release +cd build-release +cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 +make ``` The Release configuration supports testing. To enable generation of the test target in the build, add the following flag to `cmake`: @@ -321,32 +401,57 @@ Both Release and Debug configurations support building with stack trace functionality with the folloeing flag: - `-DTESTCPP_STACKTRACE_ENABLED` +# Static Analysis of TestCPP + You can run cppcheck and clang-tidy on the generated compile_commands.json. + For clang-tidy, you can also use the CMake flag to have CMake run clang-tidy during the build. -My suggested options for cppcheck are: - - --project=compile_commands.json - - Uses the generated CMake output to define a check project - - -itest - - Ignores tests, in case building with tests enabled - - -idemo - - Ignores demo code, in case building with demo enabled - - --enable=all - - Enables all CPPCheck checks - - --suppress=missingIncludeSystem - - Then suppress missing system includes, there are no <>-enclosed - includes that need to be checked for this project. - - --suppress=unusedFunction - - Then suppress checking for unused functions. Most API functions - are not used within the library itself, and CPPCheck will generate - numerous errors saying the functions are unused. - clang-tidy uses the .clang-tidy configuration file so you don't need to specify any options unless you want to run it with different checks/ behavior from what I usually run for this project. +My suggested options for cppcheck are: +- --project=compile_commands.json + - Uses the generated CMake output to define a check project; you need + to adjust the argument to this parameter to match the path to the + compile_commands.json file that was generated. +- --enable=all + - Enables all CPPCheck checks applicable to the project. +- --suppress=missingIncludeSystem + - Then suppress missing system includes, there are no <>-enclosed + includes that need to be checked for this project. +- --suppress=unusedFunction + - Then suppress checking for unused functions. Most API functions + are not used within the library itself, and CPPCheck will generate + numerous errors saying the functions are unused. +- --suppress=checkersReport + - Then suppress the checkers report, which is a summary of the checks + that were run and how many were skipped. +- --suppress='\*:3rdparty/\*' + - Ignore all checks in the 3rdparty directory, which is where the + Boost headers are stored for this project. +- --inconclusive + - Allow inconclusive results to be reported, which can identify more + potential issues in the code. +- --force + - Forces checking of all preprocessor configurations +- --check-level=exhaustive + - Analysis covers all possible paths and more expensive checks +- --inline-suppr + - Obeys inline suppression of errors in the code, which are used in + this project to suppress specific instances of errors/warnings that + are not applicable or are false positives. +- --quiet + - Suppresses all output except for errors and warnings +- --std=c++11 + - Specifies the C++ standard to use for checking the code + +I would recommend against using the -j parameter with cppcheck because + it disables certain checks that are used in the project. + # Testing and Code Coverage The library is tested using itself. @@ -386,14 +491,14 @@ After building, run the variant of the commands that align with your build configuration (starting from the project directory). For the debug build: ``` - cd build-debug - sudo cmake --install . +cd build-debug +sudo cmake --install . ``` For the release build: ``` - cd build-release - sudo cmake --install . +cd build-release +sudo cmake --install . ``` # Packaging @@ -409,6 +514,10 @@ To create basic binary packages that can be used on the or build-release): - `cpack --config CPackConfig.cmake` +Building the basic binary packages on Windows will generate an NSIS + executable installer while building on Linux will generate multiple + tarballs and an executable sh installer file. + To create source packages, run the following command from the CMake build directory (either build-debug or build-release): - `cpack --config CPackSourceConfig.cmake` @@ -420,6 +529,11 @@ If you are building on Linux, the build supports generating - `cpack -G DEB` - `cpack -G RPM` +If you are building on Windows, the build supports generating MSI + packages. To build those (make sure you have the WiX toolkit installed + first), run the following command from the CMake build directory: + - `cpack -G WIX` + Both Windows and Linux builds also support generating a zip package by running the following command from the CMake build directory (either build-debug or build-release): @@ -436,3 +550,40 @@ Please submit an issue on the repo if there are problems I am semi-actively developing this library/framework, if anyone would like to contribute please do so by submitting pull requests on GitHub. + +## GitHub Actions + +The project is configured to use GitHub Actions for CI/CD. +There are several workflows that are used to build, test, and package + the library. +The workflows are as follows: +- cmake-multi-platform-st.yml + - Builds the library on Windows and Linux with stack traces enabled. +- cmake-multi-platform-nost.yml + - Builds the library on Windows and Linux with stack traces disabled. +- cmake-build-test-st.yml + - Builds and tests the library on Windows and Linux with stack traces + enabled. +- cmake-build-test-nost.yml + - Builds and tests the library on Windows and Linux with stack traces + disabled. +- cmake-linux-pack-st.yml + - Builds and packages the library on Linux with stack traces enabled. +- cmake-linux-pack-nost.yml + - Builds and packages the library on Linux with stack traces + disabled. +- cmake-windows-pack-st.yml + - Builds and packages the library on Windows with stack traces + enabled. +- cmake-windows-pack-nost.yml + - Builds and packages the library on Windows with stack traces + disabled. +- cmake-build-cov-st.yml + - Builds and tests the library on Linux with stack traces enabled and + generates code coverage reports that are then pushed to CodeCov for + helpful visualizations and reporting. +- codeql.yml + - Runs the CodeQL static analysis tool on the library code. +- cmake-static-analysis.yml + - Runs clang-tidy and cppcheck on the library code using + JacobDomagala/StaticAnalysis@master diff --git a/cmake/Packing.cmake b/cmake/Packing.cmake index 8de2ae9..32718af 100644 --- a/cmake/Packing.cmake +++ b/cmake/Packing.cmake @@ -24,7 +24,7 @@ set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) -set (CPACK_PACKAGE_CONTACT "el.jonny@gmail.com") +set (CPACK_PACKAGE_CONTACT "jonathan.hyry@outlook.com") set (CPACK_DEBIAN_PACKAGE_MAINTAINER "Jonathan Hyry <${CPACK_PACKAGE_CONTACT}>") set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/eljonny/TestCPP") @@ -45,6 +45,13 @@ set (CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) set (CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE) set (CPACK_DEB_COMPONENT_INSTALL YES) +set (CPACK_WIX_UPGRADE_GUID "EDB6D016-633E-4A35-AD5A-7734F6F3E6A5") +set (CPACK_WIX_LICENSE_RTF "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.rtf") +set (CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/res/img/testcpp.ico") +set (CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/res/img/testcpp-inst-banner.bmp") +set (CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/res/img/testcpp-inst-dialog.bmp") +set (CPACK_WIX_CMAKE_PACKAGE_REGISTRY "${PROJECT_NAME}") + include (CPack) include (CMakePackageConfigHelpers) diff --git a/res/img/testcpp-inst-banner.bmp b/res/img/testcpp-inst-banner.bmp new file mode 100644 index 0000000..518de64 Binary files /dev/null and b/res/img/testcpp-inst-banner.bmp differ diff --git a/res/img/testcpp-inst-dialog.bmp b/res/img/testcpp-inst-dialog.bmp new file mode 100644 index 0000000..604d679 Binary files /dev/null and b/res/img/testcpp-inst-dialog.bmp differ diff --git a/res/img/testcpp.ico b/res/img/testcpp.ico new file mode 100644 index 0000000..a0a8773 Binary files /dev/null and b/res/img/testcpp.ico differ diff --git a/res/img/testcpp.png b/res/img/testcpp.png new file mode 100644 index 0000000..68361dc Binary files /dev/null and b/res/img/testcpp.png differ