# Find OpenAL # # This module defines # OpenAL_FOUND # OpenAL_INCLUDE_DIRS # OpenAL_LIBRARIES # OpenAL_FWK (Apple framework) # # Copyright (c) 2014 I-maginer # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 59 Temple # Place - Suite 330, Boston, MA 02111-1307, USA, or go to # http://www.gnu.org/copyleft/lesser.txt # # On a new cmake run, we do not need to be verbose IF(OpenAL_INCLUDE_DIR AND OpenAL_LIBRARY) SET(OpenAL_FIND_QUIETLY TRUE) ENDIF() # If OpenAL_ROOT was defined in the environment, use it. if (NOT OpenAL_ROOT) if(NOT "$ENV{OpenAL_ROOT}" STREQUAL "") set(OpenAL_ROOT $ENV{OpenAL_ROOT}) else() if (ANDROID) set(OpenAL_ROOT "$ENV{SCOL_DEPENDENCIES_PATH}/sdk/android/${ANDROID_ABI}" CACHE PATH "OPENAL SDK path" FORCE) elseif(WIN64) set(OpenAL_ROOT "$ENV{SCOL_DEPENDENCIES_PATH}/sdk/windows/x64" CACHE PATH "OPENAL SDK path" FORCE) elseif(WIN32) set(OpenAL_ROOT "$ENV{SCOL_DEPENDENCIES_PATH}/sdk/windows/x86" CACHE PATH "OPENAL SDK path" FORCE) elseif(APPLE AND NOT APPLE_IOS) set(OpenAL_ROOT "$ENV{SCOL_DEPENDENCIES_PATH}/sdk/apple/OSX" CACHE PATH "OPENAL SDK path" FORCE) #set(CMAKE_FIND_FRAMEWORK "NEVER") elseif (SCOL_INSTALL_PREFIX) set(OpenAL_ROOT "$ENV{SCOL_DEPENDENCIES_PATH}/sdk/${SCOL_INSTALL_PREFIX}" CACHE PATH "OPENAL SDK path" FORCE) else(LINUX) set(OpenAL_ROOT "$ENV{SCOL_DEPENDENCIES_PATH}/sdk/linux" CACHE PATH "OPENAL SDK path" FORCE) endif() endif() endif() # concat all the search paths IF(OpenAL_ROOT) SET(OpenAL_INCLUDE_SEARCH_DIRS ${OpenAL_INCLUDE_SEARCH_DIRS} ${OpenAL_ROOT}/include/AL ${OpenAL_ROOT}/include ) SET(OpenAL_LIBRARY_SEARCH_RELEASE_DIRS ${OpenAL_LIBRARY_SEARCH_RELEASE_DIRS} ${OpenAL_ROOT}/lib/Release ${OpenAL_ROOT}/lib ) SET(OpenAL_LIBRARY_SEARCH_DEBUG_DIRS ${OpenAL_LIBRARY_SEARCH_DEBUG_DIRS} ${OpenAL_ROOT}/lib/Debug ${OpenAL_ROOT}/lib ${OpenAL_ROOT}/lib/Release ) ENDIF() # log message IF (NOT OpenAL_FIND_QUIETLY) MESSAGE(STATUS "Checking for OpenAL library") ENDIF() # On iOS, OpenAL comes preinstalled if (APPLE) INCLUDE(AppleMacros) find_apple_system_fwk(OpenAL_LIBRARIES OpenAL) SET(OpenAL_FOUND ${OpenAL_LIBRARIES}) return() endif() # Search for header files FIND_PATH(OpenAL_INCLUDE_DIR al.h PATHS ${OpenAL_INCLUDE_SEARCH_DIRS}) # Search for libraries files (release mode) FIND_LIBRARY(OpenAL_LIBRARY_RELEASE openal OpenAL OpenAL32 OpenAL64 OpenAL_d PATHS ${OpenAL_LIBRARY_SEARCH_RELEASE_DIRS}) # Search for libraries files (debug mode) FIND_LIBRARY(OpenAL_LIBRARY_DEBUG OpenAL32_d OpenAL64_d OpenAL_d openal_d OpenALd openald openal OpenAL OpenAL32 OpenAL64 PATHS ${OpenAL_LIBRARY_SEARCH_DEBUG_DIRS}) # Configure libraries for debug/release SET(OpenAL_INCLUDE_DIRS ${OpenAL_INCLUDE_DIR} CACHE STRING "Directory containing OpenAL header files") SET(OpenAL_LIBRARY debug ${OpenAL_LIBRARY_DEBUG} optimized ${OpenAL_LIBRARY_RELEASE}) SET(OpenAL_LIBRARIES ${OpenAL_LIBRARY} CACHE STRING "OpenAL libraries files") IF(APPLE) #SET(CMAKE_FIND_FRAMEWORK "LAST") FIND_LIBRARY(COREAUDIO_LIBRARY CoreAudio) FIND_LIBRARY(AUDIOUNIT_LIBRARY AudioUnit) FIND_LIBRARY(APPSERVICES_LIBRARY ApplicationServices) SET(OpenAL_LIBRARIES ${OpenAL_LIBRARIES} ${COREAUDIO_LIBRARY} ${AUDIOUNIT_LIBRARY} ${APPSERVICES_LIBRARY}) ENDIF(APPLE) IF(OpenAL_INCLUDE_DIR AND OpenAL_LIBRARY) SET(OpenAL_FOUND TRUE) ENDIF() # Hide those variables in GUI SET(OpenAL_INCLUDE_DIR ${OpenAL_INCLUDE_DIR} CACHE INTERNAL "") SET(OpenAL_LIBRARY_RELEASE ${OpenAL_LIBRARY_RELEASE} CACHE INTERNAL "") SET(OpenAL_LIBRARY_DEBUG ${OpenAL_LIBRARY_DEBUG} CACHE INTERNAL "") SET(OpenAL_LIBRARY ${OpenAL_LIBRARY} CACHE INTERNAL "") # log find result IF(OpenAL_FOUND) IF(NOT OpenAL_FIND_QUIETLY) MESSAGE(STATUS " libraries: ${OpenAL_LIBRARIES}") MESSAGE(STATUS " includes: ${OpenAL_INCLUDE_DIRS}") ENDIF() if(NOT TARGET OpenAL::OpenAL) add_library(OpenAL::OpenAL UNKNOWN IMPORTED) if(OpenAL_INCLUDE_DIRS) set_target_properties(OpenAL::OpenAL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OpenAL_INCLUDE_DIRS}") endif() if(EXISTS "${OpenAL_LIBRARIES}") set_target_properties(OpenAL::OpenAL PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${OpenAL_LIBRARIES}") endif() if(EXISTS "${OpenAL_LIBRARY_RELEASE}") set_property(TARGET OpenAL::OpenAL APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(OpenAL::OpenAL PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" IMPORTED_LOCATION_RELEASE "${OpenAL_LIBRARY_RELEASE}") endif() if(EXISTS "${OpenAL_LIBRARY_DEBUG}") set_property(TARGET OpenAL::OpenAL APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) set_target_properties(OpenAL::OpenAL PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" IMPORTED_LOCATION_DEBUG "${OpenAL_LIBRARY_DEBUG}") endif() endif() ELSE(OpenAL_FOUND) IF(NOT OpenAL_LIBRARIES) MESSAGE(STATUS " OpenAL library or one of it dependencies could not be found.") ENDIF() IF(NOT OpenAL_INCLUDE_DIRS) MESSAGE(STATUS " OpenAL include files could not be found.") ENDIF() ENDIF(OpenAL_FOUND)