Selaa lähdekoodia

cmake: Fix targets not being copied into rundir on Windows and Linux

Windows and Linux do not require a contained application bundle to run
and debug OBS - as such targets can and should be copied independently
from the main OBS application target.

Also silences the output of the `install` step that sets up those files.
PatTheMav 3 vuotta sitten
vanhempi
sitoutus
1a7f5fb48e

+ 47 - 15
cmake/Modules/ObsHelpers.cmake

@@ -39,10 +39,20 @@ function(setup_binary_target target)
   # Set up installation paths for development rundir
   install(
     TARGETS ${target}
-    RUNTIME DESTINATION ${OBS_EXECUTABLE_DESTINATION} COMPONENT obs_rundir
-    LIBRARY DESTINATION ${OBS_LIBRARY_DESTINATION} COMPONENT obs_rundir
+    RUNTIME DESTINATION ${OBS_EXECUTABLE_DESTINATION} COMPONENT obs_${target}
+    LIBRARY DESTINATION ${OBS_LIBRARY_DESTINATION} COMPONENT obs_${target}
     PUBLIC_HEADER DESTINATION ${OBS_INCLUDE_DESTINATION} EXCLUDE_FROM_ALL)
 
+  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 OBS rundir"
+    VERBATIM)
+
 endfunction()
 
 # Helper function to set up OBS plugin targets
@@ -58,13 +68,23 @@ function(setup_plugin_target target)
 
   install(
     TARGETS ${target}
-    RUNTIME DESTINATION ${OBS_PLUGIN_DESTINATION} COMPONENT obs_rundir
+    RUNTIME DESTINATION ${OBS_PLUGIN_DESTINATION} COMPONENT obs_${target}
     LIBRARY DESTINATION ${OBS_PLUGIN_DESTINATION}
-            COMPONENT obs_rundir
+            COMPONENT obs_${target}
             EXCLUDE_FROM_ALL)
 
   setup_target_resources("${target}" "obs-plugins/${target}")
   set_property(GLOBAL APPEND PROPERTY OBS_MODULE_LIST "${target}")
+  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)
+
   message(STATUS "OBS:   ENABLED   ${target}")
 endfunction()
 
@@ -81,7 +101,7 @@ function(setup_script_plugin_target target)
   install(
     TARGETS ${target}
     LIBRARY DESTINATION ${OBS_SCRIPT_PLUGIN_DESTINATION}
-            COMPONENT obs_rundir
+            COMPONENT obs_${target}
             EXCLUDE_FROM_ALL)
 
   if(${target} STREQUAL "obspython")
@@ -93,10 +113,20 @@ function(setup_script_plugin_target target)
     install(
       FILES "$<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.py"
       DESTINATION ${OBS_SCRIPT_PLUGIN_DESTINATION}
-      COMPONENT obs_rundir
+      COMPONENT obs_${target}
       EXCLUDE_FROM_ALL)
   endif()
   set_property(GLOBAL APPEND PROPERTY OBS_SCRIPTING_MODULE_LIST "${target}")
+  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)
+
   message(STATUS "OBS:   ENABLED   ${target}")
 endfunction()
 
@@ -113,7 +143,7 @@ function(setup_target_resources target destination)
       DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/
       DESTINATION ${OBS_DATA_DESTINATION}/${destination}
       USE_SOURCE_PERMISSIONS
-      COMPONENT obs_rundir
+      COMPONENT obs_${target}
       EXCLUDE_FROM_ALL)
   endif()
 endfunction()
@@ -129,7 +159,7 @@ function(add_target_resource target resource destination)
     FILES ${resource}
     DESTINATION
       ${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
-    COMPONENT obs_rundir
+    COMPONENT obs_${target}
     EXCLUDE_FROM_ALL)
 endfunction()
 
