From 2c7ed96654c67ce15c96d81d253991a74afdc879 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sat, 26 Aug 2023 13:30:05 -0600 Subject: [PATCH] Add `FLAC::FLAC` target --- cmake/Modules/FindFLAC.cmake | 8 ++++++++ cmake/SFMLConfigDependencies.cmake.in | 2 +- src/SFML/Audio/CMakeLists.txt | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/FindFLAC.cmake b/cmake/Modules/FindFLAC.cmake index e820cf9d..d261f8e2 100644 --- a/cmake/Modules/FindFLAC.cmake +++ b/cmake/Modules/FindFLAC.cmake @@ -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() diff --git a/cmake/SFMLConfigDependencies.cmake.in b/cmake/SFMLConfigDependencies.cmake.in index 2666d195..fbef902c 100644 --- a/cmake/SFMLConfigDependencies.cmake.in +++ b/cmake/SFMLConfigDependencies.cmake.in @@ -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) diff --git a/src/SFML/Audio/CMakeLists.txt b/src/SFML/Audio/CMakeLists.txt index 41a74c4b..2bd29858 100644 --- a/src/SFML/Audio/CMakeLists.txt +++ b/src/SFML/Audio/CMakeLists.txt @@ -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")