aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorMartin Hauke <mardnh@gmx.de>2015-08-30 13:58:59 +0200
committerMartin Hauke <mardnh@gmx.de>2015-08-30 13:58:59 +0200
commit1cd151e5ad88f132d8bde648229245eb9964c2a7 (patch)
tree8a7ac91c35e778bb6813dbf28b6f26cbc27a991d /cmake
parente4e098a6f92742f5db0755a7f032f49a41fbde06 (diff)
downloadtoolame-dab-1cd151e5ad88f132d8bde648229245eb9964c2a7.tar.gz
toolame-dab-1cd151e5ad88f132d8bde648229245eb9964c2a7.tar.bz2
toolame-dab-1cd151e5ad88f132d8bde648229245eb9964c2a7.zip
Rewrote CMake support
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/Version.cmake115
-rw-r--r--cmake/cmake_uninstall.cmake.in21
2 files changed, 136 insertions, 0 deletions
diff --git a/cmake/Modules/Version.cmake b/cmake/Modules/Version.cmake
new file mode 100644
index 0000000..96ee6b7
--- /dev/null
+++ b/cmake/Modules/Version.cmake
@@ -0,0 +1,115 @@
+# Portions of this file have been borrowed from and/or inspired by
+# the Version.cmake from the rtl-sdr project.
+# http://sdr.osmocom.org/trac/wiki/rtl-sdr
+#
+# Provides:
+# ${VERSION_INFO_BASE} - Major.Minor.Patch
+# ${VERSION_INFO} - Major.minor.Patch[-git_info]
+#
+# Requires values for:
+# ${VERSION_INFO_MAJOR} - Increment on API compatibility changes.
+# ${VERSION_INFO_MINOR} - Increment when adding features.
+# ${VERSION_INFO_PATCH} - Increment for bug and documentation changes.
+#
+# Optional:
+# ${VERSION_INFO_EXTRA} - Set to "git" to append git info. This is
+# intended only for non-versioned development
+# builds
+# ${VERSION_INFO_OVERRIDE} - Set to a non-null value to override the
+# VERSION_INFO_EXTRA logic. This is intended
+# for automated snapshot builds from exported
+# trees, to pass in the git revision info.
+#
+if(DEFINED __INCLUDED_TOOLAME-DAB_VERSION_CMAKE)
+ return()
+endif()
+set(__INCLUDED_TOOLAME-DAB_VERSION_CMAKE TRUE)
+
+################################################################################
+# Gather up variables provided by parent script
+################################################################################
+
+if(NOT DEFINED VERSION_INFO_MAJOR)
+ message(FATAL_ERROR "VERSION_INFO_MAJOR is not defined")
+else()
+ set(VER_MAJ ${VERSION_INFO_MAJOR})
+endif()
+
+if(NOT DEFINED VERSION_INFO_MINOR)
+ message(FATAL_ERROR "VERSION_INFO_MINOR is not defined")
+else()
+ set(VER_MIN ${VERSION_INFO_MINOR})
+endif()
+
+if(NOT DEFINED VERSION_INFO_PATCH)
+ message(FATAL_ERROR "VERSION_INFO_PATCH is not defined")
+else()
+ set(VER_PAT ${VERSION_INFO_PATCH})
+endif()
+
+
+################################################################################
+# Craft version number, using git, if needed
+################################################################################
+find_package(Git QUIET)
+
+if(GIT_FOUND)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} rev-parse --
+ ERROR_QUIET
+ RESULT_VARIABLE NOT_GIT_REPOSITORY
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+
+ if(NOT_GIT_REPOSITORY)
+ set(GIT_INFO "-unknown")
+ else()
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD --
+ OUTPUT_VARIABLE GIT_REV OUTPUT_STRIP_TRAILING_WHITESPACE
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} diff-index --quiet HEAD --
+ RESULT_VARIABLE GIT_DIRTY
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+
+ if(GIT_DIRTY)
+ set(GIT_INFO "-${GIT_REV}-dirty")
+ else()
+ set(GIT_INFO "-${GIT_REV}")
+ endif()
+ endif()
+
+else()
+ message(WARNING "git missing -- unable to check libladeRF version.")
+ unset(NOT_GIT_REPOSITORY)
+ unset(GIT_REV)
+ unset(GIT_DIRTY)
+endif()
+
+
+################################################################################
+# Provide
+################################################################################
+set(VERSION_INFO_BASE "${VER_MAJ}.${VER_MIN}.${VER_PAT}")
+
+# Force the version suffix. Used for automated export builds.
+if(VERSION_INFO_OVERRIDE)
+ set(VERSION_INFO "${VERSION_INFO_BASE}-${VERSION_INFO_OVERRIDE}")
+
+# Intra-release builds
+elseif("${VERSION_INFO_EXTRA}" STREQUAL "git")
+ set(VERSION_INFO "${VERSION_INFO_BASE}-git${GIT_INFO}")
+
+# Versioned releases
+elseif("${VERSION_INFO_EXTRA}" STREQUAL "")
+ set(VERSION_INFO "${VERSION_INFO_BASE}")
+
+# Invalid
+else()
+ message(FATAL_ERROR
+ "Unexpected definition of VERSION_INFO_EXTRA: ${VERSION_INFO_EXTRA}")
+endif()
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..2037e36
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,21 @@
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif(NOT "${rm_retval}" STREQUAL 0)
+ else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)