mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Use imported targets for Vorbis and Ogg
The name of the find module was changed to match the name used by the reference implementation of Vorbis. Likely the target names were taken from what the reference implementation names those targets.
This commit is contained in:
parent
450acdeac2
commit
78973e4a06
@ -379,23 +379,6 @@ function(sfml_add_test target SOURCES DEPENDS)
|
|||||||
catch_discover_tests(${target} WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
|
catch_discover_tests(${target} WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Find the requested package and make an INTERFACE library from it
|
|
||||||
# The created INTERFACE library is tagged for export to be part of the generated SFMLConfig
|
|
||||||
# Usage: sfml_find_package(wanted_target_name [OPENGL_INCLUDE_DIR] [OPENGL_gl_LIBRARY])
|
|
||||||
function(sfml_find_package target INCLUDE_DIRS LINK_LIBRARIES)
|
|
||||||
if(TARGET ${target})
|
|
||||||
message(FATAL_ERROR "Target '${target}' is already defined")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package(${target} REQUIRED)
|
|
||||||
add_library(${target} INTERFACE)
|
|
||||||
|
|
||||||
target_include_directories(${target} SYSTEM INTERFACE "$<BUILD_INTERFACE:${${INCLUDE_DIRS}}>")
|
|
||||||
target_link_libraries(${target} INTERFACE "$<BUILD_INTERFACE:${${LINK_LIBRARIES}}>")
|
|
||||||
|
|
||||||
install(TARGETS ${target} EXPORT SFMLConfigExport)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
# Generate a SFMLConfig.cmake file (and associated files) from the targets registered against
|
# Generate a SFMLConfig.cmake file (and associated files) from the targets registered against
|
||||||
# the EXPORT name "SFMLConfigExport" (EXPORT parameter of install(TARGETS))
|
# the EXPORT name "SFMLConfigExport" (EXPORT parameter of install(TARGETS))
|
||||||
function(sfml_export_targets)
|
function(sfml_export_targets)
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
#
|
|
||||||
# Try to find Ogg/Vorbis libraries and include paths.
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# VORBIS_FOUND
|
|
||||||
# VORBIS_INCLUDE_DIRS
|
|
||||||
# VORBIS_LIBRARIES
|
|
||||||
#
|
|
||||||
|
|
||||||
find_path(OGG_INCLUDE_DIR ogg/ogg.h)
|
|
||||||
find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
|
|
||||||
|
|
||||||
find_library(OGG_LIBRARY NAMES ogg)
|
|
||||||
find_library(VORBIS_LIBRARY NAMES vorbis)
|
|
||||||
if(NOT SFML_OS_IOS)
|
|
||||||
find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
|
|
||||||
find_library(VORBISENC_LIBRARY NAMES vorbisenc)
|
|
||||||
set(VORBIS_LIBRARIES ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
|
|
||||||
else()
|
|
||||||
set(VORBIS_LIBRARIES ${VORBIS_LIBRARY} ${OGG_LIBRARY})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
|
|
||||||
find_package_handle_standard_args(VORBIS DEFAULT_MSG VORBIS_LIBRARIES VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR)
|
|
||||||
|
|
||||||
set(VORBIS_INCLUDE_DIRS ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
|
|
||||||
|
|
||||||
mark_as_advanced(OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY)
|
|
69
cmake/Modules/FindVorbis.cmake
Normal file
69
cmake/Modules/FindVorbis.cmake
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#
|
||||||
|
# Try to find Ogg/Vorbis libraries and include paths.
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# VORBIS_FOUND
|
||||||
|
# VORBIS_INCLUDE_DIRS
|
||||||
|
# VORBIS_LIBRARIES
|
||||||
|
#
|
||||||
|
|
||||||
|
find_path(OGG_INCLUDE_DIR ogg/ogg.h)
|
||||||
|
find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
|
||||||
|
|
||||||
|
find_library(OGG_LIBRARY NAMES ogg)
|
||||||
|
find_library(VORBIS_LIBRARY NAMES vorbis)
|
||||||
|
find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
|
||||||
|
find_library(VORBISENC_LIBRARY NAMES vorbisenc)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
find_package_handle_standard_args(Vorbis DEFAULT_MSG
|
||||||
|
OGG_INCLUDE_DIR
|
||||||
|
OGG_LIBRARY
|
||||||
|
VORBIS_INCLUDE_DIR
|
||||||
|
VORBIS_LIBRARY)
|
||||||
|
mark_as_advanced(
|
||||||
|
OGG_INCLUDE_DIR
|
||||||
|
OGG_LIBRARY
|
||||||
|
VORBIS_INCLUDE_DIR
|
||||||
|
VORBIS_LIBRARY
|
||||||
|
VORBISFILE_LIBRARY
|
||||||
|
VORBISENC_LIBRARY)
|
||||||
|
|
||||||
|
add_library(Ogg::ogg IMPORTED UNKNOWN)
|
||||||
|
set_target_properties(Ogg::ogg PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${OGG_INCLUDE_DIR})
|
||||||
|
if(OGG_LIBRARY MATCHES "/([^/]+)\\.framework$")
|
||||||
|
set_target_properties(Ogg::ogg PROPERTIES IMPORTED_LOCATION ${OGG_LIBRARY}/${CMAKE_MATCH_1})
|
||||||
|
else()
|
||||||
|
set_target_properties(Ogg::ogg PROPERTIES IMPORTED_LOCATION ${OGG_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(Vorbis::vorbis IMPORTED UNKNOWN)
|
||||||
|
set_target_properties(Vorbis::vorbis PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES ${VORBIS_INCLUDE_DIR}
|
||||||
|
INTERFACE_LINK_LIBRARIES Ogg::ogg)
|
||||||
|
if(VORBIS_LIBRARY MATCHES "/([^/]+)\\.framework$")
|
||||||
|
set_target_properties(Vorbis::vorbis PROPERTIES IMPORTED_LOCATION ${VORBIS_LIBRARY}/${CMAKE_MATCH_1})
|
||||||
|
else()
|
||||||
|
set_target_properties(Vorbis::vorbis PROPERTIES IMPORTED_LOCATION ${VORBIS_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(VORBISFILE_LIBRARY)
|
||||||
|
add_library(Vorbis::vorbisfile IMPORTED UNKNOWN)
|
||||||
|
set_target_properties(Vorbis::vorbisfile PROPERTIES INTERFACE_LINK_LIBRARIES Vorbis::vorbis)
|
||||||
|
if(VORBISFILE_LIBRARY MATCHES "/([^/]+)\\.framework$")
|
||||||
|
set_target_properties(Vorbis::vorbisfile PROPERTIES IMPORTED_LOCATION ${VORBISFILE_LIBRARY}/${CMAKE_MATCH_1})
|
||||||
|
else()
|
||||||
|
set_target_properties(Vorbis::vorbisfile PROPERTIES IMPORTED_LOCATION ${VORBISFILE_LIBRARY})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(VORBISENC_LIBRARY)
|
||||||
|
add_library(Vorbis::vorbisenc IMPORTED UNKNOWN)
|
||||||
|
set_target_properties(Vorbis::vorbisenc PROPERTIES INTERFACE_LINK_LIBRARIES Vorbis::vorbis)
|
||||||
|
if(VORBISENC_LIBRARY MATCHES "/([^/]+)\\.framework$")
|
||||||
|
set_target_properties(Vorbis::vorbisenc PROPERTIES IMPORTED_LOCATION ${VORBISENC_LIBRARY}/${CMAKE_MATCH_1})
|
||||||
|
else()
|
||||||
|
set_target_properties(Vorbis::vorbisenc PROPERTIES IMPORTED_LOCATION ${VORBISENC_LIBRARY})
|
||||||
|
endif()
|
||||||
|
endif()
|
@ -24,24 +24,6 @@ if(SFML_STATIC_LIBRARIES)
|
|||||||
# start with an empty list
|
# start with an empty list
|
||||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
set(FIND_SFML_DEPENDENCIES_NOTFOUND)
|
||||||
|
|
||||||
# macro that searches for a 3rd-party library
|
|
||||||
function(sfml_bind_dependency)
|
|
||||||
cmake_parse_arguments(THIS "" "TARGET;FRIENDLY_NAME" "SEARCH_NAMES" ${ARGN})
|
|
||||||
if(THIS_UNPARSED_ARGUMENTS)
|
|
||||||
message(FATAL_ERROR "Unknown arguments when calling sfml_bind_dependency: ${THIS_UNPARSED_ARGUMENTS}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# No lookup in environment variables (PATH on Windows), as they may contain wrong library versions
|
|
||||||
find_library(${THIS_FRIENDLY_NAME}_LIB NAMES ${THIS_SEARCH_NAMES}
|
|
||||||
PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib NO_SYSTEM_ENVIRONMENT_PATH)
|
|
||||||
mark_as_advanced(${THIS_FRIENDLY_NAME}_LIB)
|
|
||||||
if(${THIS_FRIENDLY_NAME}_LIB)
|
|
||||||
set_property(TARGET ${THIS_TARGET} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${${THIS_FRIENDLY_NAME}_LIB}")
|
|
||||||
else()
|
|
||||||
set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${THIS_FRIENDLY_NAME}" PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
# SFML::Window
|
# SFML::Window
|
||||||
list(FIND SFML_FIND_COMPONENTS "Window" FIND_SFML_WINDOW_COMPONENT_INDEX)
|
list(FIND SFML_FIND_COMPONENTS "Window" FIND_SFML_WINDOW_COMPONENT_INDEX)
|
||||||
if(FIND_SFML_WINDOW_COMPONENT_INDEX GREATER -1)
|
if(FIND_SFML_WINDOW_COMPONENT_INDEX GREATER -1)
|
||||||
@ -74,12 +56,7 @@ if(SFML_STATIC_LIBRARIES)
|
|||||||
list(FIND SFML_FIND_COMPONENTS "Audio" FIND_SFML_AUDIO_COMPONENT_INDEX)
|
list(FIND SFML_FIND_COMPONENTS "Audio" FIND_SFML_AUDIO_COMPONENT_INDEX)
|
||||||
if(FIND_SFML_AUDIO_COMPONENT_INDEX GREATER -1)
|
if(FIND_SFML_AUDIO_COMPONENT_INDEX GREATER -1)
|
||||||
find_package(OpenAL)
|
find_package(OpenAL)
|
||||||
if(NOT FIND_SFML_OS_IOS)
|
find_package(Vorbis)
|
||||||
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "VorbisFile" SEARCH_NAMES "vorbisfile")
|
|
||||||
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "VorbisEnc" SEARCH_NAMES "vorbisenc")
|
|
||||||
endif()
|
|
||||||
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "Vorbis" SEARCH_NAMES "vorbis")
|
|
||||||
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "Ogg" SEARCH_NAMES "ogg")
|
|
||||||
find_package(FLAC)
|
find_package(FLAC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ endif()
|
|||||||
|
|
||||||
# find external libraries
|
# find external libraries
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
sfml_find_package(VORBIS VORBIS_INCLUDE_DIRS VORBIS_LIBRARIES)
|
find_package(Vorbis REQUIRED)
|
||||||
find_package(FLAC REQUIRED)
|
find_package(FLAC REQUIRED)
|
||||||
|
|
||||||
# define the sfml-audio target
|
# define the sfml-audio target
|
||||||
@ -82,7 +82,10 @@ target_compile_definitions(sfml-audio PRIVATE OV_EXCLUDE_STATIC_CALLBACKS FLAC__
|
|||||||
# setup dependencies
|
# setup dependencies
|
||||||
target_link_libraries(sfml-audio
|
target_link_libraries(sfml-audio
|
||||||
PUBLIC SFML::System
|
PUBLIC SFML::System
|
||||||
PRIVATE OpenAL::OpenAL VORBIS FLAC::FLAC)
|
PRIVATE OpenAL::OpenAL Vorbis::vorbis FLAC::FLAC)
|
||||||
|
if(NOT SFML_OS_IOS)
|
||||||
|
target_link_libraries(sfml-audio PRIVATE Vorbis::vorbisfile Vorbis::vorbisenc)
|
||||||
|
endif()
|
||||||
|
|
||||||
# minimp3 sources
|
# minimp3 sources
|
||||||
target_include_directories(sfml-audio SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/minimp3")
|
target_include_directories(sfml-audio SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/minimp3")
|
||||||
|
Loading…
Reference in New Issue
Block a user