Own implementation of different tools.
-
Tested with
- IDEs
- Visual Studio 2022
- Visual Studio Code
- Compilers
- msvc14+
- gcc-{11, 12, 13}
- IDEs
-
Install
vcpkg
- Checkout tag 2024.12.16 -
git checkout tags/2024.12.16 -b tag-2024.12.16
- For the first time setup see
- Consider using
-disableMetrics
options while bootstraping vcpkg
- Checkout tag 2024.12.16 -
-
Install libraries
./vcpkg install gtest spdlog openssl boost-asio boost-iostreams nlohmann-json cxxopts glaze --triplet=<platform>
- Windows
<platform>
can bex64-windows
- Linux
<platform>
can bex64-linux
- Windows
-
Configure
- Navigate the root directory of the project
- If the environment variable
VCPKG_ROOT
is defined, use the command belowcmake -B build -S .
- Otherwise
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=<vcpkg_path>/scripts/buildsystems/vcpkg.cmake
- Additionally build type can be specified as below:
Debug
,Release
, ...-DCMAKE_BUILD_TYPE=<cfg>
-
Build
cmake --build build --parallel 8 --config <cfg>
-
Extras
-
Run the command below before configure step to build with
clang
. Change clang path if required.export CC=/usr/bin/clang export CXX=/usr/bin/clang++
-
-
Tests
- CTest
ctest --test-dir build --build-config <cfg>
ctest --test-dir build --build-config <cfg> [--tests-regex <regex>]
# .Pattern.ctest --test-dir build -C <cfg> [-R <regex>]
-N
additional options disables execution and only prints a list of test
- Manually run application with ending with name
-test
(TBD, utilizectest
)- Windows -
build\core\test\Debug\core-test.exe
- Linux -
./build/core/test/core-test
- Windows -
- Creating and running tests with CTest
- CTest
-
Install
cmake --install build --prefix ./
# Configuration picked up from the build dircmake --install build --prefix ./ --config <cfg>
# Update this part
- Console application
- Run executable
- Windows service
- Install autostart service
sc create kidmon binPath= "<absolute path of the kidmon app>" start= auto DisplayName= "Kidmon application"
- Install autostart service
- Windows
-
Install OpenCppCoverage
-
Locate project root directory
-
Run tests with coverage
OpenCppCoverage.exe --sources tools\src\core --modules test.exe --export_type=html:.reports/core/ -- out\build\x64-Debug\test\core\core-test.exe OpenCppCoverage.exe --sources tools\src\kidmon --modules test.exe --export_type=html:.reports/kidmon/ -- out\build\x64-Debug\test\kidmon\kidmon-test.exe
-
TBD - the command line above is for reference only, later create a script to produce coverage
-
- Linux
- TBD
- Read about codecov CI
- The project is formatted based on the settings in
.clang-format
- Open bash, navigate the root directory of the project
- Ensure
clang-format
version17.0.1
(or above) is installed - Run
find . -type f \( -name "*.cpp" -o -name "*.h" \) -not -path "./build/*" | xargs clang-format -i
, to format all{h,cpp}
files in place - Alternatively checkout this approach
clang-format -i {src,tests}/*.{h,cpp}
-
Debug and Run
- Visual Studio 2022
- Customize debug/launch arguments
- Select configuration
- Select target
- Select
Debug -> Debug and Launch Settings For <Target>
from menu - Add
"args": []
section in the same level where located attributename
and provide desired command line arguments
- Customize debug/launch arguments
- Visual Studio Code
- Install
CMake Tools
extension - From Command Palette
- Select
CMake: Set Launch/Debug Target
- Select
CMake: Debug
- Select
- If you need to pass custom command line argument to debugger check this documentation.
- Method 1
- Activate
Run and Debug
in the Sidebar - Click
create a launch.json file
and selectC++ (GDB)/(LLDB)
- Copy paste desired settings from section
Debug using a launch.json file
from the link above.- If you debug with
msvc
use that setting
- If you debug with
- Add custom arguments into
"args": [],
- Activate
- Method 2
-
Create
settings.json
file under thevscode
directory -
Consider adding this
{ "cmake.debugConfig": { "args": ["command arguments"] } }
-
- Install
- Visual Studio 2022
-
Profiling
- Linux
- See usage of perf or gemini
- Linux