Mastering Cmake Pdf Extra Quality (2027)
add_library(math STATIC add.cpp multiply.cpp) target_include_directories(math PUBLIC $CMAKE_CURRENT_SOURCE_DIR/include) target_compile_features(math PUBLIC cxx_std_17) option(BUILD_MATH_EXAMPLES "Build math examples" OFF) if(BUILD_MATH_EXAMPLES) add_executable(calc_example examples/calc.cpp) target_link_libraries(calc_example PRIVATE math) endif()
add_executable(test_core test_core.cpp) target_link_libraries(test_core PRIVATE core) add_test(NAME CoreSanity COMMAND test_core) add_test(NAME CoreEdgeCase COMMAND test_core --edge) Presets: The Future of CMake Workflows (3.19+) CMakePresets.json standardizes configuring, building, and testing across teams: mastering cmake pdf
"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" ] add_library(math STATIC add
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 : and testing across teams: "version": 3