11cmake_minimum_required (VERSION 3.10 )
22
3- set (CODSPEED_VERSION 2.1 .0)
3+ set (CODSPEED_VERSION 2.4 .0)
44
55project (codspeed VERSION ${CODSPEED_VERSION} LANGUAGES CXX C )
66
@@ -25,17 +25,13 @@ endif()
2525set (instrument_hooks_SOURCE_DIR ${instrument_hooks_repo_SOURCE_DIR } )
2626
2727# Add the instrument_hooks library
28- add_library (
29- instrument_hooks
30- STATIC
31- ${instrument_hooks_SOURCE_DIR } /dist/core.c
32- )
28+ add_library (instrument_hooks STATIC ${instrument_hooks_SOURCE_DIR } /dist/core.c )
3329
3430target_include_directories (
3531 instrument_hooks
3632 PUBLIC
37- $<BUILD_INTERFACE :${instrument_hooks_SOURCE_DIR } /includes >
38- $<INSTALL_INTERFACE :includes >
33+ $<BUILD_INTERFACE :${instrument_hooks_SOURCE_DIR } /includes >
34+ $<INSTALL_INTERFACE :includes >
3935)
4036
4137# Option to enable strict warnings (for CI builds)
@@ -61,25 +57,20 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
6157 list (PREPEND INSTRUMENT_HOOKS_CFLAGS -Wall -Werror)
6258 endif ()
6359
64- target_compile_options (
65- instrument_hooks
66- PRIVATE
67- ${INSTRUMENT_HOOKS_CFLAGS}
68- )
60+ target_compile_options (instrument_hooks PRIVATE ${INSTRUMENT_HOOKS_CFLAGS} )
6961elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
7062 target_compile_options (
7163 instrument_hooks
7264 PRIVATE
73- /wd4101 # unreferenced local variable (equivalent to -Wno-unused-variable)
74- /wd4189 # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable)
75- /wd4100 # unreferenced formal parameter (equivalent to -Wno-unused-parameter)
76- /wd4245 # signed/unsigned mismatch
77- /wd4132 # const object should be initialized
78- /wd4146 # unary minus operator applied to unsigned type
65+ /wd4101 # unreferenced local variable (equivalent to -Wno-unused-variable)
66+ /wd4189 # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable)
67+ /wd4100 # unreferenced formal parameter (equivalent to -Wno-unused-parameter)
68+ /wd4245 # signed/unsigned mismatch
69+ /wd4132 # const object should be initialized
70+ /wd4146 # unary minus operator applied to unsigned type
7971 )
8072endif ()
8173
82-
8374# Add the main library
8475add_library (
8576 codspeed
@@ -96,11 +87,35 @@ target_link_libraries(codspeed PRIVATE instrument_hooks)
9687# Version
9788add_compile_definitions (CODSPEED_VERSION= "${CODSPEED_VERSION} " )
9889
90+ # Collect compiler toolchain information for environment reporting
91+ # Use the shared detect_toolchain.sh script (same as Bazel) for consistent output
92+ execute_process (
93+ COMMAND
94+ bash "${CMAKE_CURRENT_SOURCE_DIR } /scripts/detect_toolchain.sh"
95+ "${CMAKE_CXX_COMPILER } " "${CMAKE_BUILD_TYPE } "
96+ OUTPUT_VARIABLE CODSPEED_TOOLCHAIN_HEADER
97+ OUTPUT_STRIP_TRAILING_WHITESPACE
98+ RESULT_VARIABLE DETECT_TOOLCHAIN_RESULT
99+ )
100+ if (DETECT_TOOLCHAIN_RESULT EQUAL 0)
101+ file (
102+ WRITE "${CMAKE_CURRENT_BINARY_DIR } /toolchain_info.h"
103+ "${CODSPEED_TOOLCHAIN_HEADER} \n "
104+ )
105+ else ()
106+ message (
107+ WARNING
108+ "detect_toolchain.sh failed, toolchain info will not be available"
109+ )
110+ endif ()
111+ target_include_directories (codspeed PRIVATE "${CMAKE_CURRENT_BINARY_DIR } " )
112+
99113# Specify the include directories for users of the library
100114target_include_directories (
101115 codspeed
102- PUBLIC $<BUILD_INTERFACE :${PROJECT_SOURCE_DIR } /include >
103- $<BUILD_INTERFACE :${instrument_hooks_SOURCE_DIR } /includes >
116+ PUBLIC
117+ $<BUILD_INTERFACE :${PROJECT_SOURCE_DIR } /include >
118+ $<BUILD_INTERFACE :${instrument_hooks_SOURCE_DIR } /includes >
104119)
105120
106121# Disable valgrind compilation errors
@@ -143,7 +158,13 @@ target_compile_definitions(
143158
144159message (STATUS "Using codspeed root directory: ${CODSPEED_ROOT_DIR} " )
145160
146- set (CODSPEED_MODE_ALLOWED_VALUES "off" "instrumentation" "simulation" "memory" "walltime" )
161+ set (CODSPEED_MODE_ALLOWED_VALUES
162+ "off"
163+ "instrumentation"
164+ "simulation"
165+ "memory"
166+ "walltime"
167+ )
147168set (CODSPEED_MODE "off" CACHE STRING "Build mode for Codspeed" )
148169set_property (
149170 CACHE CODSPEED_MODE
@@ -152,7 +173,10 @@ set_property(
152173
153174if (NOT CODSPEED_MODE STREQUAL "off" )
154175 target_compile_definitions (codspeed PUBLIC -DCODSPEED_ENABLED )
155- target_compile_definitions (codspeed PUBLIC -DCODSPEED_MODE_DISPLAY= "${CODSPEED_MODE} " )
176+ target_compile_definitions (
177+ codspeed
178+ PUBLIC -DCODSPEED_MODE_DISPLAY= "${CODSPEED_MODE} "
179+ )
156180
157181 if (NOT CMAKE_BUILD_TYPE )
158182 message (
@@ -167,11 +191,12 @@ if(NOT CODSPEED_MODE STREQUAL "off")
167191 endif ()
168192
169193 # Define a preprocessor macro based on the build mode
170- if (CODSPEED_MODE STREQUAL "instrumentation" OR CODSPEED_MODE STREQUAL "simulation" OR CODSPEED_MODE STREQUAL "memory" )
171- target_compile_definitions (
172- codspeed
173- PUBLIC -DCODSPEED_ANALYSIS
174- )
194+ if (
195+ CODSPEED_MODE STREQUAL "instrumentation"
196+ OR CODSPEED_MODE STREQUAL "simulation"
197+ OR CODSPEED_MODE STREQUAL "memory"
198+ )
199+ target_compile_definitions (codspeed PUBLIC -DCODSPEED_ANALYSIS )
175200 elseif (CODSPEED_MODE STREQUAL "walltime" )
176201 target_compile_definitions (codspeed PUBLIC -DCODSPEED_WALLTIME )
177202 else ()
0 commit comments