[kaffeine] /: Kaffeine requires vlc. So it should check for it. I could not find a FindVLC.cmake so i wrote one.

Michael Jansen kde at michael-jansen.biz
Mon May 9 01:20:29 CEST 2011


Git commit cf1522aac79f10e39a77ed789977332052b64bb1 by Michael Jansen.
Committed on 09/05/2011 at 01:23.
Pushed by mjansen into branch 'master'.

Kaffeine requires vlc. So it should check for it. I could not find a FindVLC.cmake so i wrote one.

@KDE-Buildsystem ... please review.
@Christoph ... please adapt the required version and consider making vlc a optional dependency.

CCMAIL: christophpfister at gmail.com
CCMAIL: kde-buildsystem at kde.org

M  +5    -1    CMakeLists.txt     
A  +115  -0    cmake/modules/FindVLC.cmake         [License: UNKNOWN]  *
M  +1    -1    src/CMakeLists.txt     

The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page.


http://commits.kde.org/kaffeine/cf1522aac79f10e39a77ed789977332052b64bb1

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1bc7c4e..585687c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,8 +1,12 @@
 project(kaffeine)
 
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
+
 find_package(KDE4 REQUIRED)
 find_package(X11 REQUIRED)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES}
+find_package(VLC 1.1.8 REQUIRED)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${VLC_INCLUDE_DIRS}
                     ${X11_Xscreensaver_INCLUDE_PATH})
 add_definitions(${KDE4_DEFINITIONS})
 
