fix dlopen detection so that loading plugins work
make sure system bcg729 is found and not BC's fork on https://gitlab.linphone.org/BC/public/bcg729
we don't have /usr/X11R6/lib/libGLX.so but only GL is required ?
Index: CMakeLists.txt
--- CMakeLists.txt.orig
+++ CMakeLists.txt
@@ -96,6 +96,7 @@ cmake_dependent_option(ENABLE_QSA "Enable QSA (QNX Sou
 cmake_dependent_option(ENABLE_OSS "Enable OSS support." NO "ENABLE_SOUND;LINUX_OR_BSD" NO)
 cmake_dependent_option(ENABLE_PORTAUDIO "Enable portaudio native support." NO "ENABLE_SOUND" NO)
 cmake_dependent_option(ENABLE_PULSEAUDIO "Enable pulseaudio support." YES "ENABLE_SOUND" NO)
+cmake_dependent_option(ENABLE_SNDIO "Enable sndio support." YES "ENABLE_SOUND" NO)
 option(ENABLE_G726 "Build mediastreamer2 with the G726 codec." NO)
 option(ENABLE_GSM "Build mediastreamer2 with the GSM codec." YES)
 option(ENABLE_BV16 "Build mediastreamer2 with the BV16 codec." YES)
@@ -153,7 +154,7 @@ if(ENABLE_OSS)
 	endif()
 endif()
 
-check_library_exists("dl" "dlopen" "" HAVE_DLOPEN)
+check_library_exists("c" "dlopen" "" HAVE_DLOPEN)
 
 include(TestBigEndian)
 test_big_endian(WORDS_BIGENDIAN)
@@ -215,6 +216,12 @@ endif()
 if(ENABLE_PORTAUDIO)
 	find_package(PortAudio REQUIRED)
 endif()
+if(ENABLE_SNDIO)
+	find_library(SNDIO NAMES sndio)
+	if (SNDIO)
+		set(SNDIO_FOUND ON)
+	endif()
+endif()
 if(ENABLE_PULSEAUDIO)
 	find_package(PulseAudio)
 	if(NOT PulseAudio_FOUND)
@@ -280,14 +287,14 @@ if(ENABLE_VIDEO AND APPLE)
 	include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/OpenGL")
 endif()
 if(ENABLE_GLX)
-	find_package(OpenGL COMPONENTS GLX)
-	if(OpenGL_GLX_FOUND)
+	find_package(OpenGL)
+	if(OpenGL_FOUND)
 		set(HAVE_GLX 1)
 	else()
 		set(ENABLE_GLX OFF CACHE BOOL "Enable X11+OpenGL rendering support (requires glx and glew)." FORCE)
 	endif()
 endif()
-if(NOT APPLE AND NOT ANDROID AND OPENGL_FOUND OR OpenGL_GLX_FOUND)	
+if(NOT APPLE AND NOT ANDROID AND OPENGL_FOUND)	
 	set(GLEW_VERBOSE 1)
 	include(FindGLEW) # Use cmake find in place of find_package(Glew REQUIRED)
 	if(NOT GLEW_FOUND)
@@ -327,12 +334,12 @@ if(ENABLE_QNX)
 	find_package(CamApi REQUIRED)
 endif()
 
-if(ENABLE_SOUND AND NOT(WIN32 OR ENABLE_ALSA OR ENABLE_ARTSC OR ENABLE_MACSND OR ENABLE_MACAQSND OR ENABLE_OSS OR ENABLE_PORTAUDIO OR ENABLE_PULSEAUDIO OR ENABLE_QSA OR ENABLE_ANDROIDSND))
+if(ENABLE_SOUND AND NOT(WIN32 OR ENABLE_ALSA OR ENABLE_ARTSC OR ENABLE_MACSND OR ENABLE_MACAQSND OR ENABLE_OSS OR ENABLE_PORTAUDIO OR ENABLE_PULSEAUDIO OR ENABLE_SNDIO OR ENABLE_QSA OR ENABLE_ANDROIDSND))
 	message(FATAL_ERROR "Could not find a support sound driver API. Use -DENABLE_SOUND=NO if you don't care about having sound.")
 endif()
 
 if(ENABLE_G729 OR ENABLE_G729B_CNG)
-	find_package(BCG729 1.1.1)
+	find_package(Bcg729 1.1.1)
 	if(NOT BCG729_FOUND)
 		message(WARNING "Could not find bcg729, mediastreamer2 will be compiled without G729 codec and G729 AnnexB in RFC3389.")
 		set(ENABLE_G729 OFF CACHE BOOL "Build mediastreamer2 with the G729 codec." FORCE)
@@ -416,9 +423,6 @@ endif()
 if(ANDROID AND ENABLE_VIDEO)
 	list(APPEND LINK_LIBS EGL GLESv3 android)
 endif()
-if(HAVE_DLOPEN)
-	list(APPEND LINK_LIBS dl)
-endif()
 if(ALSA_FOUND)
 	list(APPEND LINK_LIBS ALSA::ALSA)
 	set(__ALSA_ENABLED__ 1)
@@ -435,6 +439,10 @@ if(PulseAudio_FOUND)
 	list(APPEND LINK_LIBS ${PulseAudio_TARGET})
   	set(__PULSEAUDIO_ENABLED__ 1)
 endif()
+if(SNDIO_FOUND)
+	list(APPEND LINK_LIBS sndio)
+  	set(__SNDIO_ENABLED__ 1)
+endif()
 if(QSA_FOUND)
 	list(APPEND LINK_LIBS ${QSA_TARGET})
 	list(APPEND LINK_LIBS ${QnxAudioManager_TARGET})
@@ -488,7 +496,7 @@ if(BCG729_FOUND)
 	if(ENABLE_G729_CNG)
 		add_definitions("-DHAVE_G729B=1")
 	endif()
-	list(APPEND LINK_LIBS ${BCG729_TARGET})
+	list(APPEND LINK_LIBS ${BCG729_LIBRARIES})
 endif()
 if(GSM_FOUND)
 	list(APPEND LINK_LIBS ${GSM_TARGET})
