From be6c48e2daf8b7cd73255a496a00bfa27f3bfe1e Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Mon, 23 Nov 2020 14:37:22 +0100 Subject: [PATCH] Fix tst_qlibrary after rebuild tst_qlibrary depends on a library (targets mylib and mylib2) to be built. They create a library with the same name, in two versions. This is done in order to test versioned library loading. However, those two libraries were fighting over the creation of "libmylib.so". In a fresh build, mylib2 wins, as intended. But after a rebuild, mylib won, which led to failing unit tests. This patch changes the situation. With this change, mylib no longer tries to create "libmylib.so". Thus no fighting and no problem. Change-Id: Id89baa5503c9f078a8737ff0b8616edf09044f72 Reviewed-by: Qt CI Bot Reviewed-by: Joerg Bornemann (cherry picked from commit 1dff26dd9539feb40767b7761c5339085ad74dbf) Reviewed-by: Qt Cherry-pick Bot --- .../plugin/qlibrary/lib/CMakeLists.txt | 31 ++++++++++++++++++- .../plugin/qlibrary/lib2/CMakeLists.txt | 1 - 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt index 4b2e01d9975..6bdd30ab177 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt +++ b/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt @@ -7,7 +7,7 @@ qt_internal_add_cmake_library(mylib SHARED INSTALL_DIRECTORY "${INSTALL_TESTSDIR}/tst_qlibrary" - OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../" + #OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../" # special case SOURCES mylib.c PUBLIC_LIBRARIES @@ -27,6 +27,35 @@ if(WIN32) set_property(TARGET mylib PROPERTY PREFIX "") endif() + +if (MACOS) + add_custom_command(TARGET mylib POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + "${CMAKE_CURRENT_BINARY_DIR}/../" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_CURRENT_BINARY_DIR}/*dylib" + "${CMAKE_CURRENT_BINARY_DIR}/../" + ) +elseif (UNIX) + add_custom_command(TARGET mylib POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1.0.0" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1.0.0" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1.0.0" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so1" + ) +else() #Win32 + add_custom_command(TARGET mylib POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + "${CMAKE_CURRENT_BINARY_DIR}/../mylib.dll" + ) +endif() # special case end #### Keys ignored in scope 1:.:.:lib.pro:: diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt index f92cec8fb1e..e98b4ffa4c4 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt +++ b/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt @@ -40,7 +40,6 @@ if(WIN32) endif() if (UNIX) - add_dependencies(mylib2 mylib) add_custom_command(TARGET mylib2 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $