summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri Stolnikov <horiz0n@gmx.net>2013-06-02 14:33:00 +0200
committerDimitri Stolnikov <horiz0n@gmx.net>2013-06-04 20:32:31 +0200
commitb697821a8d779f5993e2f245b854c6444d426b7b (patch)
tree2f3e0a02de0e80c3268a2eebca52eea14211eada
parent0e00ac466390d76686264c103bd91be57a0daa09 (diff)
cmake: add version module
-rw-r--r--software/libosmosdr/CMakeLists.txt12
-rw-r--r--software/libosmosdr/cmake/Modules/Version.cmake60
-rw-r--r--software/libosmosdr/src/CMakeLists.txt3
3 files changed, 74 insertions, 1 deletions
diff --git a/software/libosmosdr/CMakeLists.txt b/software/libosmosdr/CMakeLists.txt
index 60f43d8..a12bf02 100644
--- a/software/libosmosdr/CMakeLists.txt
+++ b/software/libosmosdr/CMakeLists.txt
@@ -32,6 +32,12 @@ set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
+# Set the version information here
+set(VERSION_INFO_MAJOR_VERSION 0) # increment major on api compatibility changes
+set(VERSION_INFO_MINOR_VERSION 0) # increment minor on feature-level changes
+set(VERSION_INFO_PATCH_VERSION git) # increment patch for bug fixes and docs
+include(Version) # setup version info
+
########################################################################
# Compiler specific setup
########################################################################
@@ -136,3 +142,9 @@ INSTALL(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libosmosdr.pc
DESTINATION lib/pkgconfig
)
+
+########################################################################
+# Print Summary
+########################################################################
+MESSAGE(STATUS "Building for version: ${VERSION} / ${LIBVER}")
+MESSAGE(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
diff --git a/software/libosmosdr/cmake/Modules/Version.cmake b/software/libosmosdr/cmake/Modules/Version.cmake
new file mode 100644
index 0000000..2d4e76d
--- /dev/null
+++ b/software/libosmosdr/cmake/Modules/Version.cmake
@@ -0,0 +1,60 @@
+# Copyright 2013 OSMOCOM Project
+#
+# This file is part of rtl-sdr
+#
+# rtl-sdr is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# rtl-sdr is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with rtl-sdr; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+if(DEFINED __INCLUDED_VERSION_CMAKE)
+ return()
+endif()
+set(__INCLUDED_VERSION_CMAKE TRUE)
+
+# VERSION_INFO_* variables must be provided by user
+set(MAJOR_VERSION ${VERSION_INFO_MAJOR_VERSION})
+set(MINOR_VERSION ${VERSION_INFO_MINOR_VERSION})
+set(PATCH_VERSION ${VERSION_INFO_PATCH_VERSION})
+
+########################################################################
+# Extract the version string from git describe.
+########################################################################
+find_package(Git QUIET)
+
+if(GIT_FOUND)
+ message(STATUS "Extracting version information from git describe...")
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=4 --long
+ OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+else()
+ set(GIT_DESCRIBE "v${MAJOR_VERSION}.${MINOR_VERSION}.x-xxx-xunknown")
+endif()
+
+########################################################################
+# Use the logic below to set the version constants
+########################################################################
+if("${PATCH_VERSION}" STREQUAL "git")
+ # VERSION: 3.6git-xxx-gxxxxxxxx
+ # LIBVER: 3.6git
+ set(VERSION "${GIT_DESCRIBE}")
+ set(LIBVER "${MAJOR_VERSION}.${MINOR_VERSION}${PATCH_VERSION}")
+else()
+ # This is a numbered release.
+ # VERSION: 3.6.1
+ # LIBVER: 3.6.1
+ set(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
+ set(LIBVER "${VERSION}")
+endif()
diff --git a/software/libosmosdr/src/CMakeLists.txt b/software/libosmosdr/src/CMakeLists.txt
index 0811a73..c9dc7c0 100644
--- a/software/libosmosdr/src/CMakeLists.txt
+++ b/software/libosmosdr/src/CMakeLists.txt
@@ -30,7 +30,8 @@ target_link_libraries(osmosdr_shared
set_target_properties(osmosdr_shared PROPERTIES DEFINE_SYMBOL "osmosdr_EXPORTS")
set_target_properties(osmosdr_shared PROPERTIES OUTPUT_NAME osmosdr)
-set_target_properties(osmosdr_shared PROPERTIES SOVERSION 0 VERSION 0.0.0)
+set_target_properties(osmosdr_shared PROPERTIES SOVERSION ${MAJOR_VERSION})
+set_target_properties(osmosdr_shared PROPERTIES VERSION ${LIBVER})
add_library(osmosdr_static STATIC
libosmosdr.c