summaryrefslogtreecommitdiff
path: root/cmake/modules
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules')
-rw-r--r--cmake/modules/BasicFindPackageVersion.cmake.in30
-rw-r--r--cmake/modules/MacroWriteBasicCMakeVersionFile.cmake21
-rw-r--r--cmake/modules/TelepathyDefaults.cmake5
-rw-r--r--cmake/modules/TpQtMacros.cmake15
4 files changed, 71 insertions, 0 deletions
diff --git a/cmake/modules/BasicFindPackageVersion.cmake.in b/cmake/modules/BasicFindPackageVersion.cmake.in
new file mode 100644
index 00000000..2be6d9ec
--- /dev/null
+++ b/cmake/modules/BasicFindPackageVersion.cmake.in
@@ -0,0 +1,30 @@
+# This is a very basic file for the new style find_package() search mode,
+# i.e. Config-mode. It is used by MACRO_WRITE_BASIC_CMAKE_VERSION_FILE() from
+# MacroWriteBasicCMakeVersionFile.cmake.
+# In this mode find_package() searches for a <package>Config.cmake
+# file and an associated <package>Version.cmake file, which it loads to check
+# the version number.
+# This file can be used with configure_file() to generate such a file for a project
+# with very basic logic.
+# It sets PACKAGE_VERSION_EXACT if the current version string and the requested
+# version string are exactly the same and it sets PACKAGE_VERSION_COMPATIBLE
+# if the current version is >= requested version.
+# If this is not good enough for your project, you need to write your own
+# improved <package>Version.cmake file.
+# This file requires the following three variables to be set:
+# PROJECT_VERSION_MAJOR
+# PROJECT_VERSION_MINOR
+# PROJECT_VERSION_PATCH
+
+
+set(PACKAGE_VERSION @PROJECT_VERSION_FULL@)
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+endif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+
diff --git a/cmake/modules/MacroWriteBasicCMakeVersionFile.cmake b/cmake/modules/MacroWriteBasicCMakeVersionFile.cmake
new file mode 100644
index 00000000..d23d857b
--- /dev/null
+++ b/cmake/modules/MacroWriteBasicCMakeVersionFile.cmake
@@ -0,0 +1,21 @@
+# MACRO_WRITE_BASIC_CMAKE_VERSION_FILE( _filename _major _minor _patch)
+# Writes a file for use as <package>ConfigVersion.cmake file to <_filename>.
+# See the documentation of FIND_PACKAGE() for details on this.
+# _filename is the output filename, it should be in the build tree.
+# _major is the major version number of the project to be installed
+# _minor is the minor version number of the project to be installed
+# _patch is the patch version number of the project to be installed
+#
+
+# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
+# Copyright (c) 2010, Collabora Ltd., <http://www.collabora.co.uk/>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+get_filename_component(_currentListFileDir ${CMAKE_CURRENT_LIST_FILE} PATH)
+
+function(MACRO_WRITE_BASIC_CMAKE_VERSION_FILE _filename _version)
+ set(PROJECT_VERSION_FULL ${_version})
+ configure_file(${_currentListFileDir}/BasicFindPackageVersion.cmake.in "${_filename}" @ONLY)
+endfunction(MACRO_WRITE_BASIC_CMAKE_VERSION_FILE _major _minor _patch)
diff --git a/cmake/modules/TelepathyDefaults.cmake b/cmake/modules/TelepathyDefaults.cmake
index 7796cc08..a7bf77a5 100644
--- a/cmake/modules/TelepathyDefaults.cmake
+++ b/cmake/modules/TelepathyDefaults.cmake
@@ -13,6 +13,11 @@ set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
# Use colored output
set(CMAKE_COLOR_MAKEFILE ON)
+# Add an option to decide where to install the config files
+if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.6.2)
+ option(USE_COMMON_CMAKE_PACKAGE_CONFIG_DIR "Prefer to install the <package>Config.cmake files to lib/cmake/<package> instead of lib/<package>/cmake" TRUE)
+endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} VERSION_GREATER 2.6.2)
+
# Set compiler flags
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb")
diff --git a/cmake/modules/TpQtMacros.cmake b/cmake/modules/TpQtMacros.cmake
index e77a5435..a3a89428 100644
--- a/cmake/modules/TpQtMacros.cmake
+++ b/cmake/modules/TpQtMacros.cmake
@@ -104,6 +104,13 @@
# This function MUST be called before calling TPQT_ADD_DBUS_UNIT_TEST. It takes care of preparing the test
# environment for DBus tests and generating the needed files.
#
+# macro MAKE_INSTALL_PATH_ABSOLUTE (out in)
+# This macro makes the path given in the "in" variable absolute (or leaves it unchanged
+# if it's absolute already) by prefixing it with TELEPATHY_QT_INSTALL_DIR,
+# and returns the absolute path in the "out" variable. This macro is mainly used for
+# generating *Config.cmake files.
+#
+#
MACRO (TPQT_EXTRACT_DEPENDS _tpqt_other _tpqt_depends)
SET(${_tpqt_other})
@@ -433,3 +440,11 @@ sh ${CMAKE_SOURCE_DIR}/tools/with-session-bus.sh \\
--config-file=${CMAKE_BINARY_DIR}/tests/dbus-1/session.conf -- $@
")
endfunction(tpqt_setup_dbus_test_environment)
+
+macro(make_install_path_absolute out in)
+ if (IS_ABSOLUTE "${in}")
+ set(${out} "${in}")
+ else (IS_ABSOLUTE "${in}")
+ set(${out} "\${TELEPATHY_QT${QT_VERSION_MAJOR}_INSTALL_DIR}/${in}")
+ endif (IS_ABSOLUTE "${in}")
+endmacro(make_install_path_absolute out in)