1 # Copy required additional files from 3rdparty to the binary folder
2 set(DEPLOY_FILES CACHE INTERNAL "List of files to deploy before running")
4 if (OPTION_ENGINE OR OPTION_SANDBOX OR OPTION_SHADERCACHEGEN)
5 set (BinaryFileList_Win64
6 "${WINDOWS_SDK}/Debuggers/x64/srcsrv/dbghelp.dll"
7 "${WINDOWS_SDK}/Debuggers/x64/srcsrv/dbgcore.dll"
8 "${WINDOWS_SDK}/bin/x64/d3dcompiler_47.dll"
11 set (BinaryFileList_Win32
12 "${WINDOWS_SDK}/Debuggers/x86/srcsrv/dbghelp.dll"
13 "${WINDOWS_SDK}/Debuggers/x86/srcsrv/dbgcore.dll"
14 "${WINDOWS_SDK}/bin/x86/d3dcompiler_47.dll"
17 if(EXISTS "${SDK_DIR}/AMD/AGS Lib")
18 set (BinaryFileList_Win64 ${BinaryFileList_Win64}
19 "${SDK_DIR}/AMD/AGS Lib/lib/amd_ags_x64.dll"
22 set (BinaryFileList_Win32 ${BinaryFileList_Win32}
23 "${SDK_DIR}/AMD/AGS Lib/lib/amd_ags_x86.dll"
28 file(TO_CMAKE_PATH "${DURANGO_SDK}" DURANGO_SDK_CMAKE)
29 set (BinaryFileList_Durango
30 "${DURANGO_SDK_CMAKE}/xdk/symbols/d3dcompiler_47.dll"
34 set (BinaryFileList_LINUX64
35 ${SDK_DIR}/ncurses/lib/libncursesw.so.6
39 macro(add_optional_runtime_files)
41 if (OPTION_ENABLE_BROFILER)
42 set (BinaryFileList_Win64 ${BinaryFileList_Win64} "${SDK_DIR}/Brofiler/ProfilerCore64.dll")
45 if(OPTION_ENABLE_CRASHRPT)
46 set (BinaryFileList_Win64 ${BinaryFileList_Win64} "${SDK_DIR}/CrashRpt/1403/bin/x64/crashrpt_lang.ini")
47 set (BinaryFileList_Win64 ${BinaryFileList_Win64} "${SDK_DIR}/CrashRpt/1403/bin/x64/CrashSender1403.exe")
48 set (BinaryFileList_Win32 ${BinaryFileList_Win32} "${SDK_DIR}/CrashRpt/1403/bin/x86/crashrpt_lang.ini")
49 set (BinaryFileList_Win32 ${BinaryFileList_Win32} "${SDK_DIR}/CrashRpt/1403/bin/x86/CrashSender1403.exe")
52 if (PLUGIN_VR_OCULUS OR AUDIO_OCULUS_HRTF)
53 set (BinaryFileList_Win64 ${BinaryFileList_Win64} "${SDK_DIR}/audio/oculus/wwise/x64/bin/plugins/OculusSpatializerWwise.dll")
54 set (BinaryFileList_Win32 ${BinaryFileList_Win32} "${SDK_DIR}/audio/oculus/wwise/Win32/bin/plugins/OculusSpatializerWwise.dll")
58 set (BinaryFileList_Win64 ${BinaryFileList_Win64} "${SDK_DIR}/audio/cryspatial/x64/CrySpatial.dll")
59 set (BinaryFileList_Durango ${BinaryFileList_Durango} "${SDK_DIR}/audio/cryspatial/xboxone/CrySpatial.dll")
63 set (BinaryFileList_Win64 ${BinaryFileList_Win64} "${SDK_DIR}/audio/cryspatial/x64/CrySpatial.dll")
64 set (BinaryFileList_Durango ${BinaryFileList_Durango} "${SDK_DIR}/audio/cryspatial/xboxone/CrySpatial.dll")
68 set (BinaryFileList_Win64 ${BinaryFileList_Win64} "${SDK_DIR}/OpenVR/bin/win64/*.*")
72 set (BinaryFileList_Win64 ${BinaryFileList_Win64} "${SDK_DIR}/OSVR/dll/*.dll")
77 macro(deploy_runtime_file source)
79 deploy_runtime_file_impl(${source} ${ARGV1})
82 get_filename_component(FILE_NAME "${source}" NAME)
83 # Ensure remainders of a generator expression get removed
84 string(REPLACE ">" "" FILE_NAME "${FILE_NAME}")
85 deploy_runtime_file_impl(${source} "${base_outdir}/${FILE_NAME}")
89 macro(deploy_runtime_file_impl source destination)
91 # HACK: This works on the assumption that any individual file is only used by *one* configuration, or *all* configurations. CMake will generate errors otherwise.
92 list(APPEND DEPLOY_FILES "$<$<CONFIG:${USE_CONFIG}>:${source}>")
93 list(APPEND DEPLOY_FILES "${source}")
94 list(APPEND DEPLOY_FILES "${destination}")
96 list(APPEND DEPLOY_FILES "${source}")
97 list(APPEND DEPLOY_FILES "${source}")
98 list(APPEND DEPLOY_FILES "${destination}")
100 set(DEPLOY_FILES "${DEPLOY_FILES}" CACHE INTERNAL "List of files to deploy before running")
103 macro(set_base_outdir)
104 set(base_outdir ${BASE_OUTPUT_DIRECTORY})
105 if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio")
106 string( TOUPPER ${CMAKE_BUILD_TYPE} BUILD_CONFIG )
107 set(base_outdir ${BASE_OUTPUT_DIRECTORY_${BUILD_CONFIG}})
109 if(OUTPUT_DIRECTORY_SUFFIX)
110 set(base_outdir "${base_outdir}_${OUTPUT_DIRECTORY_SUFFIX}")
112 if(OPTION_DEDICATED_SERVER)
113 set(base_outdir "${base_outdir}_dedicated")
117 macro(deploy_runtime_files fileexpr)
118 file(GLOB FILES_TO_COPY "${fileexpr}")
119 foreach(FILE_PATH ${FILES_TO_COPY})
120 get_filename_component(FILE_NAME "${FILE_PATH}" NAME)
123 # If another argument was passed files are deployed to the subdirectory
124 if (${ARGC} GREATER 1)
125 deploy_runtime_file("${FILE_PATH}" "${base_outdir}/${ARGV1}/${FILE_NAME}")
126 install(FILES "${FILE_PATH}" DESTINATION "bin/${ARGV1}")
128 deploy_runtime_file("${FILE_PATH}" "${base_outdir}/${FILE_NAME}")
129 install(FILES "${FILE_PATH}" DESTINATION bin)
130 if ((NOT USE_CONFIG) AND (${CMAKE_GENERATOR} MATCHES "Visual Studio") AND (NOT source MATCHES "<"))
131 # Make sure we also deploy to release directory for Visual Studio
132 set(outdir_temp ${BASE_OUTPUT_DIRECTORY})
133 set(BASE_OUTPUT_DIRECTORY ${BASE_OUTPUT_DIRECTORY_RELEASE})
135 deploy_runtime_file("${FILE_PATH}" "${base_outdir}/${FILE_NAME}")
136 set(BASE_OUTPUT_DIRECTORY ${outdir_temp})
142 macro(deploy_runtime_dir dir output_dir)
143 file(GLOB_RECURSE FILES_TO_COPY RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/${dir}" "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*")
146 foreach(FILE_NAME ${FILES_TO_COPY})
147 set(FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${FILE_NAME}")
149 deploy_runtime_file("${FILE_PATH}" "${base_outdir}/${output_dir}/${FILE_NAME}")
152 install(DIRECTORY "${dir}" DESTINATION "bin/${output_dir}")
155 macro(deploy_pyside_files)
157 foreach(FILE_NAME ${PYSIDE_DLLS})
158 get_filename_component (name_without_extension "${FILE_NAME}" NAME_WE)
159 set(PDB_NAME "${name_without_extension}.pdb")
160 set(FILE_PATH "${PYSIDE_SOURCE}${FILE_NAME}")
161 set(PDB_PATH "${PYSIDE_SOURCE}${PDB_NAME}")
162 deploy_runtime_file("${FILE_PATH}" "${base_outdir}/${FILE_NAME}")
163 install(FILES "${FILE_PATH}" DESTINATION bin)
164 if(EXISTS "${PDB_PATH}")
165 deploy_runtime_file("${PDB_PATH}" "${base_outdir}/${PDB_NAME}")
166 install(FILES "${PDB_PATH}" DESTINATION bin)
170 foreach(FILE_NAME ${FILES_TO_COPY})
171 get_filename_component (name_without_extension "${FILE_NAME}" NAME_WE)
172 get_filename_component (dirname "${FILE_NAME}" DIRECTORY)
173 set(PDB_NAME "${dirname}${name_without_extension}.pdb")
174 set(FILE_PATH "${PYSIDE_SOURCE}${FILE_NAME}")
175 set(PDB_PATH "${PYSIDE_SOURCE}${PDB_NAME}")
176 deploy_runtime_file("${FILE_PATH}" "${base_outdir}/PySide2/${FILE_NAME}")
177 install(FILES "${FILE_PATH}" DESTINATION bin/PySide2)
178 if(EXISTS "${PDB_PATH}")
179 deploy_runtime_file("${PDB_PATH}" "${base_outdir}/PySide2/${PDB_NAME}")
180 install(FILES "${PDB_PATH}" DESTINATION bin/PySide2)
186 set(PYSIDE_SDK_SOURCE "${QT_DEPLOY_ROOT}/PySide/")
187 set(PYSIDE_SOURCE "${PYSIDE_SDK_SOURCE}PySide2/")
190 set(USE_CONFIG Profile)
192 set(PYSIDE_DLLS "pyside2.cp37-win_amd64.dll" "shiboken2.cp37-win_amd64.dll")
193 file(GLOB FILES_TO_COPY RELATIVE "${PYSIDE_SOURCE}" "${PYSIDE_SOURCE}*[^_][^d].pyd")
194 deploy_pyside_files()
197 file(GLOB FILES_TO_COPY RELATIVE "${PYSIDE_SOURCE}" "${PYSIDE_SOURCE}*.py" "${PYSIDE_SOURCE}scripts/*.py")
198 deploy_pyside_files()
200 deploy_runtime_dir("${PYSIDE_SDK_SOURCE}pyside2uic" "pyside2uic")
204 macro(copy_binary_files_to_target)
205 if (DEFINED PROJECT_BUILD_CRYENGINE AND NOT PROJECT_BUILD_CRYENGINE)
206 # When engine is not to be Build do not deploy anything either
210 message( STATUS "copy_binary_files_to_target start ${BUILD_PLATFORM}" )
212 add_optional_runtime_files()
214 set( file_list_name "BinaryFileList_${BUILD_PLATFORM}" )
215 get_property( BINARY_FILE_LIST VARIABLE PROPERTY ${file_list_name} )
216 foreach(b ${BINARY_FILE_LIST})
217 deploy_runtime_files("${b}")
220 foreach(config IN ITEMS Debug Profile Release)
221 set( file_list_name "BinaryFileList_${BUILD_PLATFORM}_${config}" )
222 get_property( BINARY_FILE_LIST VARIABLE PROPERTY ${file_list_name} )
223 set(USE_CONFIG ${config})
224 foreach(b ${BINARY_FILE_LIST})
225 deploy_runtime_files("${b}")
231 deploy_runtime_files("${SDK_DIR}/Orbis/target/sce_module/*.prx" "app/sce_module")
236 if (MSVC_VERSION GREATER 1900) # Visual Studio > 2015
237 deploy_runtime_files("${SDK_DIR}/Microsoft Visual Studio Compiler/14.15.26726/Redist/MSVC/14.15.26706/x64/**/*.dll")
238 elseif (MSVC_VERSION EQUAL 1900) # Visual Studio 2015
239 deploy_runtime_files("${SDK_DIR}/Microsoft Visual Studio Compiler/14.0/redist/x64/**/*.dll")
243 # Qt: Debug && Profile will use the same win_x64 folder, for Release Qt will not be deployed. Empty second arg do the job.
244 # d3dcompiler_47.dll file from Qt bin should not be copied in output folder
245 deploy_runtime_files("${QT_DEPLOY_ROOT}/Qt/bin/[^d][^3]*.dll" "")
246 deploy_runtime_files("${QT_DEPLOY_ROOT}/Qt/bin/QtWebEngineProcess.exe" "")
247 deploy_runtime_files("${QT_DEPLOY_ROOT}/PySide/PySide2/qt.conf" "")
248 deploy_runtime_files("${QT_DEPLOY_ROOT}/PySide/PySide2/shiboken2.cp37-win_amd64.pyd" "")
249 file(COPY ${QT_DEPLOY_ROOT}/Qt/plugins DESTINATION ${base_outdir})
250 file(COPY ${QT_DEPLOY_ROOT}/Qt/resources DESTINATION ${base_outdir})
251 file(COPY ${QT_DEPLOY_ROOT}/Qt/translations/qtwebengine_locales/en-US.pak DESTINATION "${base_outdir}/translations/qtwebengine_locales")
253 deploy_runtime_files("${SDK_DIR}/XT_13_4/bin_vc14/*.dll" "")
254 deploy_runtime_files("${SDK_DIR}/XT_13_4/bin_vc14/*.pdb" "")
260 set(DEPLOY_DESTINATIONS)
262 list(LENGTH DEPLOY_FILES deployFilesCount)
263 math(EXPR idxRangeEnd "${deployFilesCount} - 1")
264 foreach(idx RANGE 0 ${idxRangeEnd} 3)
265 math(EXPR idxIncr "${idx} + 1")
266 math(EXPR idxIncr2 "${idx} + 2")
267 list(GET DEPLOY_FILES ${idx} source)
268 list(GET DEPLOY_FILES ${idxIncr} source_file)
269 list(GET DEPLOY_FILES ${idxIncr2} destination)
271 if(source MATCHES "<") # Source contains generator expression; deploy at build time
272 add_custom_command(OUTPUT ${destination}
273 COMMAND ${CMAKE_COMMAND} "-DSOURCE=\"${source}\"" "-DDESTINATION=\"${destination}\"" -P "${TOOLS_CMAKE_DIR}/deploy_runtime_files.cmake"
274 COMMENT "Deploying ${source_file}"
276 list(APPEND DEPLOY_DESTINATIONS "${destination}")
278 message(STATUS "Deploying ${source_file}")
279 get_filename_component(DEST_DIR "${destination}" DIRECTORY)
280 file(COPY "${source}" DESTINATION "${DEST_DIR}" NO_SOURCE_PERMISSIONS)
285 if (DEPLOY_DESTINATIONS)
286 add_custom_target(deployrt ALL DEPENDS ${DEPLOY_DESTINATIONS})
287 set_solution_folder("Deploy" deployrt)
290 message( STATUS "copy_binary_files_to_target end" )