Inside the companion
Build your studio
Two small CMake checkpoints: one executable, then a library with tests and presets.
Project files 9
Build a library and its consumers
Connect the checker library, application, and registered CTest target.
cmake_minimum_required(VERSION 3.25)
project(CheckerStudio LANGUAGES CXX)
set(CMAKE_CXX_EXTENSIONS OFF)
function(studio_warnings target)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(${target} PRIVATE
-Wall -Wextra -Wpedantic -Wconversion -Wshadow)
endif()
endfunction()
add_library(checker_core src/checker.cpp)
target_include_directories(checker_core PUBLIC include)
target_compile_features(checker_core PUBLIC cxx_std_23)
studio_warnings(checker_core)
add_executable(checker src/main.cpp)
target_link_libraries(checker PRIVATE checker_core)
studio_warnings(checker)
include(CTest)
if(BUILD_TESTING)
add_executable(checker-tests tests/checker_tests.cpp)
target_link_libraries(checker-tests PRIVATE checker_core)
studio_warnings(checker-tests)
add_test(NAME checker-contracts COMMAND checker-tests)
endif()
This is the file included with the course. Copy and download give you its complete source.
Taking your work offline? Download all course companions
