Add VERBATIM option to add_custom_command calls

Use VERBATIM option to prepare the correct command line for the
add_custom_command. This especially sensitive when using build
directories with names containing special symbols, that cannot be
handled by shell correctly.

Change-Id: I51d7041cb806411135fd59bf6273c04a3c695443
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2022-03-15 17:37:11 +01:00
parent 74bef86da8
commit 8adacba3e6
12 changed files with 20 additions and 10 deletions

View File

@ -37,7 +37,7 @@ function(qt_internal_add_linker_version_script target)
BYPRODUCTS "${outfile}" DEPENDS "${infile}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Generating version linker script"
)
VERBATIM)
target_link_options("${target}" PRIVATE "-Wl,--version-script,${outfile}")
endif()
endfunction()

View File

@ -86,7 +86,8 @@ function(qt_copy_framework_headers target)
OUTPUT ${out_file_path}
DEPENDS ${in_file_path}
COMMAND ${CMAKE_COMMAND} -E make_directory "${fw_output_header_dir}"
COMMAND ${CMAKE_COMMAND} -E copy "${in_file_path}" "${fw_output_header_dir}")
COMMAND ${CMAKE_COMMAND} -E copy "${in_file_path}" "${fw_output_header_dir}"
VERBATIM)
list(APPEND out_files ${out_file_path})
endforeach()

View File

@ -57,6 +57,7 @@ function(qt_process_qlalr consuming_target input_file_list flags)
COMMAND ${QT_CMAKE_EXPORT_NAMESPACE}::qlalr ${flags} ${relative_input_file}
DEPENDS ${QT_CMAKE_EXPORT_NAMESPACE}::qlalr
MAIN_DEPENDENCY ${input_file}
VERBATIM
)
target_sources(${consuming_target} PRIVATE ${cpp_file} ${impl_file})
endforeach()

View File

@ -115,5 +115,5 @@ function(qt_enable_separate_debug_info target installDestination)
TARGET ${target}
POST_BUILD
${commands}
)
VERBATIM)
endfunction()

View File

@ -7,4 +7,5 @@ add_custom_command(
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug $<TARGET_FILE:objcopytest> objcopytest.debug
COMMAND ${CMAKE_OBJCOPY} --strip-debug $<TARGET_FILE:objcopytest>
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=objcopytest.debug $<TARGET_FILE:objcopytest>)
COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=objcopytest.debug $<TARGET_FILE:objcopytest>
VERBATIM)

View File

@ -1182,6 +1182,7 @@ if(QT_FEATURE_mimetype AND QT_FEATURE_mimetype_database)
DEPENDS ${command_depends}
COMMAND ${command_args}
COMMENT "Generating ${qmimeprovider_db_output}"
VERBATIM
)
else()
if(QT_FEATURE_zstd)

View File

@ -424,6 +424,7 @@ function(qt6_android_add_apk_target target)
COMMENT "Creating APK for ${target}"
DEPENDS "${target}" "${deployment_file}" ${extra_deps}
DEPFILE "${dep_file_path}"
VERBATIM
)
cmake_policy(POP)
@ -491,6 +492,7 @@ function(qt6_android_add_apk_target target)
--builddir "${CMAKE_BINARY_DIR}"
COMMENT "Resolving ${CMAKE_ANDROID_ARCH_ABI} dependencies for the ${target} APK"
DEPFILE "${dep_file}"
VERBATIM
)
add_custom_target(qt_internal_${target}_copy_apk_dependencies
DEPENDS "${timestamp_file}")

View File

@ -1243,6 +1243,7 @@ function(qt6_extract_metatypes target)
${multi_config_args}
COMMENT "Running AUTOMOC file extraction for target ${target}"
COMMAND_EXPAND_LISTS
VERBATIM
)
endif()
@ -1304,6 +1305,7 @@ function(qt6_extract_metatypes target)
${metatypes_file_gen}
${metatypes_file}
COMMENT "Running moc --collect-json for target ${target}"
VERBATIM
)
# We can't rely on policy CMP0118 since user project controls it
@ -1612,6 +1614,7 @@ END
add_custom_command(OUTPUT "${output}"
DEPENDS "${input}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${input}" "${output}"
VERBATIM
)
# We can't rely on policy CMP0118 since user project controls it
set_source_files_properties(${output} ${scope_args} PROPERTIES

View File

@ -931,6 +931,7 @@ add_custom_command(
OUTPUT ${vulkan_fun_outputs}
${vulkan_fun_command_content}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
VERBATIM
)
# special case end

View File

@ -35,8 +35,7 @@ if (MACOS)
"${CMAKE_CURRENT_BINARY_DIR}/../"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_BINARY_DIR}/*dylib"
"${CMAKE_CURRENT_BINARY_DIR}/../"
)
"${CMAKE_CURRENT_BINARY_DIR}/../")
elseif (UNIX)
add_custom_command(TARGET mylib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
@ -48,13 +47,13 @@ elseif (UNIX)
COMMAND ${CMAKE_COMMAND} -E create_symlink
"libmylib.so.1.0.0"
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so1"
)
VERBATIM)
else() #Win32
add_custom_command(TARGET mylib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:mylib>
"${CMAKE_CURRENT_BINARY_DIR}/../mylib.dll"
)
VERBATIM)
endif()
# special case end

View File

@ -58,7 +58,7 @@ if (UNIX)
COMMAND ${CMAKE_COMMAND} -E create_symlink
"libmylib.so.2.0.0"
"${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so2"
)
VERBATIM)
else() #Win32
add_custom_command(TARGET mylib2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
@ -67,7 +67,7 @@ else() #Win32
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:mylib2>
"${CMAKE_CURRENT_BINARY_DIR}/../mylib.dl2"
)
VERBATIM)
endif()
# special case end

View File

@ -142,6 +142,7 @@ add_custom_command(TARGET tst_moc
-o "allmocs.json"
--collect-json "@${moc_json_out}"
COMMENT "Running moc with --collect-json"
VERBATIM
)
# Add dependencies that are implicitly used inside the test