From 6095e7ef51e59def4392a2cd09516fc1a4775a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20F=C3=BCrstenberg?= Date: Fri, 9 Jan 2015 20:19:22 +0100 Subject: [PATCH] Add SOVERSION to libobs-opengl Because libobs-opengl is a public library, it's customary to have SONAME embedded in the library file. Also remove the prefix override and remove the prefixing "lib" from the output name. This also requires us to pass the library file name to dlopen invocations. --- CMakeLists.txt | 2 +- cmake/Modules/ObsHelpers.cmake | 17 +++++++++++++++++ libobs-opengl/CMakeLists.txt | 7 ++++--- obs/CMakeLists.txt | 2 ++ obs/obs-app.cpp | 2 +- obs/window-basic-main.cpp | 6 +++--- test/osx/CMakeLists.txt | 1 + test/osx/test.mm | 2 +- test/win/CMakeLists.txt | 1 + test/win/test.cpp | 2 +- 10 files changed, 32 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ff56c931..237afab83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,6 @@ endif() if(NOT INSTALLER_RUN) add_subdirectory(deps) - add_subdirectory(libobs) if(WIN32) add_subdirectory(libobs-d3d11) @@ -80,6 +79,7 @@ if(NOT INSTALLER_RUN) endif() add_subdirectory(libobs-opengl) + add_subdirectory(libobs) add_subdirectory(obs) add_subdirectory(plugins) add_subdirectory(test) diff --git a/cmake/Modules/ObsHelpers.cmake b/cmake/Modules/ObsHelpers.cmake index c8f847267..fdd83c12e 100644 --- a/cmake/Modules/ObsHelpers.cmake +++ b/cmake/Modules/ObsHelpers.cmake @@ -516,3 +516,20 @@ function(install_obs_plugin_with_data target datadir) install_obs_plugin(${target}) install_obs_data(${target} "${datadir}" "obs-plugins/${target}") endfunction() + +function(define_graphic_modules target) + foreach(dl_lib opengl d3d9 d3d11) + string(TOUPPER ${dl_lib} dl_lib_upper) + if(TARGET libobs-${dl_lib}) + target_compile_definitions(${target} + PRIVATE + DL_${dl_lib_upper}="$" + ) + else() + target_compile_definitions(${target} + PRIVATE + DL_${dl_lib_upper}="" + ) + endif() + endforeach() +endfunction() diff --git a/libobs-opengl/CMakeLists.txt b/libobs-opengl/CMakeLists.txt index 9dea56431..edc132b8e 100644 --- a/libobs-opengl/CMakeLists.txt +++ b/libobs-opengl/CMakeLists.txt @@ -1,6 +1,5 @@ project(libobs-opengl) -include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs") find_package(OpenGL REQUIRED) include_directories(${OPENGL_INCLUDE_DIR}) @@ -73,8 +72,10 @@ add_library(libobs-opengl MODULE ${libobs-opengl_HEADERS}) set_target_properties(libobs-opengl PROPERTIES - OUTPUT_NAME libobs-opengl - PREFIX "") + OUTPUT_NAME obs-opengl + VERSION 0.0 + SOVERSION 0 + ) target_link_libraries(libobs-opengl libobs glad diff --git a/obs/CMakeLists.txt b/obs/CMakeLists.txt index 305a3509b..74e8e997b 100644 --- a/obs/CMakeLists.txt +++ b/obs/CMakeLists.txt @@ -179,6 +179,8 @@ target_link_libraries(obs Qt5::Network ${obs_PLATFORM_LIBRARIES}) +define_graphic_modules(obs) + install_obs_core(obs) install_obs_data(obs data obs-studio) diff --git a/obs/obs-app.cpp b/obs/obs-app.cpp index 531f9ae47..ec4b48a5b 100644 --- a/obs/obs-app.cpp +++ b/obs/obs-app.cpp @@ -246,7 +246,7 @@ const char *OBSApp::GetRenderModule() const "Renderer"); return (astrcmpi(renderer, "Direct3D 11") == 0) ? - "libobs-d3d11" : "libobs-opengl"; + DL_D3D11 : DL_OPENGL; } bool OBSApp::OBSInit() diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index fbf7f1cb8..f9cddaabe 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -1421,13 +1421,13 @@ int OBSBasic::ResetVideo() ret = AttemptToResetVideo(&ovi); if (IS_WIN32 && ret != OBS_VIDEO_SUCCESS) { /* Try OpenGL if DirectX fails on windows */ - if (astrcmpi(ovi.graphics_module, "libobs-opengl") != 0) { + if (astrcmpi(ovi.graphics_module, DL_OPENGL) != 0) { blog(LOG_WARNING, "Failed to initialize obs video (%d) " "with graphics_module='%s', retrying " "with graphics_module='%s'", ret, ovi.graphics_module, - "libobs-opengl"); - ovi.graphics_module = "libobs-opengl"; + DL_OPENGL); + ovi.graphics_module = DL_OPENGL; ret = AttemptToResetVideo(&ovi); } } diff --git a/test/osx/CMakeLists.txt b/test/osx/CMakeLists.txt index 59dd9d5ea..6cf3546f4 100644 --- a/test/osx/CMakeLists.txt +++ b/test/osx/CMakeLists.txt @@ -15,3 +15,4 @@ add_executable(osx_test target_link_libraries(osx_test libobs ${COCOA}) +define_graphic_modules(osx_test) diff --git a/test/osx/test.mm b/test/osx/test.mm index 320b14c1f..4630368b7 100644 --- a/test/osx/test.mm +++ b/test/osx/test.mm @@ -45,7 +45,7 @@ static void CreateOBS(NSView *view) ovi.adapter = 0; ovi.fps_num = 30000; ovi.fps_den = 1001; - ovi.graphics_module = "libobs-opengl"; + ovi.graphics_module = DL_OPENGL; ovi.output_format = VIDEO_FORMAT_RGBA; ovi.base_width = cx; ovi.base_height = cy; diff --git a/test/win/CMakeLists.txt b/test/win/CMakeLists.txt index 43057a837..fd1ba9541 100644 --- a/test/win/CMakeLists.txt +++ b/test/win/CMakeLists.txt @@ -9,3 +9,4 @@ add_executable(win-test WIN32 ${win-text_SOURCES}) target_link_libraries(win-test libobs) +define_graphic_modules(win-test) diff --git a/test/win/test.cpp b/test/win/test.cpp index f4bc1fb70..148b451bd 100644 --- a/test/win/test.cpp +++ b/test/win/test.cpp @@ -80,7 +80,7 @@ static void CreateOBS(HWND hwnd) ovi.base_height = rc.bottom; ovi.fps_num = 30000; ovi.fps_den = 1001; - ovi.graphics_module = "libobs-opengl"; + ovi.graphics_module = DL_OPENGL; ovi.window_width = rc.right; ovi.window_height = rc.bottom; ovi.output_format = VIDEO_FORMAT_RGBA;