[test-suite] r302958 - cmake: Rework External handling

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 15:15:46 PDT 2017


Author: matze
Date: Fri May 12 17:15:46 2017
New Revision: 302958

URL: http://llvm.org/viewvc/llvm-project?rev=302958&view=rev
Log:
cmake: Rework External handling

When doing -DTEST_SUITE_SUBDIRS=External/skidmarks10 then
External/CMakeLists.txt and the macros within would be skipped.
Therefore move the llvm_externals_find() macro to a shared cmake module.

Added:
    test-suite/trunk/cmake/modules/External.cmake
      - copied, changed from r302900, test-suite/trunk/External/CMakeLists.txt
Modified:
    test-suite/trunk/CMakeLists.txt
    test-suite/trunk/External/CMakeLists.txt
    test-suite/trunk/External/CUDA/CMakeLists.txt
    test-suite/trunk/External/HMMER/CMakeLists.txt
    test-suite/trunk/External/Nurbs/CMakeLists.txt
    test-suite/trunk/External/Povray/CMakeLists.txt
    test-suite/trunk/External/skidmarks10/CMakeLists.txt

Modified: test-suite/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/CMakeLists.txt?rev=302958&r1=302957&r2=302958&view=diff
==============================================================================
--- test-suite/trunk/CMakeLists.txt (original)
+++ test-suite/trunk/CMakeLists.txt Fri May 12 17:15:46 2017
@@ -213,9 +213,18 @@ set(TEST_SUITE_SUBDIRS "${TEST_SUITE_SUB
     "Semicolon separated list of directories with CMakeLists.txt to include")
 
 foreach(subdir ${TEST_SUITE_SUBDIRS})
+  # When we add subdirs outside the toplevel source directory then we have to
+  # make up a directory to use for the builddir.
+  if(subdir MATCHES "^/" OR subdir MATCHES "\\.\\.")
+    if(subdir MATCHES "/$")
+      message(FATAL_ERROR "Subdir must not end in '/'")
+    endif()
+    get_filename_component(subdir_name ${subdir} NAME)
+  else()
+    set(subdir_name ${subdir})
+  endif()
   message(STATUS "Adding directory ${subdir}")
-  get_filename_component(subdir_basename ${subdir} NAME)
-  add_subdirectory(${subdir} ${subdir_basename})
+  add_subdirectory(${subdir} ${subdir_name})
 endforeach()
 
 option(TEST_SUITE_RUN_BENCHMARKS "Actually run the benchmarks in lit" On)

Modified: test-suite/trunk/External/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/CMakeLists.txt?rev=302958&r1=302957&r2=302958&view=diff
==============================================================================
--- test-suite/trunk/External/CMakeLists.txt (original)
+++ test-suite/trunk/External/CMakeLists.txt Fri May 12 17:15:46 2017
@@ -1,29 +1,3 @@
-set(TEST_SUITE_EXTERNALS_DIR "" CACHE PATH
-    "Directory containing test-suite external benchmark sources")
-
-# Find path containing an external benchmark and set PATHVAR to it.
-# Specifically this:
-# - Adds a CACHE variable for PATHVAR
-# - If PATHVAR is unset set it to the first existing directory in this list:
-#   - ${TEST_SUITE_EXTERNALS_DIR}/${NAME}
-#   - ${CMAKE_SOURCE_DIR}/test-suite-externals/${NAME}
-macro(llvm_externals_find PATHVAR NAME DESCRIPTION)
-  set(${PATHVAR} "" CACHE PATH "Directory containing ${DESCRIPTION} sourcecode")
-  if(TEST_SUITE_EXTERNALS_DIR)
-    if (NOT ${PATHVAR} AND IS_DIRECTORY "${TEST_SUITE_EXTERNALS_DIR}/${NAME}")
-      set(${PATHVAR} "${TEST_SUITE_EXTERNALS_DIR}/${NAME}")
-    endif()
-  else()
-    if(NOT ${PATHVAR} AND
-       IS_DIRECTORY "${CMAKE_SOURCE_DIR}/test-suite-externals/${NAME}")
-      set(${PATHVAR} "${CMAKE_SOURCE_DIR}/test-suite-externals/${NAME}")
-    endif()
-  endif()
-  if(${PATHVAR})
-    message(STATUS "Found ${DESCRIPTION}: ${${PATHVAR}}")
-  endif()
-endmacro()
-
 add_subdirectory(CUDA)
 add_subdirectory(HMMER)
 add_subdirectory(Nurbs)

Modified: test-suite/trunk/External/CUDA/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/CUDA/CMakeLists.txt?rev=302958&r1=302957&r2=302958&view=diff
==============================================================================
--- test-suite/trunk/External/CUDA/CMakeLists.txt (original)
+++ test-suite/trunk/External/CUDA/CMakeLists.txt Fri May 12 17:15:46 2017
@@ -1,3 +1,4 @@
+include(External)
 llvm_externals_find(TEST_SUITE_CUDA_ROOT "cuda" "CUDA prerequisites")
 
 # Helper macro to extract version number at the end of the string

