Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions SilKit/include/silkit/capi/SilKitVersionMacros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2022 Vector Informatik GmbH
//
// SPDX-License-Identifier: MIT

#pragma once

#define SILKIT_GIT_HASH "f3b467c2028695e487d0337868ddae43a5674fe7"
#define SILKIT_VERSION_MAJOR 5
#define SILKIT_VERSION_MINOR 0
#define SILKIT_VERSION_PATCH 6
#define SILKIT_BUILD_NUMBER 0
#define SILKIT_VERSION_STRING "5.0.6"
#define SILKIT_VERSION_SUFFIX ""
45 changes: 10 additions & 35 deletions SilKit/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,20 @@ add_subdirectory(dashboard)

find_package(Threads REQUIRED)

# Encode the current GIT and version infos into version_macros.hpp
# If this file is present in the current source directory we assume
# that this source-tree is a non-git/packaged source tree and re-use
# the file unmodified.
set(GIT_DIR "${PROJECT_SOURCE_DIR}/../.git")
set(GIT_HEAD_FILE "${GIT_DIR}/HEAD")
set(VERSION_MACROS_HPP ${CMAKE_CURRENT_BINARY_DIR}/version_macros.hpp)
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/version_macros.hpp)
message(STATUS "SIL Kit: using deployed version_macros.hpp")
set(VERSION_MACROS_HPP ${CMAKE_CURRENT_LIST_DIR}/version_macros.hpp)
elseif(EXISTS "${GIT_HEAD_FILE}")
configure_file(
"MakeVersionMacros.cmake.in"
${CMAKE_CURRENT_BINARY_DIR}/MakeVersionMacros.cmake
@ONLY)
include(${CMAKE_CURRENT_BINARY_DIR}/MakeVersionMacros.cmake)
if(SILKIT_INSTALL_SOURCE)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/version_macros.hpp
DESTINATION
${INSTALL_SOURCE_DIR}/SilKit/source
COMPONENT source
)
endif()
else()
message(STATUS "SIL Kit: Cannot determine hash of current git head! GIT_HEAD_HASH will be set to UNKNOWN")
set(GIT_HEAD_HASH "UNKNOWN")
configure_file(
version_macros.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/version_macros.hpp
@ONLY)
# SilKitVersionMacros.h is committed to source and updated by running sil-kit-version-gen.
# No generation at configure time — any build tool can use the file as a regular source file.
# To update: sil-kit-version-gen --major X --minor Y --patch Z [--source-dir .] <path-to-header>
set(VERSION_MACROS_HPP "${CMAKE_CURRENT_LIST_DIR}/../include/silkit/capi/SilKitVersionMacros.h")
if(NOT EXISTS "${VERSION_MACROS_HPP}")
message(FATAL_ERROR
"SilKitVersionMacros.h not found. Run sil-kit-version-gen to create it:\n"
" sil-kit-version-gen --major ${SILKIT_VERSION_MAJOR} --minor ${SILKIT_VERSION_MINOR}"
" --patch ${SILKIT_VERSION_PATCH} ${VERSION_MACROS_HPP}")
endif()
# now install the configured version_macros.hpp as a header into the `include/silkit/capi` directory.
# NB please keep the version_macros.hpp C11 compatible!

install(FILES
${VERSION_MACROS_HPP}
DESTINATION ${INSTALL_INCLUDE_DIR}/silkit/capi
RENAME SilKitVersionMacros.h
COMPONENT dev
)

Expand Down Expand Up @@ -183,7 +159,6 @@ target_link_libraries(O_SilKit_CreateSilKitRegistryImpl
add_library(O_SilKit_VersionImpl OBJECT
SilKitVersionImpl.cpp
SilKitVersionImpl.hpp
${VERSION_MACROS_HPP}
)

target_link_libraries(O_SilKit_VersionImpl
Expand Down
47 changes: 0 additions & 47 deletions SilKit/source/MakeVersionMacros.cmake.in

This file was deleted.

2 changes: 1 addition & 1 deletion SilKit/source/SilKit.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <WINVER.H>
#include "version_macros.hpp"
#include "silkit/capi/SilKitVersionMacros.h"
#pragma code_page(65001) // UTF-8 for © symbol

#define STRING_HELPER(x) #x
Expand Down
2 changes: 1 addition & 1 deletion SilKit/source/SilKitVersionImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "SilKitVersionImpl.hpp"

#include "version_macros.hpp"
#include "silkit/capi/SilKitVersionMacros.h"

namespace SilKit {
namespace Version {
Expand Down
8 changes: 8 additions & 0 deletions SilKit/source/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,12 @@ add_silkit_test_to_executable(SilKitUnitTests
)


add_executable(SilKit_version_gen sil-kit-version-gen.cpp)
set_target_properties(SilKit_version_gen PROPERTIES
CXX_STANDARD 17
OUTPUT_NAME "sil-kit-version-gen"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIG>"
)


add_subdirectory(tests)
Loading
Loading