Skip to content
Snippets Groups Projects
Commit cf2edc0d authored by Felix Weiglhofer's avatar Felix Weiglhofer Committed by Florian Uhlig
Browse files

algo: Add build infos.

Generate the file algo/base/BuildInfo.cxx at compile time containing
various information like git commit and build configuration.
parent 76c414ed
No related branches found
No related tags found
1 merge request!1162algo: Add build infos.
Pipeline #22368 passed
...@@ -28,6 +28,23 @@ set(SRCS ...@@ -28,6 +28,23 @@ set(SRCS
detectors/trd/UnpackTrd.cxx detectors/trd/UnpackTrd.cxx
) )
set(BUILD_INFO_CXX ${CMAKE_CURRENT_BINARY_DIR}/base/BuildInfo.cxx)
set(SRCS ${SRCS} ${BUILD_INFO_CXX})
add_custom_target(generateBuildInfo
COMMAND ${CMAKE_COMMAND}
-DBUILD_TYPE=${CMAKE_BUILD_TYPE}
-DXPU_DEBUG=${XPU_DEBUG}
-DINFILE=${CMAKE_CURRENT_SOURCE_DIR}/base/BuildInfo.cxx.in
-DOUTFILE=${BUILD_INFO_CXX}
-P ${CMAKE_SOURCE_DIR}/cmake/modules/GenerateBuildInfo.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/base/BuildInfo.cxx.in
${CMAKE_SOURCE_DIR}/cmake/modules/GenerateBuildInfo.cmake
BYPRODUCTS ${BUILD_INFO_CXX}
COMMENT "Generating build info"
)
add_library(Algo SHARED ${SRCS}) add_library(Algo SHARED ${SRCS})
target_include_directories(Algo target_include_directories(Algo
......
/* Copyright (C) 2022 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer]*/
#include "BuildInfo.h"
// GENERATED BY CMAKE.
// DON'T CHANGE BY HAND. MODIFY .in-File INSTEAD.
namespace cbm::algo::BuildInfo {
const std::string GIT_HASH = "@GIT_HASH@";
const std::string BUILD_TYPE = "@BUILD_TYPE@";
const bool GPU_DEBUG = @GPU_DEBUG@;
} // namespace cbm::algo::BuildInfo
/* Copyright (C) 2022 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
SPDX-License-Identifier: GPL-3.0-only
Authors: Felix Weiglhofer [committer]*/
#ifndef CBM_ALGO_BUILD_INFO_H
#define CBM_ALGO_BUILD_INFO_H
#include <string>
namespace cbm::algo::BuildInfo
{
extern const std::string GIT_HASH;
extern const std::string BUILD_TYPE;
extern const bool GPU_DEBUG;
} // namespace cbm::algo::BuildInfo
#endif // CBM_ALGO_BUILD_INFO_H
execute_process(
COMMAND git log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT DEFINED INFILE)
message(FATAL_ERROR "INFILE not defined")
endif()
if (NOT DEFINED OUTFILE)
message(FATAL_ERROR "OUTFILE not defined")
endif()
if (NOT DEFINED XPU_DEBUG)
message(FATAL_ERROR "XPU_DEBUG not defined")
endif()
if (NOT DEFINED BUILD_TYPE)
message(FATAL_ERROR "BUILD_TYPE not defined")
endif()
# message(STATUS "Git hash: ${GIT_HASH}")
# message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
# message(STATUS "XPU_DEBUG: ${XPU_DEBUG}")
if (XPU_DEBUG)
set(GPU_DEBUG 1)
else()
set(GPU_DEBUG 0)
endif()
configure_file(
${INFILE}
${OUTFILE}
@ONLY
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment