Browse Source

Generate proper DL_OPENGL value for linux

Since we rely on the dynamic linker to find the library for us via
dlopen(), we need to have DL_OPENGL be .so.N, not the full library
filename, as ldconfig doesn't cache the full filename

Use of TARGET_SONAME_FILE requires the library to be marked as SHARED,
not MODULE

This closes pull request #370
Kevin Tardif 10 năm trước cách đây
mục cha
commit
c293c17620

+ 11 - 4
cmake/Modules/ObsHelpers.cmake

@@ -521,10 +521,17 @@ function(define_graphic_modules target)
 	foreach(dl_lib opengl d3d9 d3d11)
 	foreach(dl_lib opengl d3d9 d3d11)
 		string(TOUPPER ${dl_lib} dl_lib_upper)
 		string(TOUPPER ${dl_lib} dl_lib_upper)
 		if(TARGET libobs-${dl_lib})
 		if(TARGET libobs-${dl_lib})
-			target_compile_definitions(${target}
-				PRIVATE
-				DL_${dl_lib_upper}="$<TARGET_FILE_NAME:libobs-${dl_lib}>"
-				)
+			if(UNIX AND UNIX_STRUCTURE)
+				target_compile_definitions(${target}
+					PRIVATE
+					DL_${dl_lib_upper}="$<TARGET_SONAME_FILE_NAME:libobs-${dl_lib}>"
+					)
+			else()
+				target_compile_definitions(${target}
+					PRIVATE
+					DL_${dl_lib_upper}="$<TARGET_FILE_NAME:libobs-${dl_lib}>"
+					)
+			endif()
 		else()
 		else()
 			target_compile_definitions(${target}
 			target_compile_definitions(${target}
 				PRIVATE
 				PRIVATE

+ 9 - 3
libobs-opengl/CMakeLists.txt

@@ -67,9 +67,15 @@ set(libobs-opengl_HEADERS
 	gl-shaderparser.h
 	gl-shaderparser.h
 	gl-subsystem.h)
 	gl-subsystem.h)
 
 
-add_library(libobs-opengl MODULE
-	${libobs-opengl_SOURCES}
-	${libobs-opengl_HEADERS})
+if(WIN32 OR APPLE)
+	add_library(libobs-opengl MODULE
+		${libobs-opengl_SOURCES}
+		${libobs-opengl_HEADERS})
+else()
+	add_library(libobs-opengl SHARED
+		${libobs-opengl_SOURCES}
+		${libobs-opengl_HEADERS})
+endif()
 
 
 if(WIN32 OR APPLE)
 if(WIN32 OR APPLE)
 set_target_properties(libobs-opengl
 set_target_properties(libobs-opengl