[test-suite] r322013 - [test-suite, CUDA] Make sure we use the thrust library from test external dir.

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 10:09:42 PST 2018


Author: tra
Date: Mon Jan  8 10:09:42 2018
New Revision: 322013

URL: http://llvm.org/viewvc/llvm-project?rev=322013&view=rev
Log:
[test-suite, CUDA] Make sure we use the thrust library from test external dir.

CUDA SDK comes with its own copy of thrust in its includes. In order to
guarantee that our thrust tests pick up the headers from the right place,
we need to ensure that thrust include paths precede any explicit CUDA
include paths.

Differential Revision: https://reviews.llvm.org/D41685

Modified:
    test-suite/trunk/External/CUDA/CMakeLists.txt

Modified: test-suite/trunk/External/CUDA/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/CUDA/CMakeLists.txt?rev=322013&r1=322012&r2=322013&view=diff
==============================================================================
--- test-suite/trunk/External/CUDA/CMakeLists.txt (original)
+++ test-suite/trunk/External/CUDA/CMakeLists.txt Mon Jan  8 10:09:42 2018
@@ -61,6 +61,7 @@ macro(create_one_local_test Name FileGlo
     llvm_test_run()
   endif()
   llvm_test_executable(${_executable} ${_sources})
+  target_compile_options(${_executable} PUBLIC ${VariantCPPFLAGS})
   if(VariantLibs)
     target_link_libraries(${_executable} ${VariantLibs})
   endif()
@@ -98,7 +99,8 @@ macro(create_one_thrust_test TestSource)
   llvm_test_run(--verbose ${_ExtraThrustTestArgs})
   llvm_test_executable(${_executable} ${TestSource})
   target_link_libraries(${_executable} ${VariantLibs})
-  target_compile_options(${_executable} PUBLIC ${THRUST_CPPFLAGS})
+  target_compile_options(${_executable} BEFORE PUBLIC ${THRUST_CPPFLAGS})
+  target_compile_options(${_executable} PUBLIC ${VariantCPPFLAGS})
   list(APPEND THRUST_VARIANT_TESTS ${_executable})
 endmacro()
 
@@ -111,7 +113,8 @@ function(create_thrust_tests VariantSuff
     # test framework is common for all tests, so we build it once as a
     # library.
     add_library(ThrustTestFrameworkLib-${VariantSuffix} STATIC ${ThrustTestFramework})
-    append_compile_flags(ThrustTestFrameworkLib-${VariantSuffix} ${CPPFLAGS} ${THRUST_CPPFLAGS})
+    target_compile_options(ThrustTestFrameworkLib-${VariantSuffix} BEFORE PRIVATE ${THRUST_CPPFLAGS})
+    target_compile_options(ThrustTestFrameworkLib-${VariantSuffix} PRIVATE ${VariantCPPFLAGS})
     add_dependencies(ThrustTestFrameworkLib-${VariantSuffix} timeit-host fpcmp-host)
     list(APPEND VariantLibs ThrustTestFrameworkLib-${VariantSuffix})
 
@@ -133,8 +136,12 @@ function(create_thrust_tests VariantSuff
     # overhead, so it's actually way slower than running all tests
     # sequentially.
     llvm_test_run(--verbose ${_ExtraThrustTestArgs})
+    # CUDA SDK comes with its own version of thrust in its include directory.
+    # In order to use the thrust library we want, its include path must precede
+    # that of the CUDA SDK include path.
     llvm_test_executable(${_ThrustMainTarget} ${ThrustTestFramework} ${ThrustAllTestSources})
-    target_compile_options(${_ThrustMainTarget} PUBLIC ${THRUST_CPPFLAGS})
+    target_compile_options(${_ThrustMainTarget} BEFORE PUBLIC ${THRUST_CPPFLAGS})
+    target_compile_options(${_executable} PUBLIC ${VariantCPPFLAGS})
     target_link_libraries(${_ThrustMainTarget} ${VariantLibs})
   endif()
   add_dependencies(cuda-tests-${VariantSuffix} cuda-tests-thrust-${VariantSuffix})
@@ -148,7 +155,7 @@ function(create_cuda_test_variant Std Va
     COMMENT "Build CUDA test variant ${VariantSuffix}")
 
   set(VariantLibs ${_Cuda_Libs} ${_Stdlib_Libs})
-  list(APPEND CPPFLAGS ${_Cuda_CPPFLAGS} ${_Std_CPPFLAGS} ${_Stdlib_CPPFLAGS})
+  set(VariantCPPFLAGS ${_Cuda_CPPFLAGS} ${_Std_CPPFLAGS} ${_Stdlib_CPPFLAGS})
   list(APPEND LDFLAGS ${_Cuda_LDFLAGS} ${_Std_LDFLAGS} ${_Stdlib_LDFLAGS})
 
   # Create a separate test target for simple tests that can be built/tested quickly.




More information about the llvm-commits mailing list