From cd4a3a1dc7b502b15d3483cbf81ce0bdd478b2df Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 30 Aug 2022 17:46:51 +0200 Subject: [PATCH] CMake: Fix tst_qlibrary to work on macOS with debug builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test expects the helper libraries to contain the .dylib suffix rather than .so. Replace glob copying of the libraries (which depends on the underlying shell) with manual copy calls. This also ensures the libraries don't contain a _debug postfix in the file name even in a debug build, which would break the tests. Amends f8c1909320313c8a9c03661d8fe77728bde6556a Amends 1dff26dd9539feb40767b7761c5339085ad74dbf Change-Id: I20361c33c4a1b9dd4b5273fcdb8cc79c9f266327 Reviewed-by: Jörg Bornemann --- .../plugin/qlibrary/lib/CMakeLists.txt | 38 +++++++++---------- .../plugin/qlibrary/lib2/CMakeLists.txt | 24 +++++++++++- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt index e2505f60ab..b3e17aea2c 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt +++ b/tests/auto/corelib/plugin/qlibrary/lib/CMakeLists.txt @@ -30,27 +30,27 @@ 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) - if (NOT ANDROID) +if(UNIX) + if(APPLE) add_custom_command(TARGET mylib POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1.0.0" + $ + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.1.0.0.dylib" COMMAND ${CMAKE_COMMAND} -E create_symlink - "libmylib.so.1.0.0" - "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1" + "libmylib.1.0.0.dylib" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.1.dylib" + VERBATIM) + elseif(NOT ANDROID) + 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 - "libmylib.so.1.0.0" - "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so1" + "libmylib.so.1.0.0" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so.1" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "libmylib.so.1.0.0" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so1" VERBATIM) else() # Android does not use symlinks. Also, according to our conventions, @@ -64,10 +64,10 @@ elseif (UNIX) endif() else() #Win32 add_custom_command(TARGET mylib POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ "${CMAKE_CURRENT_BINARY_DIR}/../mylib.dll" - VERBATIM) + VERBATIM) endif() # special case end diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt b/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt index f03b3d5268..cb9ce49239 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt +++ b/tests/auto/corelib/plugin/qlibrary/lib2/CMakeLists.txt @@ -42,8 +42,28 @@ if(WIN32) set_property(TARGET mylib2 PROPERTY PREFIX "") endif() -if (UNIX) - if(NOT ANDROID) +if(UNIX) + if(APPLE) + add_custom_command(TARGET mylib2 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + "${CMAKE_CURRENT_BINARY_DIR}/../system.qt.test.mylib.so.dylib" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.2.0.0.dylib" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "libmylib.2.0.0.dylib" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.2.dylib" + COMMAND ${CMAKE_COMMAND} -E remove + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.dylib" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "libmylib.2.0.0.dylib" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.dylib" + COMMAND ${CMAKE_COMMAND} -E create_symlink + "libmylib.2.0.0.dylib" + "${CMAKE_CURRENT_BINARY_DIR}/../libmylib.so2.dylib" + VERBATIM) + elseif(NOT ANDROID) add_custom_command(TARGET mylib2 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $