Skip to content

Commit be3fabb

Browse files
committed
fix: fetch instrument-hooks in cmake via FetchContent
1 parent 5edaebc commit be3fabb

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

core/CMakeLists.txt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,32 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
1111
# Add the include directory
1212
include_directories(include)
1313

14+
include(FetchContent)
15+
FetchContent_Declare(
16+
instrument_hooks_repo
17+
GIT_REPOSITORY https://github.com/CodSpeedHQ/instrument-hooks
18+
GIT_TAG b1e401a4d031ad308edb22ed59a52253a1ebe924
19+
)
20+
FetchContent_MakeAvailable(instrument_hooks_repo)
21+
FetchContent_GetProperties(instrument_hooks_repo)
22+
if(NOT instrument_hooks_repo_POPULATED)
23+
FetchContent_Populate(instrument_hooks_repo)
24+
set(instrument_hooks_SOURCE_DIR ${instrument_hooks_repo_SOURCE_DIR})
25+
else()
26+
set(instrument_hooks_SOURCE_DIR ${instrument_hooks_repo_SOURCE_DIR})
27+
endif()
28+
1429
# Add the instrument_hooks library
1530
add_library(
1631
instrument_hooks
1732
STATIC
18-
instrument-hooks/dist/core.c
33+
${instrument_hooks_SOURCE_DIR}/dist/core.c
1934
)
2035

2136
target_include_directories(
2237
instrument_hooks
2338
PUBLIC
24-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/instrument-hooks/includes>
39+
$<BUILD_INTERFACE:${instrument_hooks_SOURCE_DIR}/includes>
2540
$<INSTALL_INTERFACE:includes>
2641
)
2742

@@ -72,7 +87,7 @@ add_compile_definitions(CODSPEED_VERSION="${CODSPEED_VERSION}")
7287
target_include_directories(
7388
codspeed
7489
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
75-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/instrument-hooks/includes>
90+
$<BUILD_INTERFACE:${instrument_hooks_SOURCE_DIR}/includes>
7691
)
7792

7893
# Disable valgrind compilation errors

0 commit comments

Comments
 (0)