diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e0e18586cb5c2195486e2ba6bfcb5ca504dd14e..01ebb6f258b173aee6df867c5c5c991ec936df57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,11 +2,24 @@ cmake_minimum_required(VERSION 3.18) file(READ "${CMAKE_SOURCE_DIR}/version.txt" version) +add_definitions(-DPROJECT_VERSION="${version}") file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project) message(STATUS "Project name: ${project}") message(STATUS "Project version: ${version}") +execute_process( + COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) +message(STATUS "Latest git commit: ${GIT_COMMIT_HASH}") + +# Define a preprocessor macro with the Git commit version +add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}") + + # Note : project name is {project} and python module name is also {project} set(module_name _${project}) # target name @@ -33,7 +46,9 @@ endif() enable_language(CUDA) -message(STATUS "CMAKE_CUDA_COMPILER_VERSION = ${CMAKE_CUDA_COMPILER_VERSION}") +message(STATUS "Cuda compiler version = ${CMAKE_CUDA_COMPILER_VERSION}") +# Define a preprocessor macro with the Cuda compiler version +add_definitions(-DCUDA_COMPILER_VERSION="${CMAKE_CUDA_COMPILER_VERSION}") ############################################## diff --git a/include/aidge/utils/sys_info/CudaVersionInfo.hpp b/include/aidge/utils/sys_info/CudaVersionInfo.hpp index f67b07199c9d4931b36efa62ce6654b1dd654043..17490476b18d62da66671a28f76709349e3ba805 100644 --- a/include/aidge/utils/sys_info/CudaVersionInfo.hpp +++ b/include/aidge/utils/sys_info/CudaVersionInfo.hpp @@ -6,7 +6,18 @@ namespace Aidge { +#ifndef PROJECT_VERSION // Normally defined in CMakeLists.txt +#define PROJECT_VERSION "Unknown version" +#endif +#ifndef GIT_COMMIT_HASH +#define GIT_COMMIT_HASH "" +#endif +#ifndef CUDA_COMPILER_VERSION +#define CUDA_COMPILER_VERSION "Unknown version" +#endif void showCudaVersion() { + Log::info("Aidge backend CUDA: {} ({}), {} {}", PROJECT_VERSION, GIT_COMMIT_HASH, __DATE__, __TIME__); + Log::info("CUDA compiler version: {}", CUDA_COMPILER_VERSION); Log::info("CuDNN version: {}.{}.{}\n", CUDNN_MAJOR, CUDNN_MINOR, CUDNN_PATCHLEVEL);