Commit ae766e6d authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

CMake cleanups

Remove unused Find scripts and use targetted PkgConfig to find things.
parent 5975d134
......@@ -16,9 +16,9 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(Qt5 NO_MODULE REQUIRED COMPONENTS Core Gui Widgets Quick Test OpenGL)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Config DocTools KIO I18n Purpose Notifications)
find_package(GStreamer 1.10 REQUIRED)
find_package(GLIB2 REQUIRED)
find_package(GObject REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GStreamer IMPORTED_TARGET gstreamer-1.0)
pkg_check_modules(GStreamerVideo IMPORTED_TARGET gstreamer-video-1.0)
find_package(KF5Kirigami2)
set_package_properties(KF5Kirigami2 PROPERTIES
......
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. 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.
# - Try to find GObject
# Once done this will define
#
# GOBJECT_FOUND - system has GObject
# GOBJECT_INCLUDE_DIR - the GObject include directory
# GOBJECT_LIBRARIES - the libraries needed to use GObject
# GOBJECT_DEFINITIONS - Compiler switches required for using GObject
# Copyright (c) 2011, Raphael Kubo da Costa <kubito@gmail.com>
# Copyright (c) 2006, Tim Beaulen <tbscope@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_GOBJECT gobject-2.0)
SET(GOBJECT_DEFINITIONS ${PC_GOBJECT_CFLAGS_OTHER})
FIND_PATH(GOBJECT_INCLUDE_DIR gobject.h
HINTS
${PC_GOBJECT_INCLUDEDIR}
${PC_GOBJECT_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0/gobject/
)
FIND_LIBRARY(_GObjectLibs NAMES gobject-2.0
HINTS
${PC_GOBJECT_LIBDIR}
${PC_GOBJECT_LIBRARY_DIRS}
)
FIND_LIBRARY(_GModuleLibs NAMES gmodule-2.0
HINTS
${PC_GOBJECT_LIBDIR}
${PC_GOBJECT_LIBRARY_DIRS}
)
FIND_LIBRARY(_GThreadLibs NAMES gthread-2.0
HINTS
${PC_GOBJECT_LIBDIR}
${PC_GOBJECT_LIBRARY_DIRS}
)
FIND_LIBRARY(_GLibs NAMES glib-2.0
HINTS
${PC_GOBJECT_LIBDIR}
${PC_GOBJECT_LIBRARY_DIRS}
)
SET( GOBJECT_LIBRARIES ${_GObjectLibs} ${_GModuleLibs} ${_GThreadLibs} ${_GLibs} )
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GOBJECT DEFAULT_MSG GOBJECT_LIBRARIES GOBJECT_INCLUDE_DIR)
MARK_AS_ADVANCED(GOBJECT_INCLUDE_DIR _GObjectLibs _GModuleLibs _GThreadLibs _GLibs)
# - Try to find GStreamer
# Once done this will define
#
# GSTREAMER_FOUND - system has GStreamer
# GSTREAMER_INCLUDE_DIR - the GStreamer include directory
# GSTREAMER_LIBRARY - the main GStreamer library
# GSTREAMER_PLUGIN_DIR - the GStreamer plugin directory
#
# And for all the plugin libraries specified in the COMPONENTS
# of find_package, this module will define:
#
# GSTREAMER_<plugin_lib>_LIBRARY_FOUND - system has <plugin_lib>
# GSTREAMER_<plugin_lib>_LIBRARY - the <plugin_lib> library
# GSTREAMER_<plugin_lib>_INCLUDE_DIR - the <plugin_lib> include directory
#
# Copyright(c) 2010, Collabora Ltd.
# @author George Kiagiadakis <george.kiagiadakis@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.
# TODO: Other versions --> GSTREAMER_X_Y_FOUND(Example: GSTREAMER_0_8_FOUND and GSTREAMER_0_10_FOUND etc)
if(GSTREAMER_INCLUDE_DIR AND GSTREAMER_LIBRARIES AND GSTREAMER_BASE_LIBRARY)
# in cache already
set(GStreamer_FIND_QUIETLY TRUE)
else()
set(GStreamer_FIND_QUIETLY FALSE)
endif()
set(GSTREAMER_API_VERSION 1.0)
if(NOT WIN32)
FIND_PACKAGE(PkgConfig REQUIRED)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
# don't make this check required - otherwise you can't use macro_optional_find_package on this one
PKG_CHECK_MODULES(PKG_GSTREAMER gstreamer-${GSTREAMER_API_VERSION})
set(GSTREAMER_VERSION ${PKG_GSTREAMER_VERSION})
set(GSTREAMER_DEFINITIONS ${PKG_GSTREAMER_CFLAGS})
endif()
message(STATUS "Found GStreamer package: ${PKG_GSTREAMER_VERSION}")
set(GSTREAMER_INCLUDE_DIR ${PKG_GSTREAMER_INCLUDE_DIRS})
find_library(GSTREAMER_LIBRARIES NAMES gstreamer-${GSTREAMER_API_VERSION}
PATHS
${PKG_GSTREAMER_LIBRARY_DIRS}
)
find_library(GSTREAMER_BASE_LIBRARY NAMES gstbase-${GSTREAMER_API_VERSION}
PATHS
${PKG_GSTREAMER_LIBRARY_DIRS}
)
find_library(GSTREAMER_VIDEO_LIBRARY NAMES gstvideo-${GSTREAMER_API_VERSION}
PATHS
${PKG_GSTREAMER_LIBRARY_DIRS}
)
if(NOT GSTREAMER_INCLUDE_DIR)
message(STATUS "GStreamer: WARNING: include dir not found")
endif()
if(NOT GSTREAMER_LIBRARIES)
message(STATUS "GStreamer: WARNING: library not found")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GStreamer DEFAULT_MSG GSTREAMER_LIBRARIES GSTREAMER_INCLUDE_DIR GSTREAMER_BASE_LIBRARY)
mark_as_advanced(GSTREAMER_INCLUDE_DIR GSTREAMER_LIBRARIES GSTREAMER_BASE_LIBRARY)
# CMake module to search for LIBVLC (VLC library)
# Author: Rohit Yadav <rohityadav89@gmail.com>
#
# If it's found it sets LIBVLC_FOUND to TRUE
# and following variables are set:
# LIBVLC_INCLUDE_DIR
# LIBVLC_LIBRARY
# FIND_PATH and FIND_LIBRARY normally search standard locations
# before the specified paths. To search non-standard paths first,
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
# and then again with no specified paths to search the default
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
# searching for the same item do nothing.
#Put here path to custom location
#example: /home/user/vlc/include etc..
FIND_PATH(LIBVLC_INCLUDE_DIR vlc/vlc.h
HINTS "$ENV{LIBVLC_INCLUDE_PATH}"
PATHS
"$ENV{LIB_DIR}/include"
"$ENV{LIB_DIR}/include/vlc"
"/usr/include"
"/usr/include/vlc"
"/usr/local/include"
"/usr/local/include/vlc"
#mingw
c:/msys/local/include
)
FIND_PATH(LIBVLC_INCLUDE_DIR PATHS "${CMAKE_INCLUDE_PATH}/vlc" NAMES vlc.h)
#Put here path to custom location
#example: /home/user/vlc/lib etc..
FIND_LIBRARY(LIBVLC_LIBRARY NAMES vlc libvlc
HINTS "$ENV{LIBVLC_LIBRARY_PATH}"
PATHS
"$ENV{LIB_DIR}/lib"
#mingw
c:/msys/local/lib
)
FIND_LIBRARY(LIBVLC_LIBRARY NAMES vlc libvlc)
FIND_LIBRARY(LIBVLCCORE_LIBRARY NAMES vlccore libvlccore
HINTS "$ENV{LIBVLC_LIBRARY_PATH}"
PATHS
"$ENV{LIB_DIR}/lib"
#mingw
c:/msys/local/lib
)
FIND_LIBRARY(LIBVLCCORE_LIBRARY NAMES vlccore libvlccore)
IF (LIBVLC_INCLUDE_DIR AND LIBVLC_LIBRARY AND LIBVLCCORE_LIBRARY)
SET(LIBVLC_FOUND TRUE)
ENDIF (LIBVLC_INCLUDE_DIR AND LIBVLC_LIBRARY AND LIBVLCCORE_LIBRARY)
IF (LIBVLC_FOUND)
IF (NOT LIBVLC_FIND_QUIETLY)
MESSAGE(STATUS "Found LibVLC include-dir path: ${LIBVLC_INCLUDE_DIR}")
MESSAGE(STATUS "Found LibVLC library path:${LIBVLC_LIBRARY}")
MESSAGE(STATUS "Found LibVLCcore library path:${LIBVLCCORE_LIBRARY}")
ENDIF (NOT LIBVLC_FIND_QUIETLY)
ELSE (LIBVLC_FOUND)
IF (LIBVLC_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find LibVLC")
ENDIF (LIBVLC_FIND_REQUIRED)
ENDIF (LIBVLC_FOUND)
# cmake macro to test LibV4L2
# Copyright (c) 2009, Jaroslav Reznik <jreznik@redhat.com>
#
# LIBV4L2_FOUND
# LIBV4L2_INCLUDE_DIR
# LIBV4L2_LIBRARY
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
INCLUDE (FindPackageHandleStandardArgs)
IF (LIBV4L2_INCLUDE_DIR AND LIBV4L2_LIBRARY)
# Already in cache, be silent
SET (LIBV4L2_FIND_QUIETLY TRUE)
ENDIF (LIBV4L2_INCLUDE_DIR AND LIBV4L2_LIBRARY)
IF (NOT LIBV4L2_FOUND)
FIND_PATH (LIBV4L2_INCLUDE_DIR libv4l2.h)
FIND_LIBRARY (LIBV4L2_LIBRARY NAMES v4l2)
IF (LIBV4L2_INCLUDE_DIR AND LIBV4L2_LIBRARY)
SET (LIBV4L2_FOUND TRUE)
ENDIF( LIBV4L2_INCLUDE_DIR AND LIBV4L2_LIBRARY )
ENDIF ( NOT LIBV4L2_FOUND)
IF( LIBV4L2_FOUND )
IF( NOT LIBV4L2_FIND_QUIETLY )
MESSAGE( STATUS "Found LIBV4L2: ${LIBV4L2_LIBRARY}")
ENDIF( NOT LIBV4L2_FIND_QUIETLY )
ENDIF( LIBV4L2_FOUND )
# - Try to find OpenGLES2
# Once done this will define
#
# OPENGLES2_FOUND - system has OpenGLES2
# OPENGLES2_INCLUDE_DIR - the GLES2 include directory
# OPENGLES2_LIBRARY - the GLES2 library
#
# Copyright (c) 2012, 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.
find_path(OPENGLES2_INCLUDE_DIR GLES2/gl2.h)
find_library(OPENGLES2_LIBRARY NAMES GLESv2)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenGLES2 DEFAULT_MSG OPENGLES2_INCLUDE_DIR OPENGLES2_LIBRARY)
mark_as_advanced(OPENGLES2_INCLUDE_DIR OPENGLES2_LIBRARY)
# - macro find_gstreamer_library
#
# Copyright (c) 2010, Collabora Ltd.
# @author George Kiagiadakis <george.kiagiadakis@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.
macro(find_gstreamer_library _name _header _abi_version)
string(TOLOWER ${_name} _lower_name)
string(TOUPPER ${_name} _upper_name)
if (GSTREAMER_${_upper_name}_LIBRARY AND GSTREAMER_${_upper_name}_INCLUDE_DIR)
set(_GSTREAMER_${_upper_name}_QUIET TRUE)
else()
set(_GSTREAMER_${_upper_name}_QUIET FALSE)
endif()
if (PKG_CONFIG_FOUND)
pkg_check_modules(PKG_GSTREAMER_${_upper_name} gstreamer-${_lower_name}-${_abi_version})
endif()
find_library(GSTREAMER_${_upper_name}_LIBRARY
NAMES gst${_lower_name}-${_abi_version}
HINTS ${PKG_GSTREAMER_${_upper_name}_LIBRARY_DIRS}
${PKG_GSTREAMER_${_upper_name}_LIBDIR}
)
find_path(GSTREAMER_${_upper_name}_INCLUDE_DIR
gst/${_lower_name}/${_header}
HINTS ${PKG_GSTREAMER_${_upper_name}_INCLUDE_DIRS}
${PKG_GSTREAMER_${_upper_name}_INCLUDEDIR}
PATH_SUFFIXES gstreamer-${_abi_version}
)
if (GSTREAMER_${_upper_name}_LIBRARY AND GSTREAMER_${_upper_name}_INCLUDE_DIR)
set(GSTREAMER_${_upper_name}_LIBRARY_FOUND TRUE)
else()
set(GSTREAMER_${_upper_name}_LIBRARY_FOUND FALSE)
endif()
if (NOT _GSTREAMER_${_upper_name}_QUIET)
if (GSTREAMER_${_upper_name}_LIBRARY)
message(STATUS "Found GSTREAMER_${_upper_name}_LIBRARY: ${GSTREAMER_${_upper_name}_LIBRARY}")
else()
message(STATUS "Could NOT find GSTREAMER_${_upper_name}_LIBRARY")
endif()
if (GSTREAMER_${_upper_name}_INCLUDE_DIR)
message(STATUS "Found GSTREAMER_${_upper_name}_INCLUDE_DIR: ${GSTREAMER_${_upper_name}_INCLUDE_DIR}")
else()
message(STATUS "Could NOT find GSTREAMER_${_upper_name}_INCLUDE_DIR")
endif()
endif()
mark_as_advanced(GSTREAMER_${_upper_name}_LIBRARY GSTREAMER_${_upper_name}_INCLUDE_DIR)
endmacro()
......@@ -26,12 +26,10 @@ add_executable(kamoso
${kamosoqml_SRCS}
)
target_include_directories(kamoso PRIVATE "${GSTREAMER_INCLUDE_DIR}" "${GLIB2_INCLUDE_DIR}")
target_link_libraries(kamoso
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Quick
KF5::KIOFileWidgets KF5::ConfigGui KF5::I18n KF5::Notifications
${GSTREAMER_LIBRARIES} ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES}
PkgConfig::GStreamer
)
install(TARGETS kamoso ${INSTALL_TARGETS_DEFAULT_ARGS})
......
......@@ -10,7 +10,4 @@ add_definitions(-DPACKAGE="kamoso-gstreamer"
-DGST_DISABLE_XML
-DGST_DISABLE_LOADSAVE)
include_directories(${GSTREAMER_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR})
include_directories(${GSTREAMER_BASE_INCLUDE_DIR} ${GSTREAMER_VIDEO_INCLUDE_DIR})
add_subdirectory(gstqtvideosink)
......@@ -52,10 +52,7 @@ endif()
add_library(gst${QTVIDEOSINK_NAME} MODULE ${GstQtVideoSink_SRCS})
target_link_libraries(gst${QTVIDEOSINK_NAME}
${GOBJECT_LIBRARIES}
${GSTREAMER_LIBRARIES}
${GSTREAMER_BASE_LIBRARY}
${GSTREAMER_VIDEO_LIBRARY}
PkgConfig::GStreamerVideo
${GstQtVideoSink_GL_LIBS}
Qt5::Quick
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment