#include <catch2/catch.hpp> #include "math/add.h" TEST_CASE("Addition works", "[math]") REQUIRE(add(2, 2) == 4);
install(FILES "$CMAKE_CURRENT_BINARY_DIR/MyProjectConfigVersion.cmake" DESTINATION lib/cmake/MyProject ) CMake’s built-in testing is trivial to use: mastering cmake pdf
:
set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf) Usage: cmake -DCMAKE_TOOLCHAIN_FILE=toolchain_arm.cmake .. Allow other projects to find your library via find_package : #include <catch2/catch
"version": 3, "configurePresets": [ "name": "debug", "displayName": "Debug", "generator": "Ninja", "binaryDir": "$sourceDir/build/debug", "cacheVariables": "CMAKE_BUILD_TYPE": "Debug", "BUILD_TESTS": "ON" , "name": "release", "inherits": "debug", "displayName": "Release", "binaryDir": "$sourceDir/build/release", "cacheVariables": "CMAKE_BUILD_TYPE": "Release" ], "buildPresets": [ "name": "debug", "configurePreset": "debug" , "name": "release", "configurePreset": "release" ] #include "math/add.h" TEST_CASE("Addition works"