@@ -172,8 +202,10 @@ function(setup_obs_app target)
   add_custom_command(
     TARGET ${target}
     POST_BUILD
-    COMMAND "${CMAKE_COMMAND}" --install .. --config $<CONFIG> --prefix
-            ${OBS_OUTPUT_DIR}/$<CONFIG> --component obs_rundir
+    COMMAND
+      "${CMAKE_COMMAND}" --install .. --config $<CONFIG> --prefix
+      ${OBS_OUTPUT_DIR}/$<CONFIG> --component obs_rundir >
+      "$<IF:$<PLATFORM_ID:Windows>,nul,/dev/null>"
     COMMENT "Installing OBS rundir"
     VERBATIM)
 endfunction()
@@ -382,7 +414,7 @@ function(_install_obs_plugin_with_data target source)
       DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${source}/
       DESTINATION
         ${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_DATA_DESTINATION}/obs-plugins/${target}
-      COMPONENT obs_rundir
+      COMPONENT obs_${target}
       EXCLUDE_FROM_ALL)
 
     if(OS_WINDOWS AND DEFINED ENV{obsInstallerTempDir})
@@ -390,7 +422,7 @@ function(_install_obs_plugin_with_data target source)
         DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${source}/
         DESTINATION
           $ENV{obsInstallerTempDir}/${OBS_DATA_DESTINATION}/obs-plugins/${target}
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
         EXCLUDE_FROM_ALL)
     endif()
   endif()
@@ -416,11 +448,11 @@ function(_install_obs_datatarget target destination)
     LIBRARY
       DESTINATION
         ${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
-      COMPONENT obs_rundir
+      COMPONENT obs_${target}
     RUNTIME
       DESTINATION
         ${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_DATA_DESTINATION}/${destination}
-      COMPONENT obs_rundir
+      COMPONENT obs_${target}
       EXCLUDE_FROM_ALL)
 
   if(OS_WINDOWS)
@@ -438,7 +470,7 @@ function(_install_obs_datatarget target destination)
         LIBRARY
           DESTINATION
             $ENV{obsInstallerTempDir}/${OBS_DATA_DESTINATION}/${destination}/$<TARGET_FILE_NAME:${target}>
-          COMPONENT obs_rundir
+          COMPONENT obs_${target}
           EXCLUDE_FROM_ALL)
     endif()
   endif()

+ 16 - 16
cmake/Modules/ObsHelpers_Windows.cmake

@@ -7,12 +7,12 @@ function(setup_binary_target target)
       TARGETS ${target}
       RUNTIME
         DESTINATION $ENV{OBS_InstallerTempDir}/${OBS_EXECUTABLE_DESTINATION}
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
       LIBRARY DESTINATION $ENV{OBS_InstallerTempDir}/${OBS_LIBRARY_DESTINATION}
-              COMPONENT obs_rundir
+              COMPONENT obs_${target}
       PUBLIC_HEADER
         DESTINATION ${OBS_INCLUDE_DESTINATION}
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
         EXCLUDE_FROM_ALL)
 
     if(MSVC)
@@ -21,7 +21,7 @@ function(setup_binary_target target)
         CONFIGURATIONS "RelWithDebInfo" "Debug"
         DESTINATION
           $ENV{OBS_InstallerTempDir}/$<IF:$<STREQUAL:$<TARGET_PROPERTY:${target},TYPE>,EXECUTABLE>,${OBS_EXECUTABLE_DESTINATION},${OBS_LIBRARY_DESTINATION}>
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
         OPTIONAL EXCLUDE_FROM_ALL)
     endif()
   endif()
@@ -40,7 +40,7 @@ function(setup_binary_target target)
       CONFIGURATIONS "RelWithDebInfo" "Debug"
       DESTINATION
         $<IF:$<STREQUAL:$<TARGET_PROPERTY:${target},TYPE>,EXECUTABLE>,${OBS_EXECUTABLE_DESTINATION},${OBS_LIBRARY_DESTINATION}>
-      COMPONENT obs_rundir
+      COMPONENT obs_${target}
       OPTIONAL EXCLUDE_FROM_ALL)
   endif()
 
