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")