Skip to content

Commit 14cf29b

Browse files
fup only run once
1 parent 862412d commit 14cf29b

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

google_benchmark/cmake/Codspeed.cmake

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,18 @@ execute_process(
88
target_compile_definitions(codspeed
99
INTERFACE -DCODSPEED_GIT_ROOT_DIR="${GIT_ROOT_DIR}")
1010

11-
# Step 1: Check if CODSPEED_MODE is set via the command line
12-
13-
# CMake cache kind of breaks this mechanism, keeping it for first time
14-
# defaulting
15-
if(NOT DEFINED CODSPEED_MODE)
16-
# Step 2: Check the environment variable CODSPEED_MODE
17-
if(DEFINED $ENV{CODSPEED_RUNNER_MODE})
18-
set(CODSPEED_MODE $ENV{CODSPEED_RUNNER_MODE} FORCE)
19-
else()
20-
# Step 3: Default to "instrumentation" if no value is provided
21-
set(CODSPEED_MODE "instrumentation")
22-
endif()
23-
endif()
24-
25-
# Define a preprocessor macro based on the build mode
26-
if(CODSPEED_MODE STREQUAL "instrumentation")
11+
if(DEFINED CODSPEED_MODE)
12+
# Define a preprocessor macro based on the build mode
13+
if(CODSPEED_MODE STREQUAL "instrumentation")
2714
target_compile_definitions(codspeed INTERFACE -DCODSPEED_INSTRUMENTATION)
28-
elseif(CODSPEED_MODE STREQUAL "walltime")
15+
elseif(CODSPEED_MODE STREQUAL "walltime")
2916
target_compile_definitions(codspeed INTERFACE -DCODSPEED_WALLTIME)
30-
else()
17+
else()
3118
message(
32-
FATAL_ERROR
19+
FATAL_ERROR
3320
"Invalid build mode: ${CODSPEED_MODE}. Use 'instrumentation' or 'walltime'."
3421
)
22+
endif()
3523
endif()
3624

3725
message(STATUS "Build mode set to: ${CODSPEED_MODE}")

0 commit comments

Comments
 (0)