summaryrefslogtreecommitdiff
path: root/Modules/FindOpenAL.cmake
diff options
context:
space:
mode:
authorSam V <sam.vanheer@outlook.com>2022-06-21 17:26:31 +0200
committerBrad King <brad.king@kitware.com>2022-06-22 09:16:19 -0400
commit927e091949baf4e9627f48444a90191780501cc4 (patch)
treefde483c4fd335b28c9090a75160f8f0793092e4a /Modules/FindOpenAL.cmake
parent2f3ea66a76cc475a6742d2ed00d9eeadbbaff13e (diff)
downloadcmake-927e091949baf4e9627f48444a90191780501cc4.tar.gz
FindOpenAL: Add imported target
Fixes: #20026
Diffstat (limited to 'Modules/FindOpenAL.cmake')
-rw-r--r--Modules/FindOpenAL.cmake26
1 files changed, 26 insertions, 0 deletions
diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake
index b5b92c5685..53aafdc0c3 100644
--- a/Modules/FindOpenAL.cmake
+++ b/Modules/FindOpenAL.cmake
@@ -29,6 +29,16 @@ OpenAL is searched in the following order:
5. Manually compiled framework: ``/Library/Frameworks``.
6. Add-on package: ``/opt``.
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.25
+
+This module defines the :prop_tgt:`IMPORTED` target:
+
+``OpenAL::OpenAL``
+ The OpenAL library, if found.
+
Result Variables
^^^^^^^^^^^^^^^^
@@ -94,3 +104,19 @@ 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()
+ set_target_properties(OpenAL::OpenAL PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${OPENAL_INCLUDE_DIR}")
+ endif()
+endif()