CMakeLists.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. cmake_minimum_required(VERSION 3.28...3.30)
  2. find_package(Detours REQUIRED)
  3. find_package(Vulkan REQUIRED)
  4. if(NOT TARGET OBS::ipc-util)
  5. add_subdirectory("${CMAKE_SOURCE_DIR}/shared/ipc-util" ipc-util)
  6. endif()
  7. if(NOT TARGET OBS::obfuscate)
  8. add_subdirectory("${CMAKE_SOURCE_DIR}/libobs" "${CMAKE_BINARY_DIR}/libobs")
  9. endif()
  10. if(NOT TARGET OBS::d3d8-api)
  11. add_subdirectory("${CMAKE_SOURCE_DIR}/shared/obs-d3d8-api" obs-d3d8-api)
  12. endif()
  13. if(NOT TARGET OBS::hook-config)
  14. add_subdirectory("${CMAKE_SOURCE_DIR}/shared/obs-hook-config" obs-hook-config)
  15. endif()
  16. add_library(graphics-hook MODULE)
  17. add_library(OBS::graphics-hook ALIAS graphics-hook)
  18. target_sources(
  19. graphics-hook
  20. PRIVATE
  21. d3d10-capture.cpp
  22. d3d11-capture.cpp
  23. d3d12-capture.cpp
  24. d3d8-capture.cpp
  25. d3d9-capture.cpp
  26. d3d9-patches.hpp
  27. dxgi-capture.cpp
  28. gl-capture.c
  29. gl-decs.h
  30. graphics-hook.c
  31. graphics-hook.h
  32. graphics-hook.rc
  33. )
  34. target_compile_definitions(graphics-hook PRIVATE COMPILE_D3D12_HOOK)
  35. target_link_libraries(
  36. graphics-hook
  37. PRIVATE OBS::d3d8-api OBS::hook-config OBS::ipc-util OBS::obfuscate Detours::Detours dxguid
  38. )
  39. target_link_options(graphics-hook PRIVATE /IGNORE:4099)
  40. if(TARGET Vulkan::Vulkan)
  41. target_sources(graphics-hook PRIVATE vulkan-capture.c vulkan-capture.h)
  42. target_link_libraries(graphics-hook PRIVATE Vulkan::Vulkan)
  43. target_compile_definitions(graphics-hook PRIVATE COMPILE_VULKAN_HOOK)
  44. endif()
  45. if(OBS_PARENT_ARCHITECTURE STREQUAL CMAKE_VS_PLATFORM_NAME)
  46. if(CMAKE_VS_PLATFORM_NAME STREQUAL ARM64)
  47. add_custom_command(
  48. TARGET graphics-hook
  49. POST_BUILD
  50. COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_SOURCE_DIR}/build_x64 --config $<CONFIG> -t graphics-hook
  51. COMMENT "Build x64 graphics-hook"
  52. )
  53. endif()
  54. if(CMAKE_VS_PLATFORM_NAME MATCHES "(ARM64|x64)")
  55. add_custom_command(
  56. TARGET graphics-hook
  57. POST_BUILD
  58. COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_SOURCE_DIR}/build_x86 --config $<CONFIG> -t graphics-hook
  59. COMMENT "Build x86 graphics-hook"
  60. )
  61. endif()
  62. add_dependencies(win-capture graphics-hook)
  63. endif()
  64. if(CMAKE_VS_PLATFORM_NAME STREQUAL ARM64)
  65. set(_OUTPUT_NAME graphics-hook-arm64)
  66. elseif(CMAKE_VS_PLATFORM_NAME STREQUAL x64)
  67. set(_OUTPUT_NAME graphics-hook64)
  68. else()
  69. set(_OUTPUT_NAME graphics-hook32)
  70. endif()
  71. set_target_properties_obs(
  72. graphics-hook PROPERTIES
  73. FOLDER "plugins/win-capture"
  74. OUTPUT_NAME ${_OUTPUT_NAME}
  75. MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
  76. )