Warning, /multimedia/kasts/src/kmediasession/cmake/FindLIBVLC.cmake is written in an unsupported language. File is not indexed.

0001 # CMake module to search for LIBVLC (VLC library)
0002 #
0003 # SPDX-FileCopyrightText: 2010 (c) Rohit Yadav <rohityadav89@gmail.com>
0004 # SPDX-FileCopyrightText: 2011 (c) Harald Sitter <sitter@kde.org>
0005 # SPDX-FileCopyrightText: 2023 (c) Bart De Vries <bart@mogwai.be>
0006 #
0007 # SPDX-License-Identifier: BSD-3-Clause
0008 #
0009 # Redistribution and use is allowed according to the terms of the BSD license.
0010 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
0011 #
0012 # If it's found it sets LIBVLC_FOUND to TRUE
0013 # and following variables are set:
0014 #    LIBVLC_INCLUDE_DIR
0015 #    LIBVLC_LIBRARY
0016 #    LIBVLC_VERSION
0017 
0018 set(LIBVLC_INCLUDE_DIR LIBVLC_INCLUDE_DIR-NOTFOUND)
0019 set(LIBVLC_LIBRARY LIBVLC_LIBRARY-NOTFOUND)
0020 set(LIBVLCCORE_LIBRARY LIBVLCCORE_LIBRARY-NOTFOUND)
0021 
0022 if(NOT LIBVLC_MIN_VERSION)
0023     set(LIBVLC_MIN_VERSION "0.0")
0024 endif(NOT LIBVLC_MIN_VERSION)
0025 
0026 # find_path and find_library normally search standard locations
0027 # before the specified paths. To search non-standard paths first,
0028 # FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
0029 # and then again with no specified paths to search the default
0030 # locations. When an earlier FIND_* succeeds, subsequent FIND_*s
0031 # searching for the same item do nothing.
0032 
0033 if (NOT WIN32)
0034     find_package(PkgConfig)
0035     pkg_check_modules(PC_LIBVLC libvlc)
0036     set(LIBVLC_DEFINITIONS ${PC_LIBVLC_CFLAGS_OTHER})
0037 endif (NOT WIN32)
0038 
0039 #Put here path to custom location
0040 #example: /home/user/vlc/include etc..
0041 find_path(LIBVLC_INCLUDE_DIR vlc/vlc.h
0042 HINTS "$ENV{LIBVLC_INCLUDE_PATH}" ${PC_LIBVLC_INCLUDEDIR} ${PC_LIBVLC_INCLUDE_DIRS}
0043 PATHS
0044     "$ENV{LIB_DIR}/include"
0045     "$ENV{LIB_DIR}/include/vlc"
0046     "/usr/include"
0047     "/usr/include/vlc"
0048     "/usr/local/include"
0049     "/usr/local/include/vlc"
0050     #mingw
0051     c:/msys/local/include
0052 )
0053 find_path(LIBVLC_INCLUDE_DIR PATHS "${CMAKE_INCLUDE_PATH}/vlc" NAMES vlc.h
0054         HINTS ${PC_LIBVLC_INCLUDEDIR} ${PC_LIBVLC_INCLUDE_DIRS})
0055 
0056 #Put here path to custom location
0057 #example: /home/user/vlc/lib etc..
0058 find_library(LIBVLC_LIBRARY NAMES vlc libvlc
0059 HINTS "$ENV{LIBVLC_LIBRARY_PATH}" ${PC_LIBVLC_LIBDIR} ${PC_LIBVLC_LIBRARY_DIRS}
0060 PATHS
0061     "$ENV{LIB_DIR}/lib"
0062     #mingw
0063     c:/msys/local/lib
0064 )
0065 find_library(LIBVLC_LIBRARY NAMES vlc libvlc)
0066 find_library(LIBVLCCORE_LIBRARY NAMES vlccore libvlccore
0067 HINTS "$ENV{LIBVLC_LIBRARY_PATH}" ${PC_LIBVLC_LIBDIR} ${PC_LIBVLC_LIBRARY_DIRS}
0068 PATHS
0069     "$ENV{LIB_DIR}/lib"
0070     #mingw
0071     c:/msys/local/lib
0072 )
0073 find_library(LIBVLCCORE_LIBRARY NAMES vlccore libvlccore)
0074 
0075 set(LIBVLC_VERSION ${PC_LIBVLC_VERSION})
0076 if (LIBVLC_INCLUDE_DIR AND NOT LIBVLC_VERSION)
0077     file(READ "${LIBVLC_INCLUDE_DIR}/vlc/libvlc_version.h" _libvlc_version_h)
0078 
0079     string(REGEX MATCH "# define LIBVLC_VERSION_MAJOR +\\(([0-9])\\)" _dummy "${_libvlc_version_h}")
0080     set(_version_major "${CMAKE_MATCH_1}")
0081 
0082     string(REGEX MATCH "# define LIBVLC_VERSION_MINOR +\\(([0-9])\\)" _dummy "${_libvlc_version_h}")
0083     set(_version_minor "${CMAKE_MATCH_1}")
0084 
0085     string(REGEX MATCH "# define LIBVLC_VERSION_REVISION +\\(([0-9])\\)" _dummy "${_libvlc_version_h}")
0086     set(_version_revision "${CMAKE_MATCH_1}")
0087 
0088     # Optionally, one could also parse LIBVLC_VERSION_EXTRA, but it does not
0089     # seem to be used by libvlc.pc.
0090 
0091     set(LIBVLC_VERSION "${_version_major}.${_version_minor}.${_version_revision}")
0092 endif (LIBVLC_INCLUDE_DIR AND NOT LIBVLC_VERSION)
0093 
0094 if (LIBVLC_INCLUDE_DIR AND LIBVLC_LIBRARY AND LIBVLCCORE_LIBRARY)
0095 set(LIBVLC_FOUND TRUE)
0096 endif (LIBVLC_INCLUDE_DIR AND LIBVLC_LIBRARY AND LIBVLCCORE_LIBRARY)
0097 
0098 if (LIBVLC_VERSION VERSION_LESS "${LIBVLC_MIN_VERSION}")
0099     message(WARNING "LibVLC version not found: version searched: ${LIBVLC_MIN_VERSION}, found ${LIBVLC_VERSION}\nUnless you are on Windows this is bound to fail.")
0100 # TODO: only activate once version detection can be garunteed (which is currently not the case on windows)
0101 #     set(LIBVLC_FOUND FALSE)
0102 endif (LIBVLC_VERSION VERSION_LESS "${LIBVLC_MIN_VERSION}")
0103 
0104 if (LIBVLC_FOUND)
0105     if (NOT LIBVLC_FIND_QUIETLY)
0106         message(STATUS "Found LibVLC include-dir path: ${LIBVLC_INCLUDE_DIR}")
0107         message(STATUS "Found LibVLC library path:${LIBVLC_LIBRARY}")
0108         message(STATUS "Found LibVLCcore library path:${LIBVLCCORE_LIBRARY}")
0109         message(STATUS "Found LibVLC version: ${LIBVLC_VERSION} (searched for: ${LIBVLC_MIN_VERSION})")
0110     endif (NOT LIBVLC_FIND_QUIETLY)
0111     if(NOT TARGET LIBVLC::LIBVLC)
0112         add_library(LIBVLC::LIBVLC UNKNOWN IMPORTED)
0113         set_target_properties(LIBVLC::LIBVLC PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBVLC_INCLUDE_DIR}")
0114 
0115         set_property(TARGET LIBVLC::LIBVLC APPEND PROPERTY IMPORTED_LOCATION "${LIBVLC_LIBRARY}")
0116     endif()
0117 else (LIBVLC_FOUND)
0118     if (LIBVLC_FIND_REQUIRED)
0119         message(FATAL_ERROR "Could not find LibVLC")
0120     endif (LIBVLC_FIND_REQUIRED)
0121 endif (LIBVLC_FOUND)