@@ -35,28 +35,38 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
35
35
target_compile_options (codspeed INTERFACE -Wno-old-style-cast )
36
36
endif ()
37
37
38
- execute_process (
39
- COMMAND git rev-parse --show-toplevel
40
- OUTPUT_VARIABLE CODSPEED_ROOT_DIR
41
- OUTPUT_STRIP_TRAILING_WHITESPACE
42
- RESULT_VARIABLE GIT_COMMAND_RESULT
43
- )
38
+ # Allow the user to override CODSPEED_ROOT_DIR from the command line
39
+ set (CODSPEED_ROOT_DIR "" CACHE PATH "Root directory for Codspeed" )
40
+
41
+ if (NOT CODSPEED_ROOT_DIR )
42
+ execute_process (
43
+ COMMAND git rev-parse --show-toplevel
44
+ OUTPUT_VARIABLE CODSPEED_ROOT_DIR
45
+ OUTPUT_STRIP_TRAILING_WHITESPACE
46
+ RESULT_VARIABLE GIT_COMMAND_RESULT
47
+ )
44
48
45
- if (NOT GIT_COMMAND_RESULT EQUAL 0 )
49
+ if (GIT_COMMAND_RESULT EQUAL 0 )
50
+ message (STATUS "Detected Codspeed root directory: ${CODSPEED_ROOT_DIR} " )
51
+ else ()
52
+ message (
53
+ WARNING
54
+ "CODSPEED_ROOT_DIR will default to PWD at runtime as git detection failed."
55
+ )
56
+ endif ()
57
+ else ()
46
58
message (
47
- WARNING
48
- "Failed to determine the git root directory.\
49
- Check that git is in your PATH, and that you are in a git repository.\
50
- Continuing, but codspeed features will not be useable"
59
+ STATUS
60
+ "Using user-specified Codspeed root directory: ${CODSPEED_ROOT_DIR} "
51
61
)
52
- # Default to user's cmake source directory
53
- set (CODSPEED_ROOT_DIR ${CMAKE_SOURCE_DIR} )
54
62
endif ()
55
63
64
+ # Define the CODSPEED_ROOT_DIR macro for the target
56
65
target_compile_definitions (
57
66
codspeed
58
67
PRIVATE -DCODSPEED_ROOT_DIR= "${CODSPEED_ROOT_DIR} "
59
68
)
69
+
60
70
message (STATUS "Using codspeed root directory: ${CODSPEED_ROOT_DIR} " )
61
71
62
72
set (CODSPEED_MODE_ALLOWED_VALUES "off" "instrumentation" "walltime" )
@@ -98,10 +108,11 @@ if(NOT CODSPEED_MODE STREQUAL "off")
98
108
endif ()
99
109
100
110
install (
101
- FILES
102
- include /codspeed.h # or wherever codspeed.h is located in core/
103
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /benchmark
104
- # Or possibly: DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
111
+ DIRECTORY "${PROJECT_SOURCE_DIR} /include" "${PROJECT_BINARY_DIR} /include"
112
+ DESTINATION /usr/local
113
+ FILES_MATCHING
114
+ PATTERN "*.h"
115
+ PATTERN "*.hpp"
105
116
)
106
117
107
118
install (
0 commit comments