CopyMSVCBins.cmake 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. # Doesn't realy make sense anywhere else
  2. if(NOT MSVC)
  3. return()
  4. endif()
  5. # Internal variable to avoid copying more than once
  6. if(COPIED_DEPENDENCIES)
  7. return()
  8. endif()
  9. option(COPY_DEPENDENCIES "Automaticaly try copying all dependencies" OFF)
  10. if(NOT COPY_DEPENDENCIES)
  11. return()
  12. endif()
  13. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  14. set(_bin_suffix 64)
  15. else()
  16. set(_bin_suffix 32)
  17. endif()
  18. find_package(Libavcodec QUIET)
  19. find_package(Libx264 QUIET)
  20. find_package(Libfdk QUIET)
  21. find_package(Qt5Core QUIET)
  22. file(GLOB FFMPEG_BIN_FILES
  23. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin/avcodec-*.dll"
  24. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin${_bin_suffix}/avcodec-*.dll"
  25. "${FFMPEG_avcodec_INCLUDE_DIR}/bin${_bin_suffix}/avcodec-*.dll"
  26. "${FFMPEG_avformat_INCLUDE_DIR}/../bin/avformat-*.dll"
  27. "${FFMPEG_avformat_INCLUDE_DIR}/../bin${_bin_suffix}/avformat-*.dll"
  28. "${FFMPEG_avformat_INCLUDE_DIR}/bin${_bin_suffix}/avformat-*.dll"
  29. "${FFMPEG_avutil_INCLUDE_DIR}/../bin/avutil-*.dll"
  30. "${FFMPEG_avutil_INCLUDE_DIR}/../bin${_bin_suffix}/avutil-*.dll"
  31. "${FFMPEG_avutil_INCLUDE_DIR}/bin${_bin_suffix}/avutil-*.dll"
  32. "${FFMPEG_avdevice_INCLUDE_DIR}/../bin/avdevice-*.dll"
  33. "${FFMPEG_avdevice_INCLUDE_DIR}/../bin${_bin_suffix}/avdevice-*.dll"
  34. "${FFMPEG_avdevice_INCLUDE_DIR}/bin${_bin_suffix}/avdevice-*.dll"
  35. "${FFMPEG_avfilter_INCLUDE_DIR}/../bin/avfilter-*.dll"
  36. "${FFMPEG_avfilter_INCLUDE_DIR}/../bin${_bin_suffix}/avfilter-*.dll"
  37. "${FFMPEG_avfilter_INCLUDE_DIR}/bin${_bin_suffix}/avfilter-*.dll"
  38. "${FFMPEG_postproc_INCLUDE_DIR}/../bin/postproc-*.dll"
  39. "${FFMPEG_postproc_INCLUDE_DIR}/../bin${_bin_suffix}/postproc-*.dll"
  40. "${FFMPEG_postproc_INCLUDE_DIR}/bin${_bin_suffix}/postproc-*.dll"
  41. "${FFMPEG_swscale_INCLUDE_DIR}/../bin/swscale-*.dll"
  42. "${FFMPEG_swscale_INCLUDE_DIR}/bin${_bin_suffix}/swscale-*.dll"
  43. "${FFMPEG_swscale_INCLUDE_DIR}/../bin${_bin_suffix}/swscale-*.dll"
  44. "${FFMPEG_swresample_INCLUDE_DIR}/../bin/swresample-*.dll"
  45. "${FFMPEG_swresample_INCLUDE_DIR}/../bin${_bin_suffix}/swresample-*.dll"
  46. "${FFMPEG_swresample_INCLUDE_DIR}/bin${_bin_suffix}/swresample-*.dll"
  47. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin/libopus*.dll"
  48. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin/opus*.dll"
  49. "${FFMPEG_avcodec_INCLUDE_DIR}/bin/libopus*.dll"
  50. "${FFMPEG_avcodec_INCLUDE_DIR}/bin/opus*.dll"
  51. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin${_bin_suffix}/libopus*.dll"
  52. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin${_bin_suffix}/opus*.dll"
  53. "${FFMPEG_avcodec_INCLUDE_DIR}/bin${_bin_suffix}/libopus*.dll"
  54. "${FFMPEG_avcodec_INCLUDE_DIR}/bin${_bin_suffix}/opus*.dll"
  55. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin/libbz2*.dll"
  56. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin/zlib*.dll"
  57. "${FFMPEG_avcodec_INCLUDE_DIR}/bin/libbz2*.dll"
  58. "${FFMPEG_avcodec_INCLUDE_DIR}/bin/zlib*.dll"
  59. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin${_bin_suffix}/libbz2*.dll"
  60. "${FFMPEG_avcodec_INCLUDE_DIR}/../bin${_bin_suffix}/zlib*.dll"
  61. "${FFMPEG_avcodec_INCLUDE_DIR}/bin${_bin_suffix}/libbz2*.dll"
  62. "${FFMPEG_avcodec_INCLUDE_DIR}/bin${_bin_suffix}/zlib*.dll"
  63. )
  64. file(GLOB X264_BIN_FILES
  65. "${X264_INCLUDE_DIR}/../bin${_bin_suffix}/libx264-*.dll"
  66. "${X264_INCLUDE_DIR}/../bin/libx264-*.dll"
  67. "${X264_INCLUDE_DIR}/bin/libx264-*.dll"
  68. "${X264_INCLUDE_DIR}/bin${_bin_suffix}/libx264-*.dll")
  69. file(GLOB FREETYPE_BIN_FILES
  70. "${FREETYPE_INCLUDE_DIR_ft2build}/../../bin${_bin_suffix}/libfreetype*-*.dll"
  71. "${FREETYPE_INCLUDE_DIR_ft2build}/../../bin/libfreetype*-*.dll"
  72. "${FREETYPE_INCLUDE_DIR_ft2build}/../bin${_bin_suffix}/libfreetype*-*.dll"
  73. "${FREETYPE_INCLUDE_DIR_ft2build}/../bin/libfreetype*-*.dll"
  74. "${FREETYPE_INCLUDE_DIR_ft2build}/bin/libfreetype*-*.dll"
  75. "${FREETYPE_INCLUDE_DIR_ft2build}/bin${_bin_suffix}/libfreetype*-*.dll")
  76. file(GLOB LIBFDK_BIN_FILES
  77. "${Libfdk_INCLUDE_DIR}/../bin${_bin_suffix}/libfdk*-*.dll"
  78. "${Libfdk_INCLUDE_DIR}/../bin/libfdk*-*.dll"
  79. "${Libfdk_INCLUDE_DIR}/bin/libfdk*-*.dll"
  80. "${Libfdk_INCLUDE_DIR}/bin${_bin_suffix}/libfdk*-*.dll")
  81. if (CMAKE_CONFIGURATION_TYPES MATCHES "Debug")
  82. file(GLOB QT_DEBUG_BIN_FILES
  83. "${Qt5Core_DIR}/../../../bin/Qt5Cored.dll"
  84. "${Qt5Core_DIR}/../../../bin/Qt5Guid.dll"
  85. "${Qt5Core_DIR}/../../../bin/Qt5Widgetsd.dll"
  86. "${Qt5Core_DIR}/../../../bin/Qt5Networkd.dll"
  87. "${Qt5Core_DIR}/../../../bin/libGLESv2d.dll"
  88. "${Qt5Core_DIR}/../../../bin/libEGLd.dll")
  89. file(GLOB QT_DEBUG_PLAT_BIN_FILES
  90. "${Qt5Core_DIR}/../../../plugins/platforms/qwindowsd.dll")
  91. endif()
  92. if (CMAKE_CONFIGURATION_TYPES MATCHES "Rel")
  93. file(GLOB QT_BIN_FILES
  94. "${Qt5Core_DIR}/../../../bin/Qt5Core.dll"
  95. "${Qt5Core_DIR}/../../../bin/Qt5Gui.dll"
  96. "${Qt5Core_DIR}/../../../bin/Qt5Widgets.dll"
  97. "${Qt5Core_DIR}/../../../bin/Qt5Network.dll"
  98. "${Qt5Core_DIR}/../../../bin/libGLESv2.dll"
  99. "${Qt5Core_DIR}/../../../bin/libEGL.dll")
  100. file(GLOB QT_PLAT_BIN_FILES
  101. "${Qt5Core_DIR}/../../../plugins/platforms/qwindows.dll")
  102. endif()
  103. file(GLOB QT_ICU_BIN_FILES
  104. "${Qt5Core_DIR}/../../../bin/icu*.dll")
  105. set(ALL_BASE_BIN_FILES
  106. ${FFMPEG_BIN_FILES}
  107. ${X264_BIN_FILES}
  108. ${LIBFDK_BIN_FILES}
  109. ${FREETYPE_BIN_FILES}
  110. ${QT_ICU_BIN_FILES})
  111. set(ALL_REL_BIN_FILES
  112. ${QT_BIN_FILES})
  113. set(ALL_DBG_BIN_FILES
  114. ${QT_DEBUG_BIN_FILES})
  115. set(ALL_PLATFORM_BIN_FILES)
  116. set(ALL_PLATFORM_REL_BIN_FILES
  117. ${QT_PLAT_BIN_FILES})
  118. set(ALL_PLATFORM_DBG_BIN_FILES
  119. ${QT_DEBUG_PLAT_BIN_FILES})
  120. foreach(list
  121. ALL_BASE_BIN_FILES ALL_REL_BIN_FILES ALL_DBG_BIN_FILES
  122. ALL_PLATFORM_BIN_FILES ALL_PLATFORM_REL_BIN_FILES ALL_PLATFORM_DBG_BIN_FILES)
  123. if(${list})
  124. list(REMOVE_DUPLICATES ${list})
  125. endif()
  126. endforeach()
  127. message(STATUS "FFmpeg files: ${FFMPEG_BIN_FILES}")
  128. message(STATUS "x264 files: ${X264_BIN_FILES}")
  129. message(STATUS "Libfdk files: ${LIBFDK_BIN_FILES}")
  130. message(STATUS "Freetype files: ${FREETYPE_BIN_FILES}")
  131. message(STATUS "QT Debug files: ${QT_DEBUG_BIN_FILES}")
  132. message(STATUS "QT Debug Platform files: ${QT_DEBUG_PLAT_BIN_FILES}")
  133. message(STATUS "QT Release files: ${QT_BIN_FILES}")
  134. message(STATUS "QT Release Platform files: ${QT_PLAT_BIN_FILES}")
  135. message(STATUS "QT ICU files: ${QT_ICU_BIN_FILES}")
  136. foreach(BinFile ${ALL_BASE_BIN_FILES})
  137. message(STATUS "copying ${BinFile} to ${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}")
  138. file(COPY "${BinFile}" DESTINATION "${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}/")
  139. endforeach()
  140. foreach(BinFile ${ALL_REL_BIN_FILES})
  141. message(STATUS "copying ${BinFile} to ${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}r")
  142. file(COPY "${BinFile}" DESTINATION "${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}r/")
  143. endforeach()
  144. foreach(BinFile ${ALL_DBG_BIN_FILES})
  145. message(STATUS "copying ${BinFile} to ${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}d")
  146. file(COPY "${BinFile}" DESTINATION "${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}d/")
  147. endforeach()
  148. foreach(BinFile ${ALL_PLATFORM_BIN_FILES})
  149. make_directory("${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}/platforms")
  150. file(COPY "${BinFile}" DESTINATION "${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}/platforms/")
  151. endforeach()
  152. foreach(BinFile ${ALL_PLATFORM_REL_BIN_FILES})
  153. make_directory("${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}r/platforms")
  154. file(COPY "${BinFile}" DESTINATION "${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}r/platforms/")
  155. endforeach()
  156. foreach(BinFile ${ALL_PLATFORM_DBG_BIN_FILES})
  157. make_directory("${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}d/platforms")
  158. file(COPY "${BinFile}" DESTINATION "${CMAKE_SOURCE_DIR}/additional_install_files/exec${_bin_suffix}d/platforms/")
  159. endforeach()
  160. set(COPIED_DEPENDENCIES TRUE CACHE BOOL "Dependencies have been copied, set to false to copy again" FORCE)