[test-suite] r267243 - [test-suite] Added llvm_target_prefix() command to set unique target prefix.

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 11:53:22 PDT 2016


BTW: Maybe you should reconsider the use of cmake_policy(SET CMP0002 NEW) instead of the custom error message? Contrary to the custom error message it tells you which target is duplicate:

CMake Error at CMakeLists.txt:3 (add_executable):
  add_executable cannot create target "testtarget" because another target with the
  same name already exists.  The existing target is an executable created in
  source directory "/Users/mbraun".  See documentation for policy CMP0002 for
  more details.

- Matthias

> On Apr 25, 2016, at 11:50 AM, Artem Belevich via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> I assume you were configuring for an ARM variant.
> It appears that Vector and Vector/NEON both have files called simple.c and need to have unique prefix for their targets.
> 
> Fixed in r267439
> 
> --Artem
> 
> 
> 
> On Sat, Apr 23, 2016 at 2:15 PM, Chris Matthews <chris.matthews at apple.com <mailto:chris.matthews at apple.com>> wrote:
> After this commit the test suite fails cmake for me:
> 
> 
> CMake Error at cmake/modules/SingleMultiSource.cmake:45 (message):
>   Duplicate executable name!Please set unique prefix with
>   llvm_target_prefix().
> Call Stack (most recent call first):
>   cmake/modules/SingleMultiSource.cmake:136 (get_unique_exe_name)
>   cmake/modules/SingleMultiSource.cmake:175 (test_suite_add_executable)
>   SingleSource/UnitTests/Vector/CMakeLists.txt:21 (llvm_singlesource)
> 
> 
>> On Apr 22, 2016, at 3:53 PM, Artem Belevich via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
>> 
>> Author: tra
>> Date: Fri Apr 22 17:53:21 2016
>> New Revision: 267243
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=267243&view=rev <http://llvm.org/viewvc/llvm-project?rev=267243&view=rev>
>> Log:
>> [test-suite] Added llvm_target_prefix() command to set unique target prefix.
>> 
>> Differential Revision: http://reviews.llvm.org/D19423 <http://reviews.llvm.org/D19423>
>> 
>> Modified:
>>    test-suite/trunk/SingleSource/Benchmarks/Shootout-C++/CMakeLists.txt
>>    test-suite/trunk/SingleSource/Benchmarks/Shootout/CMakeLists.txt
>>    test-suite/trunk/SingleSource/Regression/C++/CMakeLists.txt
>>    test-suite/trunk/SingleSource/Regression/C/CMakeLists.txt
>>    test-suite/trunk/cmake/modules/SingleMultiSource.cmake
>> 
>> Modified: test-suite/trunk/SingleSource/Benchmarks/Shootout-C++/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/Shootout-C%2B%2B/CMakeLists.txt?rev=267243&r1=267242&r2=267243&view=diff <http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/Shootout-C%2B%2B/CMakeLists.txt?rev=267243&r1=267242&r2=267243&view=diff>
>> ==============================================================================
>> --- test-suite/trunk/SingleSource/Benchmarks/Shootout-C++/CMakeLists.txt (original)
>> +++ test-suite/trunk/SingleSource/Benchmarks/Shootout-C++/CMakeLists.txt Fri Apr 22 17:53:21 2016
>> @@ -1,3 +1,4 @@
>> +llvm_target_prefix("shootout-cxx")
>> list(APPEND CXXFLAGS -Wno-deprecated)
>> list(APPEND CPPFLAGS -Wno-deprecated)
>> set(FP_TOLERANCE 0.00000001)
>> 
>> Modified: test-suite/trunk/SingleSource/Benchmarks/Shootout/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/Shootout/CMakeLists.txt?rev=267243&r1=267242&r2=267243&view=diff <http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Benchmarks/Shootout/CMakeLists.txt?rev=267243&r1=267242&r2=267243&view=diff>
>> ==============================================================================
>> --- test-suite/trunk/SingleSource/Benchmarks/Shootout/CMakeLists.txt (original)
>> +++ test-suite/trunk/SingleSource/Benchmarks/Shootout/CMakeLists.txt Fri Apr 22 17:53:21 2016
>> @@ -1,3 +1,4 @@
>> +llvm_target_prefix("shootout")
>> list(APPEND LDFLAGS -lm)
>> if(ARCH STREQUAL "XCore")
>>   set(XCORE_TARGET_NEEDS_MEMORY 256)
>> 
>> Modified: test-suite/trunk/SingleSource/Regression/C++/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C%2B%2B/CMakeLists.txt?rev=267243&r1=267242&r2=267243&view=diff <http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C%2B%2B/CMakeLists.txt?rev=267243&r1=267242&r2=267243&view=diff>
>> ==============================================================================
>> --- test-suite/trunk/SingleSource/Regression/C++/CMakeLists.txt (original)
>> +++ test-suite/trunk/SingleSource/Regression/C++/CMakeLists.txt Fri Apr 22 17:53:21 2016
>> @@ -1,3 +1,4 @@
>> +llvm_target_prefix("regression-cxx")
>> list(APPEND LDFLAGS -lstdc++)
>> llvm_singlesource()
>> 
>> 
>> Modified: test-suite/trunk/SingleSource/Regression/C/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/CMakeLists.txt?rev=267243&r1=267242&r2=267243&view=diff <http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/CMakeLists.txt?rev=267243&r1=267242&r2=267243&view=diff>
>> ==============================================================================
>> --- test-suite/trunk/SingleSource/Regression/C/CMakeLists.txt (original)
>> +++ test-suite/trunk/SingleSource/Regression/C/CMakeLists.txt Fri Apr 22 17:53:21 2016
>> @@ -1,3 +1,4 @@
>> +llvm_target_prefix("regression-c")
>> if(ARCH STREQUAL "x86")
>>   if(DEFINED USE_REFERENCE_OUTPUT)
>>     set(EXEC_XFAILS casts)
>> 
>> Modified: test-suite/trunk/cmake/modules/SingleMultiSource.cmake
>> URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/SingleMultiSource.cmake?rev=267243&r1=267242&r2=267243&view=diff <http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/SingleMultiSource.cmake?rev=267243&r1=267242&r2=267243&view=diff>
>> ==============================================================================
>> --- test-suite/trunk/cmake/modules/SingleMultiSource.cmake (original)
>> +++ test-suite/trunk/cmake/modules/SingleMultiSource.cmake Fri Apr 22 17:53:21 2016
>> @@ -13,18 +13,27 @@
>> 
>> include(TestFile)
>> 
>> +
>> +# Set unique target prefix within caller's scope.
>> +function(llvm_target_prefix prefix)
>> +  if(prefix)
>> +    set(TARGET_PREFIX "${prefix}-" PARENT_SCOPE)
>> +  else()
>> +    set(TARGET_PREFIX "" PARENT_SCOPE)
>> +  endif()
>> +endfunction()
>> +
>> # Given a source file name after which a test should be named, create a unique
>> # name for the test. Usually this is just the source file with the suffix
>> -# stripped, but in some cases this ends up causing duplicates so attempt to
>> -# make each unique (by adding pathname segments until they become unique).
>> -#
>> -# FIXME: Swap this with a simpler procedure to just append a numeral
>> +# stripped, and ${TARGET_PREFIX} prepended.
>> set_property(GLOBAL PROPERTY registered_executables)
>> function(get_unique_exe_name new_name main_src)
>>   get_property(registered_executables GLOBAL PROPERTY registered_executables)
>> 
>>   string(REGEX REPLACE ".[cp]+$" "" path ${main_src})
>> -  string(REGEX REPLACE ".*/" "" name ${path})
>> +  get_filename_component(name ${path} NAME )
>> +  set(name "${TARGET_PREFIX}${name}")
>> +
>>   list(FIND registered_executables ${name} name_idx)
>> 
>>   if(${name_idx} EQUAL -1)
>> @@ -33,20 +42,8 @@ function(get_unique_exe_name new_name ma
>>     return()
>>   endif()
>> 
>> -  # There is a clash. Rename the target. Each time around the loop pull in
>> -  # a new path component.
>> -  foreach(n RANGE 1 4)
>> -    string(REGEX REPLACE ".*/([^/]+/${name})" "\\1 <>" name ${path})
>> -    string(REGEX REPLACE "/" "-" safe_name ${name})
>> -
>> -    list(FIND registered_executables ${safe_name} name_idx)
>> -    if(${name_idx} EQUAL -1)
>> -      set(${new_name} ${safe_name} PARENT_SCOPE)
>> -      set_property(GLOBAL APPEND PROPERTY registered_executables ${safe_name})
>> -      return()
>> -    endif()
>> -  endforeach()
>> -  message(FATAL_ERROR "Failed to uniquify executable name!")
>> +  message(FATAL_ERROR "Duplicate executable name!"
>> +    "Please set unique prefix with llvm_target_prefix().")
>> endfunction()
>> 
>> # Add flags to a cmake target property.
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits>
> 
> 
> 
> 
> -- 
> --Artem Belevich
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160425/1ecf7958/attachment.html>


More information about the llvm-commits mailing list