From e1b441631c31d8ab9269bd44d1a992af6424ccdd Mon Sep 17 00:00:00 2001
From: Slávek Banko <slavek.banko@axis.cz>
Date: Mon, 13 Jan 2025 22:03:57 +0100
Subject: Use CMake command create_symlink instead of calling ls -s, because it
 is resistant to repeated calls.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This solves FTBFS with CMake >= 3.11, because in the case of update
a library file, as a result of a tdelfeditor call, this will cause
repeated calls for targets that are dependent on the library.

As a result, it is now possible to use call based on POST_BUILD,
and there is no need to distinguish the way of calling created in
the commit e22f5ace4a1eae9b299a8b8c60ceb339c73a2e3c.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
---
 modules/TDEMacros.cmake | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index b0de2d0..fa1ad61 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -1263,22 +1263,12 @@ macro( tde_add_library _arg_target )
         get_target_property( _soversion ${_target} SOVERSION )
         set( _soname "${_soname}.${_soversion}" )
       endif( )
-      if( NOT _exclude_from_all )
-        add_custom_command(
-          OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_soname_base}"
-          COMMAND ln -s ${_soname} "${CMAKE_CURRENT_BINARY_DIR}/${_soname_base}"
-          DEPENDS ${_target}
-        )
-        add_custom_target(
-          ${_target}+base-so ALL
-          DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_soname_base}"
-        )
-      else( )
-        add_custom_command(
-          TARGET ${_target} POST_BUILD
-          COMMAND ln -s ${_soname} "${CMAKE_CURRENT_BINARY_DIR}/${_soname_base}"
-        )
-      endif( )
+      add_custom_command(
+        TARGET ${_target} POST_BUILD
+        COMMAND ${CMAKE_COMMAND} -E create_symlink
+          "${_soname}"
+          "${CMAKE_CURRENT_BINARY_DIR}/${_soname_base}"
+      )
       install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${_soname_base}" DESTINATION ${_destination} )
     endif( )
 
-- 
cgit v1.2.3

