use cmake project version facility

This commit is contained in:
Julius Pfrommer
2016-12-07 11:18:56 +01:00
committed by Julius Pfrommer
parent 58ce90e99d
commit 2cabd7c5d9
4 changed files with 37 additions and 28 deletions
+20 -22
View File
@@ -1,33 +1,31 @@
cmake_minimum_required(VERSION 2.8.11)
project(open62541)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/cmake")
# set(CMAKE_VERBOSE_MAKEFILE ON)
######################
# Check Dependencies #
######################
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/cmake")
find_package(PythonInterp REQUIRED)
find_package(Git)
###########
# Version #
###########
set(OPEN62541_VER_MAJOR 0)
set(OPEN62541_VER_MINOR 2)
set(OPEN62541_VER_PATCH 0)
set(OPEN62541_VER_LABEL "-rc2") # Appended to the X.Y.Z version format. For example "-rc1" or an empty string
# Set OPEN62541_VER_COMMIT
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COM_ID WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --always --tags
RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_REL_ID WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
if(NOT ${res_var} EQUAL 0)
set(GIT_COMMIT_ID "commit id unknown")
set(GIT_RELEASE_ID "release unknown")
message(STATUS "Git failed (not a repo, or no tags). Build will not contain git revision info." )
else()
string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COM_ID} )
string(REPLACE "\n" "" GIT_RELEASE_ID ${GIT_REL_ID} )
if(${res_var} EQUAL 0)
string(REPLACE "\n" "" OPEN62541_VER_COMMIT ${GIT_COM_ID} )
endif()
else()
set(GIT_COMMIT_ID "commit id unknown")
set(GIT_RELEASE_ID "release unknown")
message(STATUS "Git not found. Build will not contain git revision info." )
endif()
message(STATUS "Git version: " ${GIT_COMMIT_ID})
if(NOT ${OPEN62541_VER_COMMIT})
set(OPEN62541_VER_COMMIT "undefined")
endif()
############
# Settings #
@@ -337,7 +335,7 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespaceinit_g
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.h
PRE_BUILD
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
${GIT_COMMIT_ID} ${CMAKE_CURRENT_BINARY_DIR}/open62541.h ${exported_headers}
${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.h ${exported_headers}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
${exported_headers}
${internal_headers})
@@ -345,7 +343,7 @@ add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.h
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/open62541.c
PRE_BUILD
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py
${GIT_COMMIT_ID} ${CMAKE_CURRENT_BINARY_DIR}/open62541.c ${internal_headers}
${OPEN62541_VER_COMMIT} ${CMAKE_CURRENT_BINARY_DIR}/open62541.c ${internal_headers}
${PROJECT_SOURCE_DIR}/src/server/ua_nodestore_hash.inc ${lib_sources}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/amalgamate.py ${internal_headers}
${PROJECT_SOURCE_DIR}/src/server/ua_nodestore_hash.inc ${lib_sources})
@@ -393,7 +391,7 @@ target_compile_definitions(open62541-object PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
target_compile_definitions(open62541 PRIVATE -DUA_DYNAMIC_LINKING_EXPORT)
# Generate properly versioned shared library links on Linux
SET_TARGET_PROPERTIES(open62541 PROPERTIES SOVERSION 0 VERSION 0.2.0)
SET_TARGET_PROPERTIES(open62541 PROPERTIES SOVERSION 0 VERSION "${OPEN62541_VER_MAJOR}.${OPEN62541_VER_MINOR}.${OPEN62541_VER_PATCH}")
if(WIN32)
target_link_libraries(open62541 ws2_32)
+2 -2
View File
@@ -57,9 +57,9 @@ author = u'The open62541 authors'
# built documents.
#
# The short X.Y version.
version = "${GIT_RELEASE_ID}"
version = "${OPEN62541_VER_MAJOR}.${OPEN62541_VER_MINOR}"
# The full version, including alpha/beta/rc tags.
release = "${GIT_COMMIT_ID}"
release = "${OPEN62541_VER_MAJOR}.${OPEN62541_VER_MINOR}.${OPEN62541_VER_PATCH}${OPEN62541_VER_LABEL}"
# The full version, including alpha/beta/rc tags.
# The language for content autogenerated by Sphinx. Refer to documentation
+7 -3
View File
@@ -23,7 +23,11 @@ extern "C" {
/**
* Library Version
* --------------- */
#define UA_GIT_COMMIT_ID "${GIT_COMMIT_ID}"
#define UA_OPEN62541_VER_MAJOR ${OPEN62541_VER_MAJOR}
#define UA_OPEN62541_VER_MINOR ${OPEN62541_VER_MINOR}
#define UA_OPEN62541_VER_PATCH ${OPEN62541_VER_PATCH}
#define UA_OPEN62541_VER_LABEL "${OPEN62541_VER_LABEL}" /* Release candidate label, etc. */
#define UA_OPEN62541_VER_COMMIT "${OPEN62541_VER_COMMIT}"
/**
* Options
@@ -56,7 +60,7 @@ extern "C" {
#endif
#include <stddef.h>
#include "ms_stdint.h" /* includes stdint.h or a workaround for older Visual Studio versions */
#include "ms_stdint.h" /* Includes stdint.h or workaround for older Visual Studios */
#ifndef __cplusplus
# include <stdbool.h> /* C99 Boolean */
@@ -176,7 +180,7 @@ typedef uint8_t bool;
* Integer Endianness
* ^^^^^^^^^^^^^^^^^^ */
#if defined(_WIN32) || (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) /* little endian detected */
(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
# define UA_BINARY_OVERLAYABLE_INTEGER true
#elif defined(__ANDROID__) /* Andoid */
# include <endian.h>
+8 -1
View File
@@ -30,6 +30,10 @@ const UA_EXPORT UA_ConnectionConfig UA_ConnectionConfig_standard = {
#define UA_STRING_STATIC(s) {sizeof(s)-1, (UA_Byte*)s}
#define UA_STRING_STATIC_NULL {0, NULL}
#define STRINGIFY(arg) #arg
#define VERSION(MAJOR, MINOR, PATCH, LABEL) \
STRINGIFY(MAJOR) "." STRINGIFY(MINOR) "." STRINGIFY(PATCH) LABEL
UA_UsernamePasswordLogin usernamePasswords[2] = {
{ UA_STRING_STATIC("user1"), UA_STRING_STATIC("password") },
{ UA_STRING_STATIC("user2"), UA_STRING_STATIC("password1") } };
@@ -43,7 +47,10 @@ const UA_EXPORT UA_ServerConfig UA_ServerConfig_standard = {
.productUri = UA_STRING_STATIC(PRODUCT_URI),
.manufacturerName = UA_STRING_STATIC(MANUFACTURER_NAME),
.productName = UA_STRING_STATIC(PRODUCT_NAME),
.softwareVersion = UA_STRING_STATIC(UA_GIT_COMMIT_ID),
.softwareVersion = UA_STRING_STATIC(VERSION(UA_OPEN62541_VER_MAJOR,
UA_OPEN62541_VER_MINOR,
UA_OPEN62541_VER_PATCH,
UA_OPEN62541_VER_LABEL)),
.buildNumber = UA_STRING_STATIC(__DATE__ " " __TIME__),
.buildDate = 0 },
.applicationDescription = {