@@ -65,7 +65,7 @@ function(setup_plugin_target target)
       FILES $<TARGET_PDB_FILE:${target}>
       CONFIGURATIONS "RelWithDebInfo" "Debug"
       DESTINATION ${OBS_PLUGIN_DESTINATION}
-      COMPONENT obs_rundir
+      COMPONENT obs_${target}
       OPTIONAL EXCLUDE_FROM_ALL)
   endif()
 
@@ -73,9 +73,9 @@ function(setup_plugin_target target)
     install(
       TARGETS ${target}
       RUNTIME DESTINATION $ENV{OBS_InstallerTempDir}/${OBS_PLUGIN_DESTINATION}
-              COMPONENT obs_rundir
+              COMPONENT obs_${target}
       LIBRARY DESTINATION $ENV{OBS_InstallerTempDir}/${OBS_PLUGIN_DESTINATION}
-              COMPONENT obs_rundir
+              COMPONENT obs_${target}
               EXCLUDE_FROM_ALL)
 
     if(MSVC)
@@ -83,7 +83,7 @@ function(setup_plugin_target target)
         FILES $<TARGET_PDB_FILE:${target}>
         CONFIGURATIONS "RelWithDebInfo" "Debug"
         DESTINATION $ENV{OBS_InstallerTempDir}/${OBS_PLUGIN_DESTINATION}
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
         OPTIONAL EXCLUDE_FROM_ALL)
     endif()
   endif()
@@ -98,7 +98,7 @@ function(setup_script_plugin_target target)
       FILES $<TARGET_PDB_FILE:${target}>
       CONFIGURATIONS "RelWithDebInfo" "Debug"
       DESTINATION ${OBS_SCRIPT_PLUGIN_DESTINATION}
-      COMPONENT obs_rundir
+      COMPONENT obs_${target}
       OPTIONAL EXCLUDE_FROM_ALL)
   endif()
 
@@ -107,10 +107,10 @@ function(setup_script_plugin_target target)
       TARGETS ${target}
       RUNTIME
         DESTINATION $ENV{OBS_InstallerTempDir}/${OBS_SCRIPT_PLUGIN_DESTINATION}
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
       LIBRARY
         DESTINATION $ENV{OBS_InstallerTempDir}/${OBS_SCRIPT_PLUGIN_DESTINATION}
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
         EXCLUDE_FROM_ALL)
 
     if(MSVC)
@@ -118,7 +118,7 @@ function(setup_script_plugin_target target)
         FILES $<TARGET_PDB_FILE:${target}>
         CONFIGURATIONS "RelWithDebInfo" "Debug"
         DESTINATION $ENV{OBS_InstallerTempDir}/${OBS_SCRIPT_PLUGIN_DESTINATION}
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
         OPTIONAL EXCLUDE_FROM_ALL)
     endif()
 
@@ -127,7 +127,7 @@ function(setup_script_plugin_target target)
         FILES
           "$<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.py"
         DESTINATION $ENV{OBS_InstallerTempDir}/${OBS_SCRIPT_PLUGIN_DESTINATION}
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
         EXCLUDE_FROM_ALL)
     endif()
   endif()
@@ -145,7 +145,7 @@ function(setup_target_resources target destination)
         DESTINATION
           $ENV{OBS_InstallerTempDir}/${OBS_DATA_DESTINATION}/${destination}
         USE_SOURCE_PERMISSIONS
-        COMPONENT obs_rundir
+        COMPONENT obs_${target}
         EXCLUDE_FROM_ALL)
     endif()
   endif()
@@ -160,7 +160,7 @@ function(add_target_resource target resource destination)
       FILES ${resource}
       DESTINATION
         $ENV{OBS_InstallerTempDir}/${OBS_DATA_DESTINATION}/${destination}
-      COMPONENT obs_rundir
+      COMPONENT obs_${target}
       EXCLUDE_FROM_ALL)
   endif()
 endfunction()

+ 11 - 7
cmake/Modules/ObsHelpers_macOS.cmake

