From 5f5476ee315ffdaedc37115d2d7049f4f3f2f05d Mon Sep 17 00:00:00 2001 From: nega <1098-nega@users.noreply.gitlab.kitware.com> Date: Tue, 28 Mar 2023 18:47:25 -0400 Subject: FindOpenAL: Fix imported target for macOS framework If a framework is found, specify it through `INTERFACE_LINK_LIBRARIES` because `IMPORTED_LOCATION` requires a file and not a framework directory. --- Modules/FindOpenAL.cmake | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index 53aafdc..3d58569 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -105,18 +105,16 @@ find_package_handle_standard_args( mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR) -if(OPENAL_INCLUDE_DIR AND OPENAL_LIBRARY) - if(NOT TARGET OpenAL::OpenAL) - if(EXISTS "${OPENAL_LIBRARY}") - add_library(OpenAL::OpenAL UNKNOWN IMPORTED) - set_target_properties(OpenAL::OpenAL PROPERTIES - IMPORTED_LOCATION "${OPENAL_LIBRARY}") - else() - add_library(OpenAL::OpenAL INTERFACE IMPORTED) - set_target_properties(OpenAL::OpenAL PROPERTIES - IMPORTED_LIBNAME "${OPENAL_LIBRARY}") - endif() +if(OPENAL_FOUND AND NOT TARGET OpenAL::OpenAL) + if(OPENAL_LIBRARY MATCHES "/([^/]+)\\.framework$") + add_library(OpenAL::OpenAL INTERFACE IMPORTED) set_target_properties(OpenAL::OpenAL PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENAL_INCLUDE_DIR}") + INTERFACE_LINK_LIBRARIES "${OPENAL_LIBRARY}") + else() + add_library(OpenAL::OpenAL UNKNOWN IMPORTED) + set_target_properties(OpenAL::OpenAL PROPERTIES + IMPORTED_LOCATION "${OPENAL_LIBRARY}") endif() + set_target_properties(OpenAL::OpenAL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENAL_INCLUDE_DIR}") endif() -- cgit v0.12 From 1d06554fc6e00fdf8a6f15db9f56ec965cabeef9 Mon Sep 17 00:00:00 2001 From: nega <1098-nega@users.noreply.gitlab.kitware.com> Date: Tue, 28 Mar 2023 18:48:59 -0400 Subject: Tests: Fix FindOpenAL test for macOS framework - Use framework-style includes. - Hush deprecation warnings when compiling test. --- Tests/FindOpenAL/Test/CMakeLists.txt | 6 ++++++ Tests/FindOpenAL/Test/main.cxx | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Tests/FindOpenAL/Test/CMakeLists.txt b/Tests/FindOpenAL/Test/CMakeLists.txt index fa3e263..6479df6 100644 --- a/Tests/FindOpenAL/Test/CMakeLists.txt +++ b/Tests/FindOpenAL/Test/CMakeLists.txt @@ -12,3 +12,9 @@ add_executable(test_var main.cxx) target_include_directories(test_var PRIVATE ${OPENAL_INCLUDE_DIR}) target_link_libraries(test_var PRIVATE ${OPENAL_LIBRARY}) add_test(NAME test_var COMMAND test_var) + +# OpenAL has been deprecated on macOS since Catalina (10.15) +if(APPLE) + target_compile_options(test_tgt PRIVATE "-Wno-deprecated-declarations") + target_compile_options(test_var PRIVATE "-Wno-deprecated-declarations") +endif() diff --git a/Tests/FindOpenAL/Test/main.cxx b/Tests/FindOpenAL/Test/main.cxx index bb45faf..1396c60 100644 --- a/Tests/FindOpenAL/Test/main.cxx +++ b/Tests/FindOpenAL/Test/main.cxx @@ -1,5 +1,10 @@ -#include -#include +#ifdef __APPLE__ +# include "OpenAL/al.h" +# include "OpenAL/alc.h" +#else +# include +# include +#endif #include int main() -- cgit v0.12 From f05bd762f502330221056329e1800d57e4300c97 Mon Sep 17 00:00:00 2001 From: nega <1098-nega@users.noreply.gitlab.kitware.com> Date: Tue, 28 Mar 2023 18:55:00 -0400 Subject: ci: Enable FindOpenAL test on macOS jobs --- .gitlab/ci/configure_macos_arm64_ninja.cmake | 1 + .gitlab/ci/configure_macos_x86_64_makefiles.cmake | 1 + .gitlab/ci/configure_macos_x86_64_ninja.cmake | 1 + 3 files changed, 3 insertions(+) diff --git a/.gitlab/ci/configure_macos_arm64_ninja.cmake b/.gitlab/ci/configure_macos_arm64_ninja.cmake index f59b43c..f2068a1 100644 --- a/.gitlab/ci/configure_macos_arm64_ninja.cmake +++ b/.gitlab/ci/configure_macos_arm64_ninja.cmake @@ -1,3 +1,4 @@ +set(CMake_TEST_FindOpenAL "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_C "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_CXX "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_macos_x86_64_makefiles.cmake b/.gitlab/ci/configure_macos_x86_64_makefiles.cmake index 3c5d8fe..5d1620d 100644 --- a/.gitlab/ci/configure_macos_x86_64_makefiles.cmake +++ b/.gitlab/ci/configure_macos_x86_64_makefiles.cmake @@ -1,3 +1,4 @@ +set(CMake_TEST_FindOpenAL "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_C "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_CXX "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_macos_x86_64_ninja.cmake b/.gitlab/ci/configure_macos_x86_64_ninja.cmake index 3c5d8fe..5d1620d 100644 --- a/.gitlab/ci/configure_macos_x86_64_ninja.cmake +++ b/.gitlab/ci/configure_macos_x86_64_ninja.cmake @@ -1,3 +1,4 @@ +set(CMake_TEST_FindOpenAL "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_C "ON" CACHE BOOL "") set(CMake_TEST_FindOpenMP_CXX "ON" CACHE BOOL "") -- cgit v0.12