CMakeLists.txt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. cmake_minimum_required(VERSION 3.22...3.25)
  2. legacy_check()
  3. add_library(libobs-opengl SHARED)
  4. add_library(OBS::libobs-opengl ALIAS libobs-opengl)
  5. if(NOT TARGET OBS::glad)
  6. add_subdirectory("${CMAKE_SOURCE_DIR}/deps/glad" "${CMAKE_BINARY_DIR}/deps/glad")
  7. endif()
  8. target_sources(
  9. libobs-opengl
  10. PRIVATE gl-helpers.c
  11. gl-helpers.h
  12. gl-indexbuffer.c
  13. gl-shader.c
  14. gl-shaderparser.c
  15. gl-shaderparser.h
  16. gl-stagesurf.c
  17. gl-subsystem.c
  18. gl-subsystem.h
  19. gl-texture2d.c
  20. gl-texture3d.c
  21. gl-texturecube.c
  22. gl-vertexbuffer.c
  23. gl-zstencil.c)
  24. target_link_libraries(libobs-opengl PRIVATE OBS::libobs OBS::glad)
  25. if(OS_WINDOWS)
  26. configure_file(cmake/windows/obs-module.rc.in libobs-opengl.rc)
  27. target_sources(libobs-opengl PRIVATE gl-windows.c libobs-opengl.rc)
  28. elseif(OS_MACOS)
  29. find_library(COCOA Cocoa)
  30. find_library(IOSURF IOSurface)
  31. target_sources(libobs-opengl PRIVATE gl-cocoa.m)
  32. target_compile_definitions(libobs-opengl PRIVATE GL_SILENCE_DEPRECATION)
  33. target_compile_options(libobs-opengl PRIVATE -Wno-strict-prototypes)
  34. target_link_libraries(libobs-opengl PRIVATE ${COCOA} ${IOSURF})
  35. elseif(OS_LINUX OR OS_FREEBSD)
  36. find_package(X11 REQUIRED)
  37. find_package(
  38. xcb
  39. COMPONENTS xcb
  40. REQUIRED)
  41. find_package(x11-xcb REQUIRED)
  42. target_sources(libobs-opengl PRIVATE gl-egl-common.c gl-nix.c gl-x11-egl.c)
  43. target_link_libraries(libobs-opengl PRIVATE xcb::xcb X11::x11-xcb)
  44. if(ENABLE_WAYLAND)
  45. find_package(
  46. OpenGL
  47. COMPONENTS EGL
  48. REQUIRED)
  49. find_package(Wayland REQUIRED)
  50. target_sources(libobs-opengl PRIVATE gl-wayland-egl.c)
  51. target_link_libraries(libobs-opengl PRIVATE OpenGL::EGL Wayland::EGL)
  52. endif()
  53. endif()
  54. target_enable_feature(libobs "OpenGL renderer")
  55. set_target_properties_obs(
  56. libobs-opengl
  57. PROPERTIES FOLDER core
  58. VERSION 0
  59. PREFIX ""
  60. SOVERSION "${OBS_VERSION_MAJOR}")