@@ -222,7 +222,7 @@ function(setup_target_browser target)
         EXCLUDE_FROM_ALL)
 
       set(_COMMAND
-          "/usr/bin/codesign --force --sign \\\"${OBS_BUNDLE_CODESIGN_IDENTITY}\\\" $<$<BOOL:${OBS_CODESIGN_LINKER}>:--options linker-signed > \\\"\${CMAKE_INSTALL_PREFIX}/Frameworks/$<TARGET_FILE_NAME:OBS::browser-helper${_SUFFIX}>.app\\\""
+          "/usr/bin/codesign --force --sign \\\"${OBS_BUNDLE_CODESIGN_IDENTITY}\\\" $<$<BOOL:${OBS_CODESIGN_LINKER}>:--options linker-signed > \\\"\${CMAKE_INSTALL_PREFIX}/Frameworks/$<TARGET_FILE_NAME:OBS::browser-helper${_SUFFIX}>.app\\\" > /dev/null"
       )
 
       install(
@@ -235,8 +235,10 @@ function(setup_target_browser target)
   add_custom_command(
     TARGET ${target}
     POST_BUILD
-    COMMAND "${CMAKE_COMMAND}" --install . --config $<CONFIG> --prefix
-            $<TARGET_BUNDLE_CONTENT_DIR:${target}> --component obs_browser_dev
+    COMMAND
+      "${CMAKE_COMMAND}" --install . --config $<CONFIG> --prefix
+      $<TARGET_BUNDLE_CONTENT_DIR:${target}> --component obs_browser_dev >
+      /dev/null
     COMMENT "Installing Chromium Embedded Framework for development"
     VERBATIM)
 endfunction()
@@ -295,7 +297,7 @@ function(setup_obs_modules target)
       EXCLUDE_FROM_ALL)
 
     set(_COMMAND
-        "/usr/bin/codesign --force --sign \\\"${OBS_BUNDLE_CODESIGN_IDENTITY}\\\" $<$<BOOL:${OBS_CODESIGN_LINKER}>:--options linker-signed > \\\"\${CMAKE_INSTALL_PREFIX}/PlugIns/obspython.py\\\""
+        "/usr/bin/codesign --force --sign \\\"${OBS_BUNDLE_CODESIGN_IDENTITY}\\\" $<$<BOOL:${OBS_CODESIGN_LINKER}>:--options linker-signed > \\\"\${CMAKE_INSTALL_PREFIX}/PlugIns/obspython.py\\\" > /dev/null"
     )
 
     install(
@@ -318,7 +320,7 @@ function(setup_obs_modules target)
               EXCLUDE_FROM_ALL)
 
     set(_COMMAND
-        "/usr/bin/codesign --force --sign \\\"${OBS_BUNDLE_CODESIGN_IDENTITY}\\\" $<$<BOOL:${OBS_CODESIGN_LINKER}>:--options linker-signed > \\\"\${CMAKE_INSTALL_PREFIX}/MacOS/$<TARGET_FILE_NAME:obs-ffmpeg-mux>\\\""
+        "/usr/bin/codesign --force --sign \\\"${OBS_BUNDLE_CODESIGN_IDENTITY}\\\" $<$<BOOL:${OBS_CODESIGN_LINKER}>:--options linker-signed > \\\"\${CMAKE_INSTALL_PREFIX}/MacOS/$<TARGET_FILE_NAME:obs-ffmpeg-mux>\\\" > /dev/null"
     )
 
     install(
@@ -344,8 +346,10 @@ function(setup_obs_modules target)
   add_custom_command(
     TARGET ${target}
     POST_BUILD
-    COMMAND "${CMAKE_COMMAND}" --install .. --config $<CONFIG> --prefix
-            $<TARGET_BUNDLE_CONTENT_DIR:${target}> --component obs_plugin_dev
+    COMMAND
+      "${CMAKE_COMMAND}" --install .. --config $<CONFIG> --prefix
+      $<TARGET_BUNDLE_CONTENT_DIR:${target}> --component obs_plugin_dev >
+      /dev/null
     COMMENT "Installing OBS plugins for development"
     VERBATIM)
 endfunction()