@@ -4,8 +4,20 @@ execute_process(
44 COMMAND git rev-parse --show-toplevel
55 OUTPUT_VARIABLE GIT_ROOT_DIR
66 OUTPUT_STRIP_TRAILING_WHITESPACE
7+ RESULT_VARIABLE GIT_COMMAND_RESULT
78)
89
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+
921target_compile_definitions (
1022 codspeed
1123 INTERFACE -DCODSPEED_GIT_ROOT_DIR= "${GIT_ROOT_DIR} "
@@ -21,14 +33,11 @@ if(DEFINED CODSPEED_MODE)
2133 elseif (CODSPEED_MODE STREQUAL "walltime" )
2234 target_compile_definitions (codspeed INTERFACE -DCODSPEED_WALLTIME )
2335 else ()
24- # Step 3: Default to "instrumentation" if no value is provided
25- set (CODSPEED_MODE "instrumentation" )
26- endif ()
27- endif ()
2836 message (
2937 FATAL_ERROR
3038 "Invalid build mode: ${CODSPEED_MODE} . Use 'instrumentation' or 'walltime'."
3139 )
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