diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2021-01-16 01:00:10 +0100 |
---|---|---|
committer | Be <be@mixxx.org> | 2021-02-09 15:11:06 -0600 |
commit | d4db6a9e7d94b2f17c927465047302a6c0c46e82 (patch) | |
tree | 82231dd5a0dc59ecb8ae892de4947ef20431feed /cmake | |
parent | 8bf2abf896ab4ebaad2dc48362564db385ca3779 (diff) |
CMake: Rewrite Ogg/Vorbis find module
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/FindOgg.cmake | 78 | ||||
-rw-r--r-- | cmake/modules/FindOggVorbis.cmake | 89 | ||||
-rw-r--r-- | cmake/modules/FindVorbis.cmake | 103 |
3 files changed, 181 insertions, 89 deletions
diff --git a/cmake/modules/FindOgg.cmake b/cmake/modules/FindOgg.cmake new file mode 100644 index 0000000000..b61cb6d2c3 --- /dev/null +++ b/cmake/modules/FindOgg.cmake @@ -0,0 +1,78 @@ +# This file is part of Mixxx, Digital DJ'ing software. +# Copyright (C) 2001-2020 Mixxx Development Team +# Distributed under the GNU General Public Licence (GPL) version 2 or any later +# later version. See the LICENSE file for details. + +#[=======================================================================[.rst: +FindOgg +------- + +Finds the Ogg library. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``Ogg_FOUND`` + True if the system has the Ogg library. +``Ogg_INCLUDE_DIRS`` + Include directories needed to use Ogg. +``Ogg_LIBRARIES`` + Libraries needed to link to Ogg. +``Ogg_DEFINITIONS`` + Compile definitions needed to use Ogg. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Ogg_INCLUDE_DIR`` + The directory containing ``ogg/ogg.h``. +``Ogg_LIBRARY`` + The path to the Ogg library. + +#]=======================================================================] +find_package(PkgConfig QUIET) +if(PkgConfig_FOUND) + pkg_check_modules(PC_Ogg QUIET ogg) +endif() + +find_path(Ogg_INCLUDE_DIR + NAMES ogg/ogg.h + PATHS ${PC_Ogg_INCLUDE_DIRS} + DOC "Ogg include directory" +) +mark_as_advanced(Ogg_INCLUDE_DIR) + +find_library(Ogg_LIBRARY + NAMES ogg + PATHS ${PC_Ogg_LIBRARY_DIRS} + DOC "Ogg library" +) +mark_as_advanced(Ogg_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + Ogg + REQUIRED_VARS + Ogg_INCLUDE_DIR + Ogg_LIBRARY +) + +if(Ogg_FOUND) + set(Ogg_LIBRARIES ${Ogg_LIBRARY}) + set(Ogg_INCLUDE_DIRS ${Ogg_INCLUDE_DIR}) + set(Ogg_DEFINITIONS ${PC_Ogg_CFLAGS_OTHER}) + + if(NOT TARGET Ogg::ogg) + add_library(Ogg::ogg UNKNOWN IMPORTED) + set_target_properties(Ogg::ogg + PROPERTIES + IMPORTED_LOCATION "${Ogg_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Ogg_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Ogg_INCLUDE_DIR}" + ) + endif() +endif() diff --git a/cmake/modules/FindOggVorbis.cmake b/cmake/modules/FindOggVorbis.cmake deleted file mode 100644 index a06ed17c46..0000000000 --- a/cmake/modules/FindOggVorbis.cmake +++ /dev/null @@ -1,89 +0,0 @@ -# This file is part of Mixxx, Digital DJ'ing software. -# Copyright (C) 2001-2020 Mixxx Development Team -# Distributed under the GNU General Public Licence (GPL) version 2 or any later -# later version. See the LICENSE file for details. - -#[=======================================================================[.rst: -FindOggVorbis ---------------- - -Finds the OggVorbis library. - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables: - -``OggVorbis_FOUND`` - True if the system has the OggVorbis library. -``OggVorbis_INCLUDE_DIRS`` - Include directories needed to use OggVorbis. -``OggVorbis_LIBRARIES`` - Libraries needed to link to OggVorbis. - -Cache Variables -^^^^^^^^^^^^^^^ - -The following cache variables may also be set: - -``Ogg_INCLUDE_DIR`` - The directory containing ``ogg/ogg.h``. -``Ogg_LIBRARY`` - The path to the OggVorbis library. -``Vorbis_INCLUDE_DIR`` - The directory containing ``vorbis/vorbisfile.h``. -``Vorbis_LIBRARY`` - The path to the vorbis library. -``VorbisFile_LIBRARY`` - The path to the vorbisfile library. -``VorbisEnc_LIBRARY`` - The path to the vorbisenc library. -``Vorbis_LIBRARIES`` - Libraries needed to link to vorbis. - -#]=======================================================================] -find_path(Ogg_INCLUDE_DIR NAMES ogg/ogg.h DOC "Ogg include directory") -mark_as_advanced(Ogg_INCLUDE_DIR) - -find_library(Ogg_LIBRARY NAMES ogg DOC "Ogg library") -mark_as_advanced(Ogg_LIBRARY) - -find_path(Vorbis_INCLUDE_DIR - NAMES vorbis/vorbisfile.h - DOC "Vorbis include directory" -) -mark_as_advanced(Vorbis_INCLUDE_DIR) - -find_library(Vorbis_LIBRARY NAMES vorbis DOC "Vorbis library") -mark_as_advanced(Vorbis_LIBRARY) - -find_library(VorbisFile_LIBRARY NAMES vorbisfile DOC "Vorbisfile library") -mark_as_advanced(VorbisFile_LIBRARY) - -if(NOT MSVC) - find_library(VorbisEnc_LIBRARY NAMES vorbisenc DOC "Vorbisenc library") - mark_as_advanced(VorbisEnc_LIBRARY) - set(Vorbis_LIBRARIES - ${VorbisEnc_LIBRARY} - ${VorbisFile_LIBRARY} - ${Vorbis_LIBRARY} - ) -else() - set(Vorbis_LIBRARIES ${VorbisFile_LIBRARY} ${Vorbis_LIBRARY}) -endif() -mark_as_advanced(Vorbis_LIBRARIES) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - OggVorbis - REQUIRED_VARS - Ogg_INCLUDE_DIR - Vorbis_INCLUDE_DIR - Ogg_LIBRARY - Vorbis_LIBRARIES -) - -if(OggVorbis_FOUND) - set(OggVorbis_LIBRARIES ${Ogg_LIBRARY} ${Vorbis_LIBRARIES}) - set(OggVorbis_INCLUDE_DIRS ${Ogg_INCLUDE_DIR} ${Vorbis_INCLUDE_DIR}) -endif() diff --git a/cmake/modules/FindVorbis.cmake b/cmake/modules/FindVorbis.cmake new file mode 100644 index 0000000000..3045674c85 --- /dev/null +++ b/cmake/modules/FindVorbis.cmake @@ -0,0 +1,103 @@ +# This file is part of Mixxx, Digital DJ'ing software. +# Copyright (C) 2001-2020 Mixxx Development Team +# Distributed under the GNU General Public Licence (GPL) version 2 or any later +# later version. See the LICENSE file for details. + +#[=======================================================================[.rst: +FindVorbis +---------- + +Finds the Vorbis library. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``Vorbis_FOUND`` + True if the system has the OggVorbis library. +``Vorbis_INCLUDE_DIRS`` + Include directories needed to use OggVorbis. +``Vorbis_LIBRARIES`` + Libraries needed to link to OggVorbis. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Vorbis_vorbis_INCLUDE_DIR`` + The directory containing ``vorbis/vorbis.h``. +``Vorbis_vorbisenc_INCLUDE_DIR`` + The directory containing ``vorbis/vorbisenc.h``. +``Vorbis_vorbisfile_INCLUDE_DIR`` + The directory containing ``vorbis/vorbisfile.h``. +``Vorbis_vorbis_LIBRARY`` + The path to the vorbis library. +``Vorbis_vorbisenc_LIBRARY`` + The path to the vorbisenc library. +``Vorbis_vorbisfile_LIBRARY`` + The path to the vorbisfile library. +``Vorbis_LIBRARIES`` + Libraries needed to link to vorbis. + +#]=======================================================================] + +find_path(Vorbis_vorbis_INCLUDE_DIR + NAMES vorbis/codec.h + DOC "Vorbis include directory" +) +mark_as_advanced(Vorbis_vorbis_INCLUDE_DIR) + +find_path(Vorbis_vorbisenc_INCLUDE_DIR + NAMES vorbis/vorbisenc.h + DOC "Vorbisenc include directory" +) +mark_as_advanced(Vorbis_vorbisenc_INCLUDE_DIR) + +find_path(Vorbis_vorbisfile_INCLUDE_DIR + NAMES vorbis/vorbisfile.h + DOC "Vorbisfile include directory" +) +mark_as_advanced(Vorbis_vorbisfile_INCLUDE_DIR) + +find_library(Vorbis_vorbis_LIBRARY + NAMES vorbis + DOC "Vorbis library") +mark_as_advanced(Vorbis_vorbis_LIBRARY) + +find_library(Vorbis_vorbisenc_LIBRARY + NAMES vorbisenc + DOC "Vorbisenc library") +mark_as_advanced(Vorbis_vorbisenc_LIBRARY) + +find_library(Vorbis_vorbisfile_LIBRARY + NAMES vorbisfile + DOC "Vorbisfile library") +mark_as_advanced(Vorbis_vorbisfile_LIBRARY) + +if(NOT Vorbis_FIND_COMPONENTS) + set(Vorbis_FIND_COMPONENTS "vorbis;vorbisenc;vorbisfile") +endif() + +foreach(component ${Vorbis_FIND_COMPONENTS}) + if(Vorbis_${component}_INCLUDE_DIR AND Vorbis_${component}_LIBRARY) + set(Vorbis_${component}_FOUND TRUE) + if(NOT TARGET Vorbis::${component}) + add_library(Vorbis::${component} UNKNOWN IMPORTED) + set_target_properties(Vorbis::${component} + PROPERTIES + IMPORTED_LOCATION "${Vorbis_${component}_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_${component}_INCLUDE_DIR}" + ) + endif() + else() + set(Vorbis_${component}_FOUND FALSE) + endif() +endforeach() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Vorbis + REQUIRED_VARS Vorbis_vorbis_INCLUDE_DIR Vorbis_vorbis_LIBRARY + HANDLE_COMPONENTS +) |