-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCodspeed.cmake
More file actions
44 lines (39 loc) · 1.33 KB
/
Codspeed.cmake
File metadata and controls
44 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
add_subdirectory(${PROJECT_SOURCE_DIR}/../core codspeed)
execute_process(
COMMAND git rev-parse --show-toplevel
OUTPUT_VARIABLE GIT_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE GIT_COMMAND_RESULT
)
if(NOT GIT_COMMAND_RESULT EQUAL 0)
message(
WARNING
"Failed to determine the git root directory.\
Check that git is in your PATH, and that you are in a git repository.\
Continuing, but codspeed features will not be useable"
)
# Default to user's cmake source directory
set(GIT_ROOT_DIR ${CMAKE_SOURCE_DIR})
endif()
target_compile_definitions(
codspeed
INTERFACE -DCODSPEED_GIT_ROOT_DIR="${GIT_ROOT_DIR}"
)
if(DEFINED CODSPEED_MODE)
target_compile_definitions(codspeed INTERFACE -DCODSPEED_ENABLED)
# Define a preprocessor macro based on the build mode
if(CODSPEED_MODE STREQUAL "instrumentation")
target_compile_definitions(
codspeed
INTERFACE -DCODSPEED_INSTRUMENTATION
)
elseif(CODSPEED_MODE STREQUAL "walltime")
target_compile_definitions(codspeed INTERFACE -DCODSPEED_WALLTIME)
else()
message(
FATAL_ERROR
"Invalid build mode: ${CODSPEED_MODE}. Use 'instrumentation' or 'walltime'."
)
endif()
endif()
message(STATUS "Build mode set to: ${CODSPEED_MODE}")