win-capture: Fix added resources not properly copied to rundir

The `add_target_resource` function uses unnecessary path components
when copying files to the rundir, resulting in files added that way
not to end up where OBS expects them to.

The generated binaries created by sub-targets also need to be copied
as part of `win-capture`'s data files, which was easy to fix as the
target exists before CMake switches into the subdirectories.
master
PatTheMav 2022-03-30 11:10:54 +02:00
parent a6532fc176
commit d42c98fa22
No known key found for this signature in database
GPG Key ID: CEFD5D83C12A66B3
5 changed files with 56 additions and 37 deletions

View File

@ -157,8 +157,7 @@ function(add_target_resource target resource destination)
install(
FILES ${resource}
DESTINATION
${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
DESTINATION ${OBS_DATA_DESTINATION}/${destination}
COMPONENT obs_${target}
EXCLUDE_FROM_ALL)
endfunction()
@ -458,20 +457,16 @@ function(_install_obs_datatarget target destination)
install(
TARGETS ${target}
LIBRARY
DESTINATION
${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
COMPONENT obs_${target}
RUNTIME
DESTINATION
${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
COMPONENT obs_${target}
EXCLUDE_FROM_ALL)
LIBRARY DESTINATION ${OBS_DATA_DESTINATION}/${destination}
COMPONENT obs_${target}
RUNTIME DESTINATION ${OBS_DATA_DESTINATION}/${destination}
COMPONENT obs_${target}
EXCLUDE_FROM_ALL)
if(OS_WINDOWS)
if(MSVC)
add_target_resource(${target} "$<TARGET_PDB_FILE:${target}>"
"${destination}")
"${destination}" OPTIONAL)
endif()
if(DEFINED ENV{obsInstallerTempDir})
@ -487,4 +482,14 @@ function(_install_obs_datatarget target destination)
EXCLUDE_FROM_ALL)
endif()
endif()
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND
"${CMAKE_COMMAND}" --install .. --config $<CONFIG> --prefix
${OBS_OUTPUT_DIR}/$<CONFIG> --component obs_${target} >
"$<IF:$<PLATFORM_ID:Windows>,nul,/dev/null>"
COMMENT "Installing ${target} to OBS rundir"
VERBATIM)
endfunction()

View File

@ -152,8 +152,27 @@ function(setup_target_resources target destination)
endfunction()
# Helper function to set up specific resource files for targets
function(add_target_resource target resource destination)
_add_target_resource(${ARGV})
function(add_target_resource)
set(target ${ARGV0})
set(resource ${ARGV1})
set(destination ${ARGV2})
if(${ARGC} EQUAL 4)
set(optional ${ARGV3})
else()
set(optional "")
endif()
install(
FILES ${resource}
DESTINATION ${OBS_DATA_DESTINATION}/${destination}
COMPONENT ${target}_Runtime
${optional})
install(
FILES ${resource}
DESTINATION ${OBS_DATA_DESTINATION}/${destination}
COMPONENT obs_${target}
${optional} EXCLUDE_FROM_ALL)
if(DEFINED ENV{OBS_InstallerTempDir})
install(
@ -161,7 +180,7 @@ function(add_target_resource target resource destination)
DESTINATION
$ENV{OBS_InstallerTempDir}/${OBS_DATA_DESTINATION}/${destination}
COMPONENT obs_${target}
EXCLUDE_FROM_ALL)
${optional} EXCLUDE_FROM_ALL)
endif()
endfunction()

View File

@ -20,9 +20,8 @@ target_link_libraries(get-graphics-offsets d3d9.lib dxgi.lib d3d11.lib)
if(MSVC)
target_compile_options(get-graphics-offsets
PRIVATE "$<IF:$<CONFIG:Debug>,/MTd,/MT>")
add_target_resource(
get-graphics-offsets "$<TARGET_PDB_FILE:get-graphics-offsets>"
"obs-plugins/win-capture/")
add_target_resource(win-capture "$<TARGET_PDB_FILE:get-graphics-offsets>"
"obs-plugins/win-capture/" OPTIONAL)
endif()
set_target_properties(get-graphics-offsets PROPERTIES FOLDER
@ -33,5 +32,7 @@ set_target_properties(
"get-graphics-offsets$<IF:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>,64,32>"
)
add_target_resource(get-graphics-offsets "$<TARGET_FILE:get-graphics-offsets>"
add_target_resource(win-capture "$<TARGET_FILE:get-graphics-offsets>"
"obs-plugins/win-capture/")
add_dependencies(win-capture get-graphics-offsets)

View File

@ -33,8 +33,8 @@ target_link_libraries(graphics-hook PRIVATE OBS::ipc-util Detours::Detours
if(MSVC)
target_compile_options(graphics-hook PRIVATE "$<IF:$<CONFIG:Debug>,/MTd,/MT>")
add_target_resource(graphics-hook "$<TARGET_PDB_FILE:graphics-hook>"
"obs-plugins/win-capture/")
add_target_resource(win-capture "$<TARGET_PDB_FILE:graphics-hook>"
"obs-plugins/win-capture/" OPTIONAL)
endif()
set_target_properties(
@ -53,22 +53,14 @@ if(TARGET Vulkan::Vulkan)
target_compile_definitions(graphics-hook PRIVATE COMPILE_VULKAN_HOOK)
add_target_resource(
graphics-hook "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan64.json"
win-capture "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan64.json"
"obs-plugins/win-capture/")
add_target_resource(
graphics-hook "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan32.json"
win-capture "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan32.json"
"obs-plugins/win-capture/")
add_custom_command(
TARGET graphics-hook
POST_BUILD
COMMAND
"${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan64.json"
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/data/obs-plugins/win-capture/obs-vulkan64.json"
COMMAND
"${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan32.json"
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/data/obs-plugins/win-capture/obs-vulkan32.json"
VERBATIM)
endif()
add_target_resource(graphics-hook "$<TARGET_FILE:graphics-hook>"
add_target_resource(win-capture "$<TARGET_FILE:graphics-hook>"
"obs-plugins/win-capture/")
add_dependencies(win-capture graphics-hook)

View File

@ -10,8 +10,8 @@ target_include_directories(inject-helper PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
if(MSVC)
target_compile_options(inject-helper PRIVATE "$<IF:$<CONFIG:Debug>,/MTd,/MT>")
add_target_resource(inject-helper "$<TARGET_PDB_FILE:inject-helper>"
"obs-plugins/win-capture/")
add_target_resource(win-capture "$<TARGET_PDB_FILE:inject-helper>"
"obs-plugins/win-capture/" OPTIONAL)
endif()
set_target_properties(
@ -20,5 +20,7 @@ set_target_properties(
OUTPUT_NAME
"inject-helper$<IF:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>,64,32>")
add_target_resource(inject-helper "$<TARGET_FILE:inject-helper>"
add_target_resource(win-capture "$<TARGET_FILE:inject-helper>"
"obs-plugins/win-capture/")
add_dependencies(win-capture inject-helper)