Source browser/Build integration
CMake · complete file

CMakeLists.txt

Check vendored, FetchContent and installed-package integration.

test/integration/CMakeLists.txt
32 lines1.3 KiBClick a line number to link to it
CMakeLists.txt
1cmake_minimum_required(VERSION 3.20)2if(CMAKE_HOST_APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)3  set(CMAKE_OSX_DEPLOYMENT_TARGET "14.4" CACHE STRING "Minimum macOS version")4endif()5project(TwoBufQueueConsumer LANGUAGES CXX)6set(BRQ_INTEGRATION_MODE "package" CACHE STRING "package, add_subdirectory, or fetchcontent")7if(BRQ_INTEGRATION_MODE STREQUAL "package")8  find_package(TwoBufQueue 0.6 CONFIG REQUIRED)9elseif(BRQ_INTEGRATION_MODE STREQUAL "add_subdirectory" OR10       BRQ_INTEGRATION_MODE STREQUAL "fetchcontent")11  if(NOT BRQ_SOURCE_DIR)12    message(FATAL_ERROR "Set BRQ_SOURCE_DIR to the library source root")13  endif()14  get_filename_component(BRQ_SOURCE_DIR "${BRQ_SOURCE_DIR}" ABSOLUTE15    BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")16  if(BRQ_INTEGRATION_MODE STREQUAL "add_subdirectory")17    add_subdirectory("${BRQ_SOURCE_DIR}" dependency)18  else()19    include(FetchContent)20    FetchContent_Declare(TwoBufQueue SOURCE_DIR "${BRQ_SOURCE_DIR}")21    FetchContent_MakeAvailable(TwoBufQueue)22  endif()23  if(BRQ_BUILD_TESTS OR BRQ_BUILD_EXAMPLES)24    message(FATAL_ERROR "Embedded library unexpectedly enabled tests or examples")25  endif()26else()27  message(FATAL_ERROR "Unknown BRQ_INTEGRATION_MODE")28endif()29add_executable(consumer main.cpp)30target_link_libraries(consumer PRIVATE TwoBufQueue::TwoBufQueue)31enable_testing()32add_test(NAME consumer_records COMMAND consumer)

Continue reading

CMake integration