]> git.mxchange.org Git - simgear.git/commitdiff
Find OpenAL the proper way
authorErik Hofman <erik@ehofman.com>
Mon, 30 May 2016 08:50:22 +0000 (10:50 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 13 Aug 2016 08:21:16 +0000 (10:21 +0200)
CMakeLists.txt
CMakeModules/FindOpenAL.cmake [new file with mode: 0644]

index 90dfc810f9eeb97db58cc7bf5404387be3292940..0721332c079c3f227348b095ac173a05c3bbd4d7 100644 (file)
@@ -243,7 +243,6 @@ check_include_file(sys/time.h HAVE_SYS_TIME_H)
 check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
 check_include_file(unistd.h HAVE_UNISTD_H)
 check_include_file(windows.h HAVE_WINDOWS_H)
-check_include_file(AL/alext.h HAVE_AL_EXT_H)
 
 if(HAVE_INTTYPES_H)
   # ShivaVG needs inttypes.h
@@ -386,7 +385,7 @@ include_directories(BEFORE ${PROJECT_BINARY_DIR}/simgear)
 include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
     ${Boost_INCLUDE_DIRS}
     ${ZLIB_INCLUDE_DIR}
-    ${OPENAL_INCLUDE_DIR}
+    ${OPENAL_INCLUDE_DIRS}
     ${CURL_INCLUDE_DIRS}
 )
 
diff --git a/CMakeModules/FindOpenAL.cmake b/CMakeModules/FindOpenAL.cmake
new file mode 100644 (file)
index 0000000..d86bef2
--- /dev/null
@@ -0,0 +1,59 @@
+#  Copyright Matus Chochlik.
+#  Distributed under the Boost Software License, Version 1.0.
+#  See accompanying file LICENSE_1_0.txt or copy at
+#   http://www.boost.org/LICENSE_1_0.txt
+#
+#  2016-05-30: Updated for FlightGear --EMH--
+#
+unset(OPENAL_INCLUDE_DIRS)
+set(OPENAL_FOUND 0)
+#
+# try to find AL/al.h
+find_path(
+       OPENAL_AL_H_DIR AL/al.h
+       PATHS ${HEADER_SEARCH_PATHS}
+       NO_DEFAULT_PATH
+)
+# if that didn't work try the system directories
+if((NOT OPENAL_AL_H_DIR) OR (NOT EXISTS ${OPENAL_AL_H_DIR}))
+       find_path(OPENAL_AL_H_DIR AL/al.h)
+endif()
+# if found append it to the include directories
+if((OPENAL_AL_H_DIR) AND (EXISTS ${OPENAL_AL_H_DIR}))
+       set(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIRS} ${OPENAL_AL_H_DIR})
+       set(HAVE_AL_H true)
+       set(OPENAL_FOUND 1)
+endif()
+#
+#
+# try to find AL/alext.h
+find_path(
+       OPENAL_ALEXT_H_DIR AL/alext.h
+       PATHS ${HEADER_SEARCH_PATHS}
+       NO_DEFAULT_PATH
+)
+# if that didn't work try the system directories
+if((NOT OPENAL_ALEXT_H_DIR) OR (NOT EXISTS ${OPENAL_ALEXT_H_DIR}))
+       find_path(OPENAL_ALEXT_H_DIR AL/alext.h)
+endif()
+#
+if((OPENAL_ALEXT_H_DIR) AND (EXISTS ${OPENAL_ALEXT_H_DIR}))
+       set(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIRS} ${OPENAL_ALEXT_H_DIR})
+       set(HAVE_ALEXT_H true)
+endif()
+
+# try to find the AL library
+find_library(
+       OPENAL_LIBRARY NAMES openal
+       PATHS ${LIBRARY_SEARCH_PATHS}
+       NO_DEFAULT_PATH
+)
+if(NOT OPENAL_LIBRARY)
+       find_library(OPENAL_LIBRARY NAMES openal)
+endif()
+
+set(OPENAL_LIBRARIES "")
+if(OPENAL_LIBRARY AND EXISTS ${OPENAL_LIBRARY})
+       set(OPENAL_LIBRARIES ${OPENAL_LIBRARIES} ${OPENAL_LIBRARY})
+endif()
+