Add FLAC::FLAC target

This commit is contained in:
Chris Thrasher 2023-08-26 13:30:05 -06:00
parent 1aa6750f50
commit 2c7ed96654
3 changed files with 11 additions and 3 deletions

View File

@ -16,3 +16,11 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FLAC DEFAULT_MSG FLAC_LIBRARY FLAC_INCLUDE_DIR)
mark_as_advanced(FLAC_INCLUDE_DIR FLAC_LIBRARY)
add_library(FLAC::FLAC IMPORTED UNKNOWN)
set_target_properties(FLAC::FLAC PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${FLAC_INCLUDE_DIR})
if(FLAC_LIBRARY MATCHES "/([^/]+)\\.framework$")
set_target_properties(FLAC::FLAC PROPERTIES IMPORTED_LOCATION ${FLAC_LIBRARY}/${CMAKE_MATCH_1})
else()
set_target_properties(FLAC::FLAC PROPERTIES IMPORTED_LOCATION ${FLAC_LIBRARY})
endif()

View File

@ -80,7 +80,7 @@ if(SFML_STATIC_LIBRARIES)
endif()
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "Vorbis" SEARCH_NAMES "vorbis")
sfml_bind_dependency(TARGET VORBIS FRIENDLY_NAME "Ogg" SEARCH_NAMES "ogg")
sfml_bind_dependency(TARGET FLAC FRIENDLY_NAME "FLAC" SEARCH_NAMES "FLAC")
find_package(FLAC)
endif()
if(FIND_SFML_DEPENDENCIES_NOTFOUND)

View File

@ -70,7 +70,7 @@ endif()
# find external libraries
sfml_find_package(OpenAL OPENAL_INCLUDE_DIR OPENAL_LIBRARY)
sfml_find_package(VORBIS VORBIS_INCLUDE_DIRS VORBIS_LIBRARIES)
sfml_find_package(FLAC FLAC_INCLUDE_DIR FLAC_LIBRARY)
find_package(FLAC REQUIRED)
# define the sfml-audio target
sfml_add_library(Audio
@ -82,7 +82,7 @@ target_compile_definitions(sfml-audio PRIVATE OV_EXCLUDE_STATIC_CALLBACKS FLAC__
# setup dependencies
target_link_libraries(sfml-audio
PUBLIC SFML::System
PRIVATE OpenAL VORBIS FLAC)
PRIVATE OpenAL VORBIS FLAC::FLAC)
# minimp3 sources
target_include_directories(sfml-audio SYSTEM PRIVATE "${PROJECT_SOURCE_DIR}/extlibs/headers/minimp3")