summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2015-06-23 14:59:33 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2015-06-23 14:59:33 +0200
commitf3c6e08fe4068534373f8026892f569bdcdfa4dd (patch)
tree729385463df8c457e62c8fcfd8b2c01c826e1cb0
parentcc7465bec1ab0b12ca79758807788e4ac8fad765 (diff)
downloadlibufodecode-f3c6e08fe4068534373f8026892f569bdcdfa4dd.tar.gz
libufodecode-f3c6e08fe4068534373f8026892f569bdcdfa4dd.tar.bz2
libufodecode-f3c6e08fe4068534373f8026892f569bdcdfa4dd.tar.xz
libufodecode-f3c6e08fe4068534373f8026892f569bdcdfa4dd.zip
Use ConfigurePaths to configure paths
-rw-r--r--CMakeLists.txt32
-rw-r--r--ConfigurePaths.cmake90
-rw-r--r--src/CMakeLists.txt14
-rw-r--r--test/CMakeLists.txt6
-rw-r--r--ufodecode.pc.in16
5 files changed, 112 insertions, 46 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 231aa15..0b68b35 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,37 +1,19 @@
cmake_minimum_required(VERSION 2.8)
-set(TARNAME "libufodecode")
set(LIBUFODECODE_API_VERSION "0.3")
set(LIBUFODECODE_ABI_VERSION "0.3")
set(LIBUFODECODE_ABI_MAJOR_VERSION "0")
+set(LIBUFODECODE_VERSION "0.3.0")
-set(PACKAGE_VERSION "0.3.0")
-set(PACKAGE_NAME "${TARNAME}")
-set(PACKAGE_TARNAME "${TARNAME}")
-set(PACKAGE_STRING "${PACKAGE_NAME}-${PACKAGE_VERSION}")
-set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
-set(CPACK_SOURCE_GENERATOR "TGZ")
-set(CPACK_SOURCE_IGNORE_FILES ".git" "tags" ".bzr" ".swp")
-set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_STRING} CACHE INTERNAL "tarball basename")
+include(ConfigurePaths)
+configure_paths(LIBUFODECODE)
-if(NOT DEFINED BIN_INSTALL_DIR)
- set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
-endif(NOT DEFINED BIN_INSTALL_DIR)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ufodecode.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/ufodecode.pc"
+ @ONLY IMMEDIATE)
-if(NOT DEFINED LIB_INSTALL_DIR)
- set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib")
-endif(NOT DEFINED LIB_INSTALL_DIR)
-
-if(NOT DEFINED INCLUDE_INSTALL_DIR)
- set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
-endif(NOT DEFINED INCLUDE_INSTALL_DIR)
-
-if(NOT DEFINED LOCALE_INSTALL_DIR)
- set(LOCALE_INSTALL_DIR "${DATA_INSTALL_DIR}/locale/")
-endif(NOT DEFINED LOCALE_INSTALL_DIR)
-
-configure_file(ufodecode.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ufodecode.pc)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/ufodecode.pc
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
diff --git a/ConfigurePaths.cmake b/ConfigurePaths.cmake
new file mode 100644
index 0000000..df9c03c
--- /dev/null
+++ b/ConfigurePaths.cmake
@@ -0,0 +1,90 @@
+# - pre-configured paths for CMake
+#
+# Usage:
+# configure_paths(<PREFIX>)
+#
+# Checks if configure-like prefix and installation paths were passed by the user
+# and sets up corresponding variables for use in install() commands and to fill
+# out .pc files:
+#
+# PREFIX_PREFIX defaults to ... CMAKE_INSTALL_PREFIX
+# PREFIX_EPREFIX PREFIX_PREFIX
+# PREFIX_SBINDIR PREFIX_EPREFIX/sbin
+# PREFIX_SYSCONFDIR PREFIX_PREFIX/etc
+# PREFIX_LOCALSTATEDIR PREFIX_PREFIX/var
+# PREFIX_BINDIR PREFIX_EPREFIX/bin
+# PREFIX_LIBDIR PREFIX_EPREFIX/lib
+# PREFIX_INCLUDEDIR PREFIX_PREFIX/include
+# PREFIX_PKGCONFIGDIR PREFIX_LIBDIR/pkgconfig
+# PREFIX_TYPELIBDIR PREFIX_LIBDIR/girepository-1.0
+# PREFIX_DATAROOTDIR PREFIX_PREFIX/share
+# PREFIX_DATADIR PREFIX_DATAROOTDIR
+# PREFIX_INFODIR PREFIX_DATAROOTDIR/info
+# PREFIX_MANDIR PREFIX_DATAROOTDIR/man
+# PREFIX_LOCALEDIR PREFIX_DATAROOTDIR/locale
+# PREFIX_GIRDIR PREFIX_DATAROOTDIR/gir-1.0
+
+# Copyright (C) 2013 Matthias Vogelgesang <matthias.vogelgesang@gmail.com>
+#
+# Redistribution and use, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+# 1. Redistributions must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+# 2. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+if(__configure_paths)
+ return()
+endif()
+
+set(__configure_paths YES)
+
+macro(_set_var _prefix _var _user _override _description)
+ set(_name "${_prefix}_${_var}")
+
+ set("${_name}" "${_user}")
+
+ if("${_name}" STREQUAL "")
+ set("${_name}" "${_override}")
+ endif()
+
+ set(${_name} "${${_name}}" CACHE PATH "${_description}")
+ mark_as_advanced(${_name})
+endmacro()
+
+function(configure_paths _prefix)
+ _set_var("${_prefix}" "PREFIX" "${PREFIX}" "${CMAKE_INSTALL_PREFIX}" "install architecture-independent files in PREFIX")
+ _set_var("${_prefix}" "EPREFIX" "${EXEC_PREFIX}" "${${_prefix}_PREFIX}" "install architecture-dependent files in EPREFIX")
+
+ _set_var("${_prefix}" "SBINDIR" "${SBINDIR}" "${${_prefix}_EPREFIX}/sbin" "system admin executabls")
+ _set_var("${_prefix}" "SYSCONFDIR" "${SYSCONFDIR}" "${${_prefix}_PREFIX}/etc" "read-only single-machine data")
+ _set_var("${_prefix}" "LOCALSTATEDIR" "${LOCALSTATEDIR}" "${${_prefix}_PREFIX}/var" "modifiable single-machine data")
+ _set_var("${_prefix}" "BINDIR" "${BINDIR}" "${${_prefix}_EPREFIX}/bin" "user executables")
+ _set_var("${_prefix}" "LIBDIR" "${LIBDIR}" "${${_prefix}_EPREFIX}/lib" "object code libraries")
+ _set_var("${_prefix}" "INCLUDEDIR" "${INCLUDEDIR}" "${${_prefix}_PREFIX}/include" "C header files")
+ _set_var("${_prefix}" "PKGCONFIGDIR" "${PKGCONFIGDIR}" "${${_prefix}_LIBDIR}/pkgconfig" "pkg-config files")
+ _set_var("${_prefix}" "TYPELIBDIR" "${TYPELIBDIR}" "${${_prefix}_LIBDIR}/girepository-1.0" "GObject run-time introspection data")
+ _set_var("${_prefix}" "DATAROOTDIR" "${DATAROOTDIR}" "${${_prefix}_PREFIX}/share" "read-only arch.-independent data root")
+ _set_var("${_prefix}" "DATADIR" "${DATADIR}" "${${_prefix}_DATAROOTDIR}" "read-only architecture-independent data")
+ _set_var("${_prefix}" "INFODIR" "${INFODIR}" "${${_prefix}_DATAROOTDIR}/info" "info documentation")
+ _set_var("${_prefix}" "MANDIR" "${MANDIR}" "${${_prefix}_DATAROOTDIR}/man" "man documentation")
+ _set_var("${_prefix}" "LOCALEDIR" "${LOCALEDIR}" "${${_prefix}_DATAROOTDIR}/locale" "locale-dependent data")
+ _set_var("${_prefix}" "GIRDIR" "${GIRDIR}" "${${_prefix}_DATAROOTDIR}/gir-1.0" "GObject introspection data")
+endfunction()
+
+# vim: tw=0:
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 313b932..85feff4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,6 +31,9 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}
)
+configure_file("config.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/config.h")
+
add_definitions("--std=c99 -Wall -O2 ${SSE_FLAGS}")
add_library(ufodecode SHARED ufodecode.c)
@@ -41,17 +44,10 @@ set_target_properties(ufodecode PROPERTIES
)
install(TARGETS ufodecode
- LIBRARY DESTINATION lib${LIB_SUFFIX}
+ LIBRARY DESTINATION ${LIBUFODECODE_LIBDIR}
)
install(FILES
ufodecode.h
- DESTINATION include
+ DESTINATION ${LIBUFODECODE_INCLUDEDIR}
)
-
-if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
- set(DEBUG "1")
-endif()
-
-configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
-
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7539c19..b0214d4 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -11,10 +11,8 @@ include_directories(
${CMAKE_SOURCE_DIR}/src
)
-add_executable(ipedec
- ipedec.c
- timer.c)
+add_executable(ipedec ipedec.c timer.c)
target_link_libraries(ipedec ufodecode)
-install(TARGETS ipedec DESTINATION ${BIN_INSTALL_DIR})
+install(TARGETS ipedec DESTINATION ${LIBUFODECODE_BINDIR})
diff --git a/ufodecode.pc.in b/ufodecode.pc.in
index f9b007a..b4d9524 100644
--- a/ufodecode.pc.in
+++ b/ufodecode.pc.in
@@ -1,10 +1,10 @@
-prefix=${CMAKE_INSTALL_PREFIX}
-exec_prefix=${BIN_INSTALL_DIR}
-libdir=${LIB_INSTALL_DIR}
-includedir=${INCLUDE_INSTALL_DIR}
+prefix=@LIBUFODECODE_PREFIX@
+exec_prefix=@LIBUFODECODE_EPREFIX@
+libdir=@LIBUFODECODE_LIBDIR@
+includedir=@LIBUFODECODE_INCLUDEDIR@
-Name: ${TARNAME}
+Name: libufodecode
Description: Decoding routines for the UFO camera
-Version: ${PACKAGE_VERSION}
-Libs: -L${LIB_INSTALL_DIR} -lufodecode
-Cflags: -I${INCLUDE_INSTALL_DIR}
+Version: @LIBUFODECODE_VERSION@
+Libs: -L@LIBUFODECODE_LIBDIR@ -lufodecode
+Cflags: -I@LIBUFODECODE_INCLUDEDIR@