Commit 83d7bf32bbdfb50a077daaa1d4cc9d611570b93e
Merge branch 'feat/pgroen/set_software_version' into 'master'
Add version information to projectheader Versioning as a submodule will be deprecated. To enable the version on libraries, we need to add version information ( obtained from git ) in the projectheader. This is a macro used in every makefile so it seems like the most logical place. See merge request !2
Showing
1 changed file
with
25 additions
and
0 deletions
projectheader.cmake
@@ -3,12 +3,37 @@ | @@ -3,12 +3,37 @@ | ||
3 | # @param CURRENT_PROJECT_BINARY_DIR [optional] Override for the default project binary dir (PROJECT_BINARY_DIR for executables, CMAKE_BINARY_DIR for libraries). | 3 | # @param CURRENT_PROJECT_BINARY_DIR [optional] Override for the default project binary dir (PROJECT_BINARY_DIR for executables, CMAKE_BINARY_DIR for libraries). |
4 | macro ( project_header CURRENT_PROJECT_NAME ) | 4 | macro ( project_header CURRENT_PROJECT_NAME ) |
5 | 5 | ||
6 | +# Determine the version and fill the following variables : | ||
7 | +# SOVERSION : The tag from the git-repository. Not necessarily a number-only string. | ||
8 | +find_package(Git QUIET) | ||
9 | + | ||
10 | +if(GIT_FOUND) | ||
11 | + if( EXISTS "${PROJECT_SOURCE_DIR}/.git") | ||
12 | + execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --tags | ||
13 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
14 | + OUTPUT_VARIABLE CURRENT_PROJECT_VERSION | ||
15 | + OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
16 | + message( STATUS "================================================================" ) | ||
17 | + message( STATUS "Found the following tag : ${CURRENT_PROJECT_VERSION}") | ||
18 | + message( STATUS "================================================================" ) | ||
19 | + else() | ||
20 | + message( STATUS ".git directory does not exists..") | ||
21 | + message( STATUS "Project directory : ${PROJECT_SOURCE_DIR}") | ||
22 | + endif() | ||
23 | +else() | ||
24 | + message( STATUS "git-command not found....") | ||
25 | + message( FATAL "Unable to determine the version of the software.") | ||
26 | +endif() | ||
27 | + | ||
6 | message( STATUS "" ) | 28 | message( STATUS "" ) |
7 | message( STATUS "================================================================" ) | 29 | message( STATUS "================================================================" ) |
8 | message( STATUS "Creating Makefile of ${CURRENT_PROJECT_NAME}" ) | 30 | message( STATUS "Creating Makefile of ${CURRENT_PROJECT_NAME}" ) |
9 | message( STATUS "================================================================" ) | 31 | message( STATUS "================================================================" ) |
10 | message( STATUS "CURRENT_PROJECT_VERSION: ${CURRENT_PROJECT_VERSION}" ) | 32 | message( STATUS "CURRENT_PROJECT_VERSION: ${CURRENT_PROJECT_VERSION}" ) |
11 | 33 | ||
34 | +set(SOVERSION "${CURRENT_PROJECT_VERSION}") | ||
35 | +set(VERSION "${CURRENT_PROJECT_VERSION}") | ||
36 | + | ||
12 | project(${CURRENT_PROJECT_NAME} VERSION ${CURRENT_PROJECT_VERSION}) | 37 | project(${CURRENT_PROJECT_NAME} VERSION ${CURRENT_PROJECT_VERSION}) |
13 | set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES 1) | 38 | set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES 1) |
14 | 39 |