Commit 82a21284 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD] - added more nice version file and automatic library versioning with...

[ADD] - added more nice version file and automatic library versioning with linking in binary dir. This is needed for install target and the packages. It makes release-builds even easier. No manual modifications anymore (besides VERSION file)
parent 38b4dd14
CHECKOUT
# OW Version File. This file specifies the version. The line VERSION=X.Y.Z is
# used and parsed. If you do not want a version, comment it out.
#
# IMPORTANT: If you modify the file, cmake re-creates the version header. But
# it is not able to set all library version. Please re-run cmake if
# you change something here.
#
# NOTE: do not add a space after #. The current CMake script will fail.
#VERSION=1.3.0
......@@ -168,6 +168,13 @@ ENDIF()
SET( OW_VERSION_HEADER ${PROJECT_SOURCE_DIR}/WVersion.h )
SETUP_VERSION_HEADER( ${OW_VERSION_HEADER} )
# Set the OW version string. This can be used by others for setting target versions during compilation.
GET_VERSION_STRING( dummy OW_VERSION "0.0.0 " )
IF( NOT DEFINED OW_VERSION )
# CMake does not like unset variables for target properties.
SET( OW_VERSION "0.0.0" )
ENDIF()
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# REQUIRED third party libs
......
......@@ -56,6 +56,9 @@ TARGET_LINK_LIBRARIES( ${LibName} ${OWExtBioSigName} ${OWExtEEPName} ${OWExtNift
# NOTE: this needs to be placed AFTER ADD_EXECUTABLE or ADD_LIBRARY
SETUP_USE_VERSION_HEADER( ${LibName} )
# Set the version of the library.
SET_TARGET_PROPERTIES( ${LibName} PROPERTIES VERSION ${OW_VERSION} )
# Do not forget the install targets
INSTALL( TARGETS ${LibName}
ARCHIVE # NOTE: this is needed on windows
......
......@@ -18,6 +18,9 @@ IF( CMAKE_HOST_SYSTEM MATCHES Windows )
TARGET_LINK_LIBRARIES( OWext_biosig ws2_32 )
ENDIF()
# Set the version of the library.
SET_TARGET_PROPERTIES( OWext_biosig PROPERTIES VERSION ${OW_VERSION} )
# install target
INSTALL( TARGETS OWext_biosig
ARCHIVE # NOTE: this is needed on windows
......
......@@ -18,6 +18,9 @@ IF( CMAKE_HOST_SYSTEM MATCHES Windows )
TARGET_LINK_LIBRARIES( OWext_biosig ws2_32 )
ENDIF()
# Set the version of the library.
SET_TARGET_PROPERTIES( OWext_biosig PROPERTIES VERSION ${OW_VERSION} )
# install target
INSTALL( TARGETS OWext_biosig
ARCHIVE # NOTE: this is needed on windows
......
......@@ -21,6 +21,9 @@ IF(MSVC_IDE)
SET_TARGET_PROPERTIES( OWext_eep PROPERTIES PREFIX "../")
ENDIF(MSVC_IDE)
# Set the version of the library.
SET_TARGET_PROPERTIES( OWext_eep PROPERTIES VERSION ${OW_VERSION} )
# install target
INSTALL( TARGETS OWext_eep
ARCHIVE # NOTE: this is needed on windows
......
......@@ -50,6 +50,11 @@ IF(UNIX)
TARGET_LINK_LIBRARIES(${NIFTI_NIFTILIB_NAME} -lm)
ENDIF(UNIX)
# Set the version of the library.
SET_TARGET_PROPERTIES( ${NIFTI_ZNZLIB_NAME} PROPERTIES VERSION ${OW_VERSION} )
# Set the version of the library.
SET_TARGET_PROPERTIES( ${NIFTI_NIFTILIB_NAME} PROPERTIES VERSION ${OW_VERSION} )
# install target
INSTALL( TARGETS ${NIFTI_NIFTILIB_NAME} ${NIFTI_ZNZLIB_NAME}
ARCHIVE # NOTE: this is needed on windows
......
......@@ -29,7 +29,6 @@
# Optional second Parameter: list of additional dependencies
# Optional third Parameter: list of style-excludes as regexp.
FUNCTION( ADD_MODULE _MODULE_NAME )
SET( MODULE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${_MODULE_NAME} )
# is there a CMakeLists.txt? If yes, use it.
......@@ -84,6 +83,9 @@ FUNCTION( SETUP_MODULE _MODULE_NAME _MODULE_SOURCE_DIR _MODULE_DEPENDENCIES _MOD
ADD_LIBRARY( ${MODULE_NAME} SHARED ${TARGET_CPP_FILES} ${TARGET_H_FILES} )
TARGET_LINK_LIBRARIES( ${MODULE_NAME} ${OWCoreName} ${Boost_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} ${_MODULE_DEPENDENCIES} )
# Set the version of the library.
SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES VERSION ${OW_VERSION} )
# Do not forget the install targets
# NOTE: do we really need to set all permissions explicitely?
INSTALL( TARGETS ${MODULE_NAME}
......
......@@ -253,8 +253,9 @@ ENDFUNCTION( SETUP_RESOURCES )
# empty, the contents of it get combined with the mercurial results if mercurial is installed. If not, only the file content will be used. If
# both methods fail, a default string is used.
# _version the returned version string
# _file_version returns only the version loaded from the version file. This is useful to set CMake version info for release compilation
# _default a default string you specify if all version check methods fail
FUNCTION( GET_VERSION_STRING _version _default )
FUNCTION( GET_VERSION_STRING _version _file_version _default )
# Undef the OW_VERSION variable
UNSET( OW_VERSION_HG )
UNSET( OW_VERSION_FILE )
......@@ -263,15 +264,22 @@ FUNCTION( GET_VERSION_STRING _version _default )
SET( OW_VERSION_FILENAME ${PROJECT_SOURCE_DIR}/../VERSION )
IF( EXISTS ${OW_VERSION_FILENAME} )
# Read the version file
FILE( READ ${OW_VERSION_FILENAME} OW_VERSION_FILE )
# this wil contain an line-break. Remove it.
STRING( REGEX REPLACE "\n" "" OW_VERSION_FILE "${OW_VERSION_FILE}" )
FILE( READ ${OW_VERSION_FILENAME} OW_VERSION_FILE_CONTENT )
# The first regex will mathc
STRING(REGEX REPLACE ".*[^#]VERSION=([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" OW_VERSION_FILE ${OW_VERSION_FILE_CONTENT} )
STRING( COMPARE EQUAL ${OW_VERSION_FILE} ${OW_VERSION_FILE_CONTENT} OW_VERSION_FILE_INVALID )
IF( OW_VERSION_FILE_INVALID )
UNSET( OW_VERSION_FILE )
ENDIF()
# this is ugly because, if the version file is empty, the OW_VERSION_FILE content is "". Unfortunately, this is not UNDEFINED as it would be
# by SET( VAR "" ) ... so set it manually
IF( OW_VERSION_FILE STREQUAL "" )
UNSET( OW_VERSION_FILE )
ENDIF()
# set the return parameter too
SET( ${_file_version} ${OW_VERSION_FILE} PARENT_SCOPE )
ENDIF()
# Use hg to query version information.
......
......@@ -28,5 +28,5 @@
# know.)
INCLUDE( BuildUtils.cmake )
GET_VERSION_STRING( OW_VERSION "Unknown Tarball Version" )
GET_VERSION_STRING( OW_VERSION OW_FILE_VERSION "0.0.0" )
FILE( WRITE ${HEADER_FILENAME} "// generated by CMake. Do not modify.\n#define W_VERSION \"${OW_VERSION}\"\n" )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment