#14584 Fix Windows build race copying Qt DLLs into the build root

extract-projectfile-versions linked into the shared build root and copied
Qt6Core.dll and Qt6Sql.dll next to its executable as a POST_BUILD step. The
generated_classes.py edge runs ResInsight.exe out of that same directory with
those DLLs loaded, and nothing orders the two edges relative to each other, so
Ninja was free to schedule them concurrently. Overwriting a mapped DLL is a
sharing violation on Windows, which failed the copy and took the build down.

Give the target its own RUNTIME_OUTPUT_DIRECTORY. It is a standalone developer
tool with no reason to share the application output directory, so moving it
removes the conflict instead of narrowing it. Also switch the copy to
copy_if_different, matching the equivalent step in the unit test target.
This commit is contained in:
Magne Sjaastad committed 2026-08-22 11:50:55 +02:00
1 parent e9b60d7167
commit f68c0fe2cb
1 file changed
+15 -2
+15 -2
View File
@@ -13,12 +13,25 @@ add_executable(extract-projectfile-versions main.cpp)
target_link_libraries(extract-projectfile-versions Qt6::Core Qt6::Sql)
# This standalone developer tool must not share the output directory with the
# application. The POST_BUILD step below copies Qt6Core.dll and Qt6Sql.dll next
# to the executable, and the build root has ResInsight.exe running out of it
# during Python code generation with those same DLLs loaded. Overwriting a
# mapped DLL is a sharing violation on Windows, and nothing orders the two build
# edges relative to each other.
set_target_properties(
extract-projectfile-versions
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
if(MSVC)
add_custom_command(
TARGET extract-projectfile-versions
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:extract-projectfile-versions>
$<TARGET_FILE_DIR:extract-projectfile-versions>
COMMAND
${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:extract-projectfile-versions>
$<TARGET_FILE_DIR:extract-projectfile-versions>
COMMAND_EXPAND_LISTS
)
endif(MSVC)