Skip to content

Commit b1f9ac3

Browse files
author
Nicolas Laurent
committed
Version is deduced from git tag
1 parent 837f889 commit b1f9ac3

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

remoting/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
3939

4040
message("FMI_PLATFORM: ${FMI_PLATFORM}")
4141

42+
# Version.h creation
43+
find_package(Git QUIET)
44+
if(NOT Git_FOUND)
45+
message(WARNING "Git not found")
46+
set(GIT_TAG, "LOCAL Version")
47+
else()
48+
execute_process(
49+
COMMAND ${GIT_EXECUTABLE} describe --tags --always
50+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
51+
OUTPUT_VARIABLE GIT_TAG
52+
OUTPUT_STRIP_TRAILING_WHITESPACE
53+
RESULT_VARIABLE GIT_RESULT
54+
)
55+
endif()
56+
message("--- Version: ${GIT_TAG}")
57+
configure_file(
58+
${CMAKE_SOURCE_DIR}/version.h.in
59+
${CMAKE_CURRENT_BINARY_DIR}/version.h
60+
)
61+
62+
63+
4264
if (MSVC)
4365
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
4466
endif ()

remoting/client.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "client.h"
2626
#include "communication.h"
2727
#include "process.h"
28+
#include "version.h"
2829

2930
//#define CLIENT_DEBUG
3031
#ifdef CLIENT_DEBUG
@@ -320,7 +321,7 @@ static client_t* client_new(const char *filename, const char *instanceName, cons
320321
client->instance_name = strdup(instanceName);
321322
client->is_debug = loggingOn;
322323

323-
LOG_DEBUG(client, "FMU Remoting Interface version %s", REMOTING_VERSION);
324+
LOG_DEBUG(client, "FMU Remoting Interface version %s", VERSION_TAG);
324325
client_new_key(client);
325326

326327
fp = fopen(filename, "rt");

remoting/version.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

remoting/version.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef VERSION_H
2+
# define VERSION_H
3+
4+
#define VERSION_TAG "@GIT_TAG@"
5+
6+
#endif

0 commit comments

Comments
 (0)