[test-suite] r263235 - [test-suite] Append LDFLAGS to LINK_LIBRARIES

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 05:53:49 PST 2016


Author: mcrosier
Date: Fri Mar 11 07:53:49 2016
New Revision: 263235

URL: http://llvm.org/viewvc/llvm-project?rev=263235&view=rev
Log:
[test-suite] Append LDFLAGS to LINK_LIBRARIES

r261397 changed how LDFLAGS were added to the target under cmake from
using target_link_libraries to using a function to call
append_target_flags to append LDFLAGS to LINK_FLAGS because
target_link_libraries ignores flags that do not begin with -; however,
LINK_FLAGS are appended before the object files on the link line, so
this causes linking statically to fail.

This patches changes the append_compile_flags macro to append LDFLAGS to
LINK_LIBRARIES instead of LINK_FLAGS, as LINK_LIBRARIES is appended
after the object files. In addition, it modifies the append_target_flags
macro to strip whitespace before setting the destination variable, as
having any whitespace before or after LINK_LIBRARIES violates CMP0004.

Modified:
    test-suite/trunk/cmake/modules/SingleMultiSource.cmake

Modified: test-suite/trunk/cmake/modules/SingleMultiSource.cmake
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/SingleMultiSource.cmake?rev=263235&r1=263234&r2=263235&view=diff
==============================================================================
--- test-suite/trunk/cmake/modules/SingleMultiSource.cmake (original)
+++ test-suite/trunk/cmake/modules/SingleMultiSource.cmake Fri Mar 11 07:53:49 2016
@@ -61,7 +61,11 @@ macro(append_target_flags propertyname t
     string(REPLACE " " "\\ " quoted "${ARGN}")
     string(REPLACE "\"" "\\\"" quoted "${quoted}")
     string(REPLACE ";" " " quoted "${quoted}")
-    set_target_properties(${target} PROPERTIES ${propertyname} "${old_flags} ${quoted}")
+    # Ensure that there is no leading or trailing whitespace
+    # This is especially important if old_flags is empty and the property
+    # is LINK_LIBRARIES, as extra whitespace violates CMP0004
+    string(STRIP "${old_flags} ${quoted}" new_flags)
+    set_target_properties(${target} PROPERTIES ${propertyname} "${new_flags}")
   endif()
 endmacro()
 
@@ -70,7 +74,7 @@ macro(append_compile_flags target)
 endmacro()
 
 macro(append_link_flags target)
-  append_target_flags(LINK_FLAGS ${target} ${ARGN})
+  append_target_flags(LINK_LIBRARIES ${target} ${ARGN})
 endmacro()
 
 # llvm_add_test - Create a .test driver file suitable for LIT.




More information about the llvm-commits mailing list