Modified: test-suite/trunk/External/HMMER/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/HMMER/CMakeLists.txt?rev=302958&r1=302957&r2=302958&view=diff
==============================================================================
--- test-suite/trunk/External/HMMER/CMakeLists.txt (original)
+++ test-suite/trunk/External/HMMER/CMakeLists.txt Fri May 12 17:15:46 2017
@@ -1,3 +1,4 @@
+include(External)
 llvm_externals_find(TEST_SUITE_HMMER_ROOT "hmmer" "HMMER 2.3.2")
 
 if(TEST_SUITE_HMMER_ROOT)

Modified: test-suite/trunk/External/Nurbs/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/Nurbs/CMakeLists.txt?rev=302958&r1=302957&r2=302958&view=diff
==============================================================================
--- test-suite/trunk/External/Nurbs/CMakeLists.txt (original)
+++ test-suite/trunk/External/Nurbs/CMakeLists.txt Fri May 12 17:15:46 2017
@@ -1,5 +1,6 @@
 # Nurbs uses SSE and only works on x86.
 if(ARCH STREQUAL "x86")
+  include(External)
   llvm_externals_find(TEST_SUITE_NURBS_ROOT "nurbs" "Nurbs")
 
   if(TEST_SUITE_NURBS_ROOT)

Modified: test-suite/trunk/External/Povray/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/Povray/CMakeLists.txt?rev=302958&r1=302957&r2=302958&view=diff
==============================================================================
--- test-suite/trunk/External/Povray/CMakeLists.txt (original)
+++ test-suite/trunk/External/Povray/CMakeLists.txt Fri May 12 17:15:46 2017
@@ -1,3 +1,4 @@
+include(External)
 llvm_externals_find(TEST_SUITE_POVRAY_ROOT "povray31" "POV-Ray 3.1")
 
 if(TEST_SUITE_POVRAY_ROOT)

Modified: test-suite/trunk/External/skidmarks10/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/skidmarks10/CMakeLists.txt?rev=302958&r1=302957&r2=302958&view=diff
==============================================================================
--- test-suite/trunk/External/skidmarks10/CMakeLists.txt (original)
+++ test-suite/trunk/External/skidmarks10/CMakeLists.txt Fri May 12 17:15:46 2017
@@ -1,3 +1,4 @@
+include(External)
 llvm_externals_find(TEST_SUITE_SKIDMARKS10_ROOT "skidmarks10" "Skidmarks 10")
 
 if(TEST_SUITE_SKIDMARKS10_ROOT)

Copied: test-suite/trunk/cmake/modules/External.cmake (from r302900, test-suite/trunk/External/CMakeLists.txt)
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/modules/External.cmake?p2=test-suite/trunk/cmake/modules/External.cmake&p1=test-suite/trunk/External/CMakeLists.txt&r1=302900&r2=302958&rev=302958&view=diff
==============================================================================
--- test-suite/trunk/External/CMakeLists.txt (original)
+++ test-suite/trunk/cmake/modules/External.cmake Fri May 12 17:15:46 2017
@@ -9,24 +9,18 @@ set(TEST_SUITE_EXTERNALS_DIR "" CACHE PA
 #   - ${CMAKE_SOURCE_DIR}/test-suite-externals/${NAME}
 macro(llvm_externals_find PATHVAR NAME DESCRIPTION)
   set(${PATHVAR} "" CACHE PATH "Directory containing ${DESCRIPTION} sourcecode")
-  if(TEST_SUITE_EXTERNALS_DIR)
-    if (NOT ${PATHVAR} AND IS_DIRECTORY "${TEST_SUITE_EXTERNALS_DIR}/${NAME}")
-      set(${PATHVAR} "${TEST_SUITE_EXTERNALS_DIR}/${NAME}")
+  if(NOT ${PATHVAR})
+    if(TEST_SUITE_EXTERNALS_DIR)
+      if (IS_DIRECTORY "${TEST_SUITE_EXTERNALS_DIR}/${NAME}")
+        set(${PATHVAR} "${TEST_SUITE_EXTERNALS_DIR}/${NAME}")
+      endif()
+    else()
+      if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/test-suite-externals/${NAME}")
+        set(${PATHVAR} "${CMAKE_SOURCE_DIR}/test-suite-externals/${NAME}")
+      endif()
     endif()
-  else()
-    if(NOT ${PATHVAR} AND
-       IS_DIRECTORY "${CMAKE_SOURCE_DIR}/test-suite-externals/${NAME}")
-      set(${PATHVAR} "${CMAKE_SOURCE_DIR}/test-suite-externals/${NAME}")
+    if(${PATHVAR})
+      message(STATUS "Found ${DESCRIPTION}: ${${PATHVAR}}")
     endif()
   endif()
-  if(${PATHVAR})
-    message(STATUS "Found ${DESCRIPTION}: ${${PATHVAR}}")
-  endif()
 endmacro()
-
-add_subdirectory(CUDA)
-add_subdirectory(HMMER)
-add_subdirectory(Nurbs)
-add_subdirectory(Povray)
-add_subdirectory(SPEC)
-add_subdirectory(skidmarks10)




More information about the llvm-commits mailing list