diff --git a/cmake/modules/FindVLC.cmake b/cmake/modules/FindVLC.cmake
new file mode 100644
index 0000000..29ece5c
--- /dev/null
+++ b/cmake/modules/FindVLC.cmake
@@ -0,0 +1,115 @@
+###############################################################################
+# CMake module to search for the vlc libraries.
+#
+# WARNING: This module is experimental work in progress.
+#
+# This module defines:
+#  VLC_INCLUDE_DIRS        = include dirs to be used when using the vlc library.
+#  VLC_LIBRARY_DIRS        = directories where the libraries are located.
+#  VLC_LIBRARY             = full path to the vlc library.
+#  VLC_CORE_LIBRARY        = full path to the vlccore library.
+#  VLC_VERSION_STRING      = the vlc version found
+#       VLC_VERSION_MAJOR
+#       VLC_VERSION_MINOR
+#       VLC_VERSION_PATCH
+#       VLC_VERSION_EXTRA
+#  VLC_FOUND               = true if vlc was found.
+#
+# This module respects:
+#  LIB_SUFFIX         = (64|32|"") Specifies the suffix for the lib directory
+#
+# Copyright (c) 2011 Michael Jansen <info at michael-jansen.biz>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+###############################################################################
+
+#
+### Global Configuration Section
+#
+SET(_VLC_REQUIRED_VARS VLC_INCLUDE_DIR VLC_LIBRARY VLC_VERSION_MAJOR VLC_VERSION_MINOR VLC_VERSION_PATCH)
+
+#
+### VLC uses pkgconfig.
+#
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+    pkg_check_modules(PC_VLC QUIET libvlc)
+endif(PKG_CONFIG_FOUND)
+
+#
+### Look for the include files.
+#
+find_path(
+    VLC_INCLUDE_DIR
+    NAMES vlc/vlc.h
+    HINTS
+        ${PC_VLC_INCLUDEDIR}
+        ${PC_VLC_INCLUDE_DIRS} # Unused for vlc but anyway
+    DOC "VLC include directory"
+    )
+mark_as_advanced(VLC_INCLUDE_DIR)
+set(VLC_INCLUDE_DIRS ${VLC_INCLUDE_DIR})
+
+#
+### Look for the libraries (vlc and vlcsore)
+#
+find_library(
+    VLC_LIBRARY
+    NAMES vlc
+    HINTS
+        ${PC_VLC_LIBDIR}
+        ${PC_VLC_LIBRARY_DIRS} # Unused for vlc but anyway
+    PATH_SUFFIXES lib${LIB_SUFFIX}
+    )
+get_filename_component(_VLC_LIBRARY_DIR ${VLC_LIBRARY} PATH)
+mark_as_advanced(VLC_LIBRARY )
+
+find_library(
+    VLC_CORE_LIBRARY
+    NAMES vlccore
+    HINTS
+        ${PC_VLC_LIBDIR}
+        ${PC_VLC_LIBRARY_DIRS}
+    PATH_SUFFIXES lib${LIB_SUFFIX}
+    )
+get_filename_component(_VLC_CORE_LIBRARY_DIR ${VLC_CORE_LIBRARY} PATH)
+mark_as_advanced(VLC_CORE_LIBRARY )
+
+set(VLC_LIBRARY_DIRS _VLC_CORE_LIBRARY_DIR _VLC_LIBRARY_DIR)
+list(REMOVE_DUPLICATES VLC_LIBRARY_DIRS)
+mark_as_advanced(VLC_LIBRARY_DIRS)
+
+#
+### Now parse the version
+#
+if(VLC_INCLUDE_DIR)
+    if(EXISTS "${VLC_INCLUDE_DIR}/vlc/libvlc_version.h" )
+        file( STRINGS "${VLC_INCLUDE_DIR}/vlc/libvlc_version.h" VLC_INFO_H REGEX "^# *define LIBVLC_VERSION_.*\\([0-9]+\\).*$")
+        string(REGEX REPLACE ".*LIBVLC_VERSION_MAJOR +\\(([0-9]+)\\).*" "\\1"    VLC_VERSION_MAJOR "${VLC_INFO_H}")
+        string(REGEX REPLACE ".*LIBVLC_VERSION_MINOR +\\(([0-9]+)\\).*" "\\1"    VLC_VERSION_MINOR "${VLC_INFO_H}")
+        string(REGEX REPLACE ".*LIBVLC_VERSION_REVISION +\\(([0-9]+)\\).*" "\\1" VLC_VERSION_PATCH "${VLC_INFO_H}")
+        string(REGEX REPLACE ".*LIBVLC_VERSION_EXTRA +\\(([0-9]+)\\).*" "\\1" VLC_VERSION_EXTRA "${VLC_INFO_H}")
+        set(VLC_VERSION_STRING "${VLC_VERSION_MAJOR}.${VLC_VERSION_MINOR}.${VLC_VERSION_PATCH}.${VLC_VERSION_EXTRA}")
+        mark_as_advanced(
+            VLC_VERSION_MAJOR
+            VLC_VERSION_MINOR
+            VLC_VERSION_PATCH
+            VLC_VERSION_EXTRA
+            VLC_VERSION_STRING)
+    else()
+        message(FATAL_ERROR "Could not find vlc/vlc_version.h")
+    endif()
+endif()
+
+#
+### Check if everything was found and if the version is sufficient.
+#
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+    VLC
+    REQUIRED_VARS ${_VLC_REQUIRED_VARS}
+    VERSION_VAR VLC_VERSION_STRING
+    )
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2699005..1b985da 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -41,7 +41,7 @@ configure_file(config-kaffeine.h.cmake ${CMAKE_BINARY_DIR}/config-kaffeine.h)
 
 kde4_add_executable(kaffeine ${kaffeinedvb_SRCS} ${kaffeine_SRCS})
 target_link_libraries(kaffeine ${QT_QTSQL_LIBRARY} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS}
-                      ${KDE4_SOLID_LIBS} ${X11_Xscreensaver_LIB} vlc)
+    ${KDE4_SOLID_LIBS} ${X11_Xscreensaver_LIB} ${VLC_LIBRARY})
 install(TARGETS kaffeine ${INSTALL_TARGETS_DEFAULT_ARGS})
 install(FILES scanfile.dvb DESTINATION ${DATA_INSTALL_DIR}/kaffeine)
 install(PROGRAMS kaffeine.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})


More information about the Kde-buildsystem mailing list