@@ -35,28 +35,38 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
3535 target_compile_options (codspeed INTERFACE -Wno-old-style-cast)
3636endif ()
3737
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+ )
4448
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 ()
4658 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} "
5161 )
52- # Default to user's cmake source directory
53- set (CODSPEED_ROOT_DIR ${CMAKE_SOURCE_DIR} )
5462endif ()
5563
64+ # Define the CODSPEED_ROOT_DIR macro for the target
5665target_compile_definitions (
5766 codspeed
5867 PRIVATE -DCODSPEED_ROOT_DIR="${CODSPEED_ROOT_DIR} "
5968)
69+
6070message (STATUS "Using codspeed root directory: ${CODSPEED_ROOT_DIR} " )
6171
6272set (CODSPEED_MODE_ALLOWED_VALUES "off" "instrumentation" "walltime" )
@@ -98,10 +108,11 @@ if(NOT CODSPEED_MODE STREQUAL "off")
98108endif ()
99109
100110install (
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"
105116)
106117
107118install (
0 commit comments