@@ -4,8 +4,20 @@ execute_process(
4
4
COMMAND git rev-parse --show-toplevel
5
5
OUTPUT_VARIABLE GIT_ROOT_DIR
6
6
OUTPUT_STRIP_TRAILING_WHITESPACE
7
+ RESULT_VARIABLE GIT_COMMAND_RESULT
7
8
)
8
9
10
+ if (NOT GIT_COMMAND_RESULT EQUAL 0)
11
+ message (
12
+ WARNING
13
+ "Failed to determine the git root directory.\
14
+ Check that git is in your PATH, and that you are in a git repository.\
15
+ Continuing, but Codspeed features will not be useable"
16
+ )
17
+ # Default to user's cmake source directory
18
+ set (GIT_ROOT_DIR ${CMAKE_SOURCE_DIR} )
19
+ endif ()
20
+
9
21
target_compile_definitions (
10
22
codspeed
11
23
INTERFACE -DCODSPEED_GIT_ROOT_DIR="${GIT_ROOT_DIR} "
@@ -21,14 +33,11 @@ if(DEFINED CODSPEED_MODE)
21
33
elseif (CODSPEED_MODE STREQUAL "walltime" )
22
34
target_compile_definitions (codspeed INTERFACE -DCODSPEED_WALLTIME)
23
35
else ()
24
- # Step 3: Default to "instrumentation" if no value is provided
25
- set (CODSPEED_MODE "instrumentation" )
26
- endif ()
27
- endif ()
28
36
message (
29
37
FATAL_ERROR
30
38
"Invalid build mode: ${CODSPEED_MODE} . Use 'instrumentation' or 'walltime'."
31
39
)
32
- if (CODSPEED_MODE STREQUAL "instrumentation" )
33
- target_compile_definitions (codspeed INTERFACE -DCODSPEED_INSTRUMENTATION)
34
- elseif (CODSPEED_MODE STREQUAL "walltime" )
40
+ endif ()
41
+ endif ()
42
+
43
+ message (STATUS "Build mode set to: ${CODSPEED_MODE} " )
0 commit comments