warp-pipe/CMakeLists.txt
2026-01-29 21:01:56 -07:00

61 lines
2 KiB
CMake

cmake_minimum_required(VERSION 3.20)
project(warppipe VERSION 0.1.0 LANGUAGES CXX)
set(WARPPIPE_HOMEBREW_PREFIX "/home/linuxbrew/.linuxbrew")
if(EXISTS "${WARPPIPE_HOMEBREW_PREFIX}/bin/brew")
list(PREPEND CMAKE_PREFIX_PATH "${WARPPIPE_HOMEBREW_PREFIX}")
set(ENV{PKG_CONFIG_PATH}
"${WARPPIPE_HOMEBREW_PREFIX}/lib/pkgconfig:${WARPPIPE_HOMEBREW_PREFIX}/share/pkgconfig:$ENV{PKG_CONFIG_PATH}")
endif()
option(WARPPIPE_BUILD_EXAMPLES "Build warppipe examples" ON)
option(WARPPIPE_BUILD_TESTS "Build warppipe tests" ON)
option(WARPPIPE_BUILD_PERF "Build warppipe perf tools" ON)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PIPEWIRE REQUIRED IMPORTED_TARGET libpipewire-0.3)
include(FetchContent)
find_package(nlohmann_json 3.11.0 QUIET)
if(NOT nlohmann_json_FOUND)
FetchContent_Declare(json
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
FetchContent_MakeAvailable(json)
endif()
add_library(warppipe STATIC
src/warppipe.cpp
)
target_include_directories(warppipe
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(warppipe PUBLIC cxx_std_17)
target_link_libraries(warppipe PUBLIC PkgConfig::PIPEWIRE PRIVATE nlohmann_json::nlohmann_json)
if(WARPPIPE_BUILD_EXAMPLES)
add_executable(warppipe_example examples/minimal.cpp)
target_link_libraries(warppipe_example PRIVATE warppipe)
add_executable(warppipe_cli examples/warppipe_cli.cpp)
target_link_libraries(warppipe_cli PRIVATE warppipe)
endif()
if(WARPPIPE_BUILD_PERF)
add_executable(warppipe_perf perf/warppipe_perf.cpp)
target_link_libraries(warppipe_perf PRIVATE warppipe)
endif()
if(WARPPIPE_BUILD_TESTS)
enable_testing()
find_package(Catch2 3 REQUIRED)
add_executable(warppipe_tests tests/warppipe_tests.cpp)
target_link_libraries(warppipe_tests PRIVATE warppipe Catch2::Catch2WithMain)
target_compile_definitions(warppipe PRIVATE WARPPIPE_TESTING)
target_compile_definitions(warppipe_tests PRIVATE WARPPIPE_TESTING)
add_test(NAME warppipe_tests COMMAND warppipe_tests)
endif()