From 0f80b65a01fcb12ec44e337191273ecf4d7e12c1 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Tue, 30 Aug 2022 17:37:31 +1000 Subject: [PATCH] wasm: handle cmake's RUNTIME_OUTPUT_DIRECTORY Also OUTPUT_NAME Pick-to: 6.4 Fixes: QTBUG-105923 Change-Id: Iaef92b068845d69fad4f73abb7e15dcba3107265 Reviewed-by: Alexandru Croitor --- src/corelib/Qt6WasmMacros.cmake | 46 +++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/corelib/Qt6WasmMacros.cmake b/src/corelib/Qt6WasmMacros.cmake index 379229bc6a..ce96c4fbec 100644 --- a/src/corelib/Qt6WasmMacros.cmake +++ b/src/corelib/Qt6WasmMacros.cmake @@ -8,32 +8,46 @@ function(_qt_internal_wasm_add_target_helpers target) get_target_property(targetType "${target}" TYPE) if("${targetType}" STREQUAL "EXECUTABLE") - set(APPNAME ${target}) - if(QT6_INSTALL_PREFIX) set(WASM_BUILD_DIR "${QT6_INSTALL_PREFIX}") elseif(QT_BUILD_DIR) set(WASM_BUILD_DIR "${QT_BUILD_DIR}") endif() - _qt_internal_test_batch_target_name(test_batch_target_name) - if(QT_BUILD_TESTS_BATCHED AND target STREQUAL test_batch_target_name) - get_target_property(batch_output_dir ${target} RUNTIME_OUTPUT_DIRECTORY) - configure_file("${WASM_BUILD_DIR}/libexec/batchedtestrunner.html" - "${batch_output_dir}/batchedtestrunner.html" COPYONLY) - configure_file("${WASM_BUILD_DIR}/libexec/batchedtestrunner.js" - "${batch_output_dir}/batchedtestrunner.js" COPYONLY) - configure_file("${WASM_BUILD_DIR}/libexec/qwasmjsruntime.js" - "${batch_output_dir}/qwasmjsruntime.js" COPYONLY) - configure_file("${WASM_BUILD_DIR}/libexec/util.js" - "${batch_output_dir}/util.js" COPYONLY) + get_target_property(output_name ${target} OUTPUT_NAME) + if(NOT "${output_name}" STREQUAL "") + set(_target_output_name "${output_name}") else() + set(_target_output_name "${target}") + endif() + + set(APPNAME ${_target_output_name}) + + _qt_internal_test_batch_target_name(test_batch_target_name) + get_target_property(target_output_directory ${target} RUNTIME_OUTPUT_DIRECTORY) + + if(QT_BUILD_TESTS_BATCHED AND target STREQUAL test_batch_target_name) + configure_file("${WASM_BUILD_DIR}/libexec/batchedtestrunner.html" + "${target_output_directory}/batchedtestrunner.html" COPYONLY) + configure_file("${WASM_BUILD_DIR}/libexec/batchedtestrunner.js" + "${target_output_directory}/batchedtestrunner.js" COPYONLY) + configure_file("${WASM_BUILD_DIR}/libexec/qwasmjsruntime.js" + "${target_output_directory}/qwasmjsruntime.js" COPYONLY) + configure_file("${WASM_BUILD_DIR}/libexec/util.js" + "${target_output_directory}/util.js" COPYONLY) + else() + if(NOT "${target_output_directory}" STREQUAL "") + set(_target_directory "${target_output_directory}") + else() + set(_target_directory "${CMAKE_CURRENT_BINARY_DIR}") + endif() + configure_file("${WASM_BUILD_DIR}/plugins/platforms/wasm_shell.html" - "${target}.html") + "${_target_directory}/${_target_output_name}.html") configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtloader.js" - qtloader.js COPYONLY) + ${_target_directory}/qtloader.js COPYONLY) configure_file("${WASM_BUILD_DIR}/plugins/platforms/qtlogo.svg" - qtlogo.svg COPYONLY) + ${_target_directory}/qtlogo.svg COPYONLY) endif() if(QT_FEATURE_thread)