|
| 1 | +cmake_minimum_required(VERSION 3.15) |
| 2 | +project(test_fetch_content VERSION 1.0.0 LANGUAGES CXX) |
| 3 | + |
| 4 | +set(CMAKE_CXX_STANDARD 20) |
| 5 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 6 | + |
| 7 | +# Disable cpp-remote-profiler's own examples/tests/install to avoid conflicts |
| 8 | +set(REMOTE_PROFILER_BUILD_EXAMPLES OFF CACHE BOOL "") |
| 9 | +set(REMOTE_PROFILER_BUILD_TESTS OFF CACHE BOOL "") |
| 10 | +set(REMOTE_PROFILER_INSTALL OFF CACHE BOOL "") |
| 11 | + |
| 12 | +# Use add_subdirectory to bring in cpp-remote-profiler |
| 13 | +# This simulates what FetchContent does at configure time |
| 14 | +# SOURCE_DIR is passed by the CI test step |
| 15 | +if(NOT DEFINED PROFILER_SOURCE_DIR) |
| 16 | + message(FATAL_ERROR "PROFILER_SOURCE_DIR must be set to the cpp-remote-profiler source directory") |
| 17 | +endif() |
| 18 | + |
| 19 | +add_subdirectory(${PROFILER_SOURCE_DIR} ${CMAKE_BINARY_DIR}/cpp-remote-profiler) |
| 20 | + |
| 21 | +# Test: link against profiler_core |
| 22 | +add_executable(test_core main.cpp) |
| 23 | +target_link_libraries(test_core profiler_core) |
| 24 | +# Include generated profiler_version.h from the subproject's binary dir |
| 25 | +target_include_directories(test_core PRIVATE ${CMAKE_BINARY_DIR}/cpp-remote-profiler) |
| 26 | + |
| 27 | +# Test: link against profiler_web (if available) |
| 28 | +if(TARGET profiler_web) |
| 29 | + add_executable(test_web main.cpp) |
| 30 | + target_link_libraries(test_web profiler_web) |
| 31 | + target_include_directories(test_web PRIVATE ${CMAKE_BINARY_DIR}/cpp-remote-profiler) |
| 32 | + message(STATUS "test_fetch_content: profiler_web available, building test_web") |
| 33 | +else() |
| 34 | + message(STATUS "test_fetch_content: profiler_web not available, skipping test_web") |
| 35 | +endif() |
0 commit comments