]> git.tdb.fi Git - ext/openal.git/blob - cmake/FindMySOFA.cmake
Import OpenAL Soft 1.23.1 sources
[ext/openal.git] / cmake / FindMySOFA.cmake
1 # - Find MySOFA
2 # Find the MySOFA libraries
3 #
4 #  This module defines the following variables:
5 #     MYSOFA_FOUND        - True if MYSOFA_INCLUDE_DIR & MYSOFA_LIBRARY are found
6 #     MYSOFA_INCLUDE_DIRS - where to find mysofa.h, etc.
7 #     MYSOFA_LIBRARIES    - the MySOFA library
8 #
9
10 #=============================================================================
11 # Copyright 2009-2011 Kitware, Inc.
12 # Copyright 2009-2011 Philip Lowman <philip@yhbt.com>
13 #
14 # Redistribution and use in source and binary forms, with or without
15 # modification, are permitted provided that the following conditions are
16 # met:
17 #
18 #  * Redistributions of source code must retain the above copyright notice,
19 #    this list of conditions and the following disclaimer.
20 #
21 #  * Redistributions in binary form must reproduce the above copyright notice,
22 #    this list of conditions and the following disclaimer in the documentation
23 #    and/or other materials provided with the distribution.
24 #
25 #  * The names of Kitware, Inc., the Insight Consortium, or the names of
26 #    any consortium members, or of any contributors, may not be used to
27 #    endorse or promote products derived from this software without
28 #    specific prior written permission.
29 #
30 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
31 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
34 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #=============================================================================
41
42 find_package(ZLIB)
43
44 find_path(MYSOFA_INCLUDE_DIR NAMES mysofa.h
45           DOC "The MySOFA include directory"
46 )
47
48 find_library(MYSOFA_LIBRARY NAMES mysofa
49              DOC "The MySOFA library"
50 )
51
52 find_library(MYSOFA_M_LIBRARY NAMES m
53              DOC "The math library for MySOFA"
54 )
55
56 # handle the QUIETLY and REQUIRED arguments and set MYSOFA_FOUND to TRUE if
57 # all listed variables are TRUE
58 include(FindPackageHandleStandardArgs)
59 find_package_handle_standard_args(MySOFA REQUIRED_VARS MYSOFA_LIBRARY MYSOFA_INCLUDE_DIR ZLIB_FOUND)
60
61 if(MYSOFA_FOUND)
62     set(MYSOFA_INCLUDE_DIRS ${MYSOFA_INCLUDE_DIR})
63     set(MYSOFA_LIBRARIES ${MYSOFA_LIBRARY})
64     set(MYSOFA_LIBRARIES ${MYSOFA_LIBRARIES} ZLIB::ZLIB)
65     if(MYSOFA_M_LIBRARY)
66         set(MYSOFA_LIBRARIES ${MYSOFA_LIBRARIES} ${MYSOFA_M_LIBRARY})
67     endif()
68
69     add_library(MySOFA::MySOFA UNKNOWN IMPORTED)
70     set_property(TARGET MySOFA::MySOFA PROPERTY
71         IMPORTED_LOCATION ${MYSOFA_LIBRARY})
72     set_target_properties(MySOFA::MySOFA PROPERTIES
73         INTERFACE_INCLUDE_DIRECTORIES ${MYSOFA_INCLUDE_DIRS}
74         INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
75     if(MYSOFA_M_LIBRARY)
76         set_property(TARGET MySOFA::MySOFA APPEND PROPERTY
77             INTERFACE_LINK_LIBRARIES ${MYSOFA_M_LIBRARY})
78     endif()
79 endif()
80
81 mark_as_advanced(MYSOFA_INCLUDE_DIR MYSOFA_LIBRARY)