rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit 7c8869770146088b221043ed55bb98e8fa15276d
parent 7b46a88b4c3cb8651df3259d3baf6d02015ac98e
Author: vaplv <vaplv@free.fr>
Date:   Thu,  5 Dec 2013 14:35:12 +0100

Modifications on the version management of the lib

The major, minor and patch versions of the library are directly
extracted from `rsys' header

Diffstat:
Msrc/CMakeLists.txt | 23+++++++++++++++++------
Msrc/rsys.h | 4++++
2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -25,10 +25,21 @@ add_definitions(-D_POSIX_C_SOURCE=200112L) ################################################################################ # Define targets ################################################################################ -set(RSYS_VERSION_MAJOR 0) -set(RSYS_VERSION_MINOR 0) -set(RSYS_VERSION_PATCH 0) +macro(version_get component) + file(STRINGS "rsys.h" RSYS_VERSION_${component}_LINE + REGEX "^#define[ \t]+RSYS_VERSION_${component}[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+RSYS_VERSION_${component}[ \t]+([0-9]+)$" "\\1" + RSYS_VERSION_${component} "${RSYS_VERSION_${component}_LINE}") + if(RSYS_VERSION_${component} STREQUAL "") + message(FATAL_ERROR "The ${component} version of the library can't be defined") + endif() +endmacro() +version_get(MAJOR) +version_get(MINOR) +version_get(PATCH) + set(RSYS_VERSION ${RSYS_VERSION_MAJOR}.${RSYS_VERSION_MINOR}.${RSYS_VERSION_PATCH}) +message(STATUS "Current library version: ${RSYS_VERSION}") set(RSYS_FILES_SRC clock_time.c @@ -50,9 +61,9 @@ set(RSYS_FILES_INC add_library(rsys SHARED ${RSYS_FILES_SRC} ${RSYS_FILES_INC}) target_link_libraries(rsys dl rt) -set_target_properties(rsys PROPERTIES +set_target_properties(rsys PROPERTIES DEFINE_SYMBOL RSYS_SHARED_BUILD - VERSION ${RSYS_VERSION} + VERSION ${RSYS_VERSION} SOVERSION ${RSYS_VERSION_MAJOR}) ################################################################################ @@ -105,6 +116,6 @@ add_test(test_signal test_signal) ################################################################################ # Define output & install directories ################################################################################ -install(TARGETS rsys LIBRARY DESTINATION lib) +install(TARGETS rsys LIBRARY DESTINATION lib OPTIONAL NAMELINK_SKIP) install(FILES ${RSYS_FILES_INC} DESTINATION include/rsys) diff --git a/src/rsys.h b/src/rsys.h @@ -1,6 +1,10 @@ #ifndef RSYS_H #define RSYS_H +#define RSYS_VERSION_MAJOR 0 +#define RSYS_VERSION_MINOR 0 +#define RSYS_VERSION_PATCH 0 + #ifndef __GNUC__ #error "Unsupported compiler" #endif