summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2013-05-23 17:01:10 +0300
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2013-05-23 21:10:13 +0300
commit6624f10817da99a63253799f1f99162304cbd894 (patch)
treef3e38195e537c52f3ca9c4a8a4b171508bc9685e
parente8901e6eb70bde679fd324dc4a665c1257678559 (diff)
cmake: Use the new CMakePackageConfigHelpers
-rw-r--r--CMakeLists.txt9
-rw-r--r--cmake/modules/FindQtGStreamer.cmake131
-rw-r--r--cmake/modules/QtGStreamerConfig.cmake.in32
-rw-r--r--cmake/modules/QtGStreamerConfigCommon.cmake24
-rw-r--r--src/CMakeLists.txt18
5 files changed, 78 insertions, 136 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a8d6871..2e89987 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,9 +37,14 @@ endif()
find_package(Boost 1.39)
macro_log_feature(Boost_FOUND "Boost" "Required for building QtGLib" "http://www.boost.org/" TRUE "1.39")
-# this just sets the QTGSTREAMER_* cmake variables
+# set the QTGSTREAMER_* cmake variables
set(BUILDING_QTGSTREAMER TRUE)
-find_package(QtGStreamer REQUIRED)
+set(QTGLIB_LIBRARY QtGLib)
+set(QTGSTREAMER_LIBRARY QtGStreamer)
+set(QTGSTREAMER_UI_LIBRARY QtGStreamerUi)
+set(QTGSTREAMER_UTILS_LIBRARY QtGStreamerUtils)
+set(QTGSTREAMER_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src)
+include(QtGStreamerConfigCommon)
find_package(GStreamer 0.10.33 COMPONENTS base)
macro_log_feature(GSTREAMER_FOUND "GStreamer" "Required to build QtGStreamer"
diff --git a/cmake/modules/FindQtGStreamer.cmake b/cmake/modules/FindQtGStreamer.cmake
deleted file mode 100644
index 54e75f6..0000000
--- a/cmake/modules/FindQtGStreamer.cmake
+++ /dev/null
@@ -1,131 +0,0 @@
-# - Try to find QtGStreamer
-# Once done this will define
-#
-# QTGSTREAMER_FOUND - system has QtGStreamer
-# QTGSTREAMER_INCLUDE_DIR - the QtGStreamer include directory
-# QTGSTREAMER_INCLUDES - the include directories needed to use QtGStreamer
-# QTGLIB_LIBRARY - the QtGLib library
-# QTGLIB_LIBRARIES - the libraries needed to use QtGLib
-# QTGSTREAMER_LIBRARY - the QtGStreamer library
-# QTGSTREAMER_LIBRARIES - the libraries needed to use QtGStreamer
-# QTGSTREAMER_UI_LIBRARY - the QtGStreamerUi library
-# QTGSTREAMER_UI_LIBRARIES - the libraries needed to use QtGStreamerUi
-# QTGSTREAMER_UTILS_LIBRARY - the QtGStreamerUtils library
-# QTGSTREAMER_UTILS_LIBRARIES - the libraries needed to use QtGStreamerUtils
-# QTGSTREAMER_DEFINITIONS - definitions recommended for using QtGStreamer
-# QTGSTREAMER_FLAGS - extra compiler switches recommended for using QtGStreamer
-#
-# Copyright (c) 2010, George Kiagiadakis <kiagiadakis.george@gmail.com>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-
-# if variables are already in cache or we are building QtGStreamer
-if((QTGSTREAMER_LIBRARY AND QTGSTREAMER_INCLUDE_DIR) OR BUILDING_QTGSTREAMER)
- set(QtGStreamer_FIND_QUIETLY TRUE)
-else()
- set(QtGStreamer_FIND_QUIETLY FALSE)
-endif()
-
-set(_QTGSTREAMER_LINK_TO_QT_REQUIRED FALSE)
-
-if(BUILDING_QTGSTREAMER)
- set(QTGLIB_LIBRARY QtGLib)
- set(QTGSTREAMER_LIBRARY QtGStreamer)
- set(QTGSTREAMER_UI_LIBRARY QtGStreamerUi)
- set(QTGSTREAMER_UTILS_LIBRARY QtGStreamerUtils)
- set(QTGSTREAMER_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src)
-else()
- # Attempt to find the generated QtGStreamerTargets.cmake in the same directory
- get_filename_component(_QTGSTREAMER_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
- find_file(_QTGSTREAMER_TARGETS_FILE QtGStreamerTargets.cmake PATHS ${_QTGSTREAMER_CONFIG_DIR} NO_DEFAULT_PATH)
-
- if(NOT _QTGSTREAMER_TARGETS_FILE)
- # Targets file not found. Do a typical search for QtGStreamer.
- # Normally, this path is never executed. It is just provided as a fallback in case something goes wrong.
- find_library(QTGLIB_LIBRARY QtGLib-2.0
- PATHS "${_QTGSTREAMER_CONFIG_DIR}/../../lib")
- find_library(QTGSTREAMER_LIBRARY QtGStreamer-0.10
- PATHS "${_QTGSTREAMER_CONFIG_DIR}/../../lib")
- find_library(QTGSTREAMER_UI_LIBRARY QtGStreamerUi-0.10
- PATHS "${_QTGSTREAMER_CONFIG_DIR}/../../lib")
- find_library(QTGSTREAMER_UTILS_LIBRARY QtGStreamerUtils-0.10
- PATHS "${_QTGSTREAMER_CONFIG_DIR}/../../lib")
- find_path(QTGSTREAMER_INCLUDE_DIR QGst/global.h
- PATHS "${_QTGSTREAMER_CONFIG_DIR}/../../include"
- PATH_SUFFIXES QtGStreamer)
- set(_QTGSTREAMER_LINK_TO_QT_REQUIRED TRUE)
- mark_as_advanced(QTGLIB_LIBRARY QTGSTREAMER_LIBRARY QTGSTREAMER_UI_LIBRARY
- QTGSTREAMER_UTILS_LIBRARY QTGSTREAMER_INCLUDE_DIR)
- else()
- # Targets file found. Use imported QtGStreamer target and relative include path.
- # We assume that this file has been installed in $PREFIX/lib(64)/QtGStreamer/,
- # or $PREFIX/lib/<arch_triplet>/QtGStreamer, or $PREFIX/lib(64)/cmake/QtGStreamer/,
- # or $PREFIX/lib/<arch_triplet>/cmake/QtGStreamer/,
- # so the include path should evaluate to $PREFIX/include/QtGStreamer
- include(${_QTGSTREAMER_TARGETS_FILE})
- set(QTGLIB_LIBRARY QtGLib)
- set(QTGSTREAMER_LIBRARY QtGStreamer)
- set(QTGSTREAMER_UI_LIBRARY QtGStreamerUi)
- set(QTGSTREAMER_UTILS_LIBRARY QtGStreamerUtils)
- find_path(QTGSTREAMER_INCLUDE_DIR QGst/Global
- PATHS "${_QTGSTREAMER_CONFIG_DIR}/../../include/QtGStreamer"
- "${_QTGSTREAMER_CONFIG_DIR}/../../../include/QtGStreamer"
- "${_QTGSTREAMER_CONFIG_DIR}/../../../../include/QtGStreamer"
- NO_DEFAULT_PATH)
- endif()
-endif()
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(QtGStreamer DEFAULT_MSG QTGSTREAMER_INCLUDE_DIR QTGLIB_LIBRARY
- QTGSTREAMER_LIBRARY QTGSTREAMER_UI_LIBRARY
- QTGSTREAMER_UTILS_LIBRARY)
-
-if(QTGSTREAMER_FOUND)
- # Find dependencies, if not already found
- if (NOT DEFINED QT_INCLUDE_DIR)
- message(STATUS "Qt hasn't been found yet. Looking...")
- find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
- endif()
-
- if (NOT DEFINED Boost_INCLUDE_DIRS)
- message(STATUS "Boost hasn't been found yet. Looking...")
- find_package(Boost REQUIRED)
- endif()
-
- # Set misc variables
- set(QTGSTREAMER_INCLUDES ${QTGSTREAMER_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
- set(QTGSTREAMER_DEFINITIONS "-DQT_NO_KEYWORDS")
-
- if (_QTGSTREAMER_LINK_TO_QT_REQUIRED)
- set(QTGLIB_LIBRARIES ${QTGLIB_LIBRARY} ${QT_QTCORE_LIBRARY})
- set(QTGSTREAMER_LIBRARIES ${QTGSTREAMER_LIBRARY} ${QTGLIB_LIBRARIES})
- set(QTGSTREAMER_UI_LIBRARIES ${QTGSTREAMER_UI_LIBRARY} ${QT_QTGUI_LIBRARY} ${QTGSTREAMER_LIBRARIES})
- set(QTGSTREAMER_UTILS_LIBRARIES ${QTGSTREAMER_UTILS_LIBRARY} ${QTGSTREAMER_LIBRARIES})
- else()
- set(QTGLIB_LIBRARIES ${QTGLIB_LIBRARY})
- set(QTGSTREAMER_LIBRARIES ${QTGSTREAMER_LIBRARY})
- set(QTGSTREAMER_UI_LIBRARIES ${QTGSTREAMER_UI_LIBRARY})
- set(QTGSTREAMER_UTILS_LIBRARIES ${QTGSTREAMER_UTILS_LIBRARY})
- endif()
-
- if (CMAKE_COMPILER_IS_GNUCXX)
- execute_process(COMMAND ${CMAKE_CXX_COMPILER} "-dumpversion"
- RESULT_VARIABLE _GCC_DUMPVERSION_RESULT
- OUTPUT_VARIABLE _GCC_VERSION
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- if ((${_GCC_DUMPVERSION_RESULT} EQUAL 0)
- AND (${_GCC_VERSION} VERSION_GREATER 4.4.99)
- AND (NOT QTGSTREAMER_DISABLE_CXX0X))
-
- if (NOT QTGSTREAMER_FLAGS) # be quiet if we try to find QtGStreamer multiple times
- message(STATUS "GCC 4.5 or later detected. Enabling C++0x support in QTGSTREAMER_FLAGS.")
- endif()
- set(QTGSTREAMER_FLAGS "-std=c++0x")
- endif()
- endif()
-
-endif()
diff --git a/cmake/modules/QtGStreamerConfig.cmake.in b/cmake/modules/QtGStreamerConfig.cmake.in
new file mode 100644
index 0000000..5007382
--- /dev/null
+++ b/cmake/modules/QtGStreamerConfig.cmake.in
@@ -0,0 +1,32 @@
+set(QTGSTREAMER_VERSION @QTGSTREAMER_VERSION@)
+
+@PACKAGE_INIT@
+
+get_filename_component(_QTGSTREAMER_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+# include the generated QtGStreamerTargets.cmake from the same directory
+find_file(_QTGSTREAMER_TARGETS_FILE QtGStreamerTargets.cmake
+ PATHS ${_QTGSTREAMER_CONFIG_DIR} NO_DEFAULT_PATH)
+include(${_QTGSTREAMER_TARGETS_FILE})
+
+set(QTGLIB_LIBRARY @QTGLIB_LIBRARY@)
+set(QTGSTREAMER_LIBRARY @QTGSTREAMER_LIBRARY@)
+set(QTGSTREAMER_UI_LIBRARY @QTGSTREAMER_UI_LIBRARY@)
+set(QTGSTREAMER_UTILS_LIBRARY @QTGSTREAMER_UTILS_LIBRARY@)
+set_and_check(QTGSTREAMER_INCLUDE_DIR @PACKAGE_INCLUDES_INSTALL_DIR@)
+
+# Find dependencies, if not already found
+if (NOT DEFINED QT_INCLUDE_DIR)
+ message(STATUS "Qt hasn't been found yet. Looking...")
+ find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
+endif()
+
+if (NOT DEFINED Boost_INCLUDE_DIRS)
+ message(STATUS "Boost hasn't been found yet. Looking...")
+ find_package(Boost REQUIRED)
+endif()
+
+# include QtGStreamerConfigCommon.cmake from the same directory
+find_file(_QTGSTREAMER_CONFIG_COMMON_FILE QtGStreamerConfigCommon.cmake
+ PATHS ${_QTGSTREAMER_CONFIG_DIR} NO_DEFAULT_PATH)
+include(${_QTGSTREAMER_CONFIG_COMMON_FILE})
diff --git a/cmake/modules/QtGStreamerConfigCommon.cmake b/cmake/modules/QtGStreamerConfigCommon.cmake
new file mode 100644
index 0000000..e758e85
--- /dev/null
+++ b/cmake/modules/QtGStreamerConfigCommon.cmake
@@ -0,0 +1,24 @@
+set(QTGLIB_LIBRARIES ${QTGLIB_LIBRARY})
+set(QTGSTREAMER_LIBRARIES ${QTGSTREAMER_LIBRARY})
+set(QTGSTREAMER_UI_LIBRARIES ${QTGSTREAMER_UI_LIBRARY})
+set(QTGSTREAMER_UTILS_LIBRARIES ${QTGSTREAMER_UTILS_LIBRARY})
+set(QTGSTREAMER_INCLUDES ${QTGSTREAMER_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
+set(QTGSTREAMER_DEFINITIONS "-DQT_NO_KEYWORDS")
+
+if (CMAKE_COMPILER_IS_GNUCXX)
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} "-dumpversion"
+ RESULT_VARIABLE _GCC_DUMPVERSION_RESULT
+ OUTPUT_VARIABLE _GCC_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if ((${_GCC_DUMPVERSION_RESULT} EQUAL 0)
+ AND (${_GCC_VERSION} VERSION_GREATER 4.4.99)
+ AND (NOT QTGSTREAMER_DISABLE_CXX0X))
+
+ if (NOT QTGSTREAMER_FLAGS) # be quiet if we try to find QtGStreamer multiple times
+ message(STATUS "GCC 4.5 or later detected. Enabling C++0x support in QTGSTREAMER_FLAGS.")
+ endif()
+ set(QTGSTREAMER_FLAGS "-std=c++0x")
+ endif()
+endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3822449..1f6c54b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -56,10 +56,22 @@ if (QT_QTDECLARATIVE_FOUND)
endif()
# Install the cmake scripts that are used to find the installed library from external projects
+include(CMakePackageConfigHelpers)
+configure_package_config_file(
+ ${CMAKE_SOURCE_DIR}/cmake/modules/QtGStreamerConfig.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamerConfig.cmake
+ INSTALL_DESTINATION ${LIB_INSTALL_DIR}/QtGStreamer
+ PATH_VARS INCLUDES_INSTALL_DIR
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+write_basic_package_version_file(
+ ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamerConfigVersion.cmake
+ VERSION ${QTGSTREAMER_VERSION}
+ COMPATIBILITY SameMajorVersion)
install(EXPORT ${EXPORT_TARGET_SET} DESTINATION ${LIB_INSTALL_DIR}/QtGStreamer)
-install(FILES ${CMAKE_SOURCE_DIR}/cmake/modules/FindQtGStreamer.cmake
- DESTINATION ${LIB_INSTALL_DIR}/QtGStreamer
- RENAME QtGStreamerConfig.cmake)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamerConfig.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/QtGStreamerConfigVersion.cmake
+ ${CMAKE_SOURCE_DIR}/cmake/modules/QtGStreamerConfigCommon.cmake
+ DESTINATION ${LIB_INSTALL_DIR}/QtGStreamer)
# Install pkgconfig files
file(GLOB_RECURSE PC_IN_FILES "*.pc.in")