Skip to content

Commit ce20900

Browse files
committed
fixup: add instrument hooks directly to cmake/bazel
1 parent 8cfd715 commit ce20900

File tree

4 files changed

+68
-7
lines changed

4 files changed

+68
-7
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "core/instrument-hooks"]
2+
path = core/instrument-hooks
3+
url = https://github.com/CodSpeedHQ/instrument-hooks

core/BUILD

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,32 @@ config_setting(
88
constraint_values = ["@platforms//os:windows"],
99
)
1010

11+
# Instrument-hooks library with warning suppressions
12+
cc_library(
13+
name = "instrument_hooks",
14+
srcs = ["instrument-hooks/dist/core.c"],
15+
hdrs = glob(["instrument-hooks/includes/*.h"]),
16+
includes = ["instrument-hooks/includes"],
17+
copts = select({
18+
":windows": [
19+
"/wd4101", # unreferenced local variable (equivalent to -Wno-unused-variable)
20+
"/wd4189", # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable)
21+
"/wd4100", # unreferenced formal parameter (equivalent to -Wno-unused-parameter)
22+
"/wd4245", # signed/unsigned mismatch
23+
"/wd4132", # const object should be initialized
24+
"/wd4146", # unary minus operator applied to unsigned type
25+
],
26+
"//conditions:default": [
27+
"-Wno-maybe-uninitialized",
28+
"-Wno-unused-variable",
29+
"-Wno-unused-parameter",
30+
"-Wno-unused-but-set-variable",
31+
"-Wno-type-limits",
32+
],
33+
}),
34+
visibility = ["//visibility:public"],
35+
)
36+
1137

1238
# Define the codspeed library
1339
cc_library(
@@ -26,7 +52,7 @@ cc_library(
2652
":walltime_mode": ["CODSPEED_ENABLED", "CODSPEED_WALLTIME"],
2753
"//conditions:default": [],
2854
}),
29-
deps = ["@instrument_hooks//:instrument_hooks"],
55+
deps = [":instrument_hooks"],
3056
visibility = ["//visibility:public"],
3157
)
3258

core/CMakeLists.txt

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,44 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
1111
# Add the include directory
1212
include_directories(include)
1313

14-
include(FetchContent)
15-
FetchContent_Declare(
14+
# Add the instrument_hooks library
15+
add_library(
16+
instrument_hooks
17+
STATIC
18+
instrument-hooks/dist/core.c
19+
)
20+
21+
target_include_directories(
1622
instrument_hooks
17-
GIT_REPOSITORY https://github.com/CodSpeedHQ/instrument-hooks/
18-
GIT_TAG 42ed74076c697c2f06c5ac81a84ccee983d7f140
23+
PUBLIC
24+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/instrument-hooks/includes>
25+
$<INSTALL_INTERFACE:includes>
1926
)
20-
FetchContent_MakeAvailable(instrument_hooks)
27+
28+
# Suppress warnings for the instrument_hooks library
29+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
30+
target_compile_options(
31+
instrument_hooks
32+
PRIVATE
33+
-Wno-maybe-uninitialized
34+
-Wno-unused-variable
35+
-Wno-unused-parameter
36+
-Wno-unused-but-set-variable
37+
-Wno-type-limits
38+
)
39+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
40+
target_compile_options(
41+
instrument_hooks
42+
PRIVATE
43+
/wd4101 # unreferenced local variable (equivalent to -Wno-unused-variable)
44+
/wd4189 # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable)
45+
/wd4100 # unreferenced formal parameter (equivalent to -Wno-unused-parameter)
46+
/wd4245 # signed/unsigned mismatch
47+
/wd4132 # const object should be initialized
48+
/wd4146 # unary minus operator applied to unsigned type
49+
)
50+
endif()
51+
2152

2253
# Add the main library
2354
add_library(
@@ -38,7 +69,7 @@ add_compile_definitions(CODSPEED_VERSION="${CODSPEED_VERSION}")
3869
target_include_directories(
3970
codspeed
4071
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
41-
$<BUILD_INTERFACE:${instrument_hooks_SOURCE_DIR}/includes>
72+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/instrument-hooks/includes>
4273
)
4374

4475
# Disable valgrind compilation errors

core/instrument-hooks

Submodule instrument-hooks added at 9907c26

0 commit comments

Comments
 (0)