[llvm-commits] [llvm] r158909 - in /llvm/trunk: cmake/modules/AddLLVM.cmake cmake/modules/LLVMProcessSources.cmake unittests/ADT/CMakeLists.txt unittests/Analysis/CMakeLists.txt unittests/Bitcode/CMakeLists.txt unittests/CMakeLists.txt unittests/ExecutionEngine/CMakeLists.txt unittests/ExecutionEngine/JIT/CMakeLists.txt unittests/Support/CMakeLists.txt unittests/Transforms/CMakeLists.txt unittests/Transforms/Utils/CMakeLists.txt unittests/VMCore/CMakeLists.txt

Chandler Carruth chandlerc at gmail.com
Thu Jun 21 02:51:27 PDT 2012


Author: chandlerc
Date: Thu Jun 21 04:51:26 2012
New Revision: 158909

URL: http://llvm.org/viewvc/llvm-project?rev=158909&view=rev
Log:
Completely refactor the structuring of unittest CMake files to match the
Makefiles, the CMake files in every other part of the LLVM tree, and
sanity.

This should also restore the output tree structure of all the unit
tests, sorry for breaking that, and thanks for letting me know.

The fundamental change is to put a CMakeLists.txt file in the unittest
directory, with a single test binary produced from it. This has several
advantages:

- No more weird directory stripping in the unittest macro, allowing it
  to be used more readily in other projects.
- No more directory prefixes on all the source files.
- Allows correct and precise use of LLVM's per-directory dependency
  system.
- Allows use of the checking logic for source files that have not been
  added to the CMake build. This uncovered a file being skipped with
  CMake in LLVM and one in Clang's unit tests.
- Makes Specifying conditional compilation or other custom logic for JIT
  tests easier.

It did require adding the concept of an explicit 'optional' source file
to the CMake build so that the missing-file check can skip cases where
the file is *supposed* to be missing. =]

This is another chunk of refactoring the CMake build in order to make it
usable for other clients like CompilerRT / ASan / TSan.

Note that this is interdependent with a Clang CMake change.

Added:
    llvm/trunk/unittests/ADT/CMakeLists.txt
    llvm/trunk/unittests/Analysis/CMakeLists.txt
    llvm/trunk/unittests/Bitcode/CMakeLists.txt
    llvm/trunk/unittests/ExecutionEngine/CMakeLists.txt
    llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt
    llvm/trunk/unittests/Support/CMakeLists.txt
    llvm/trunk/unittests/Transforms/CMakeLists.txt
    llvm/trunk/unittests/Transforms/Utils/CMakeLists.txt
    llvm/trunk/unittests/VMCore/CMakeLists.txt
Modified:
    llvm/trunk/cmake/modules/AddLLVM.cmake
    llvm/trunk/cmake/modules/LLVMProcessSources.cmake
    llvm/trunk/unittests/CMakeLists.txt

Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=158909&r1=158908&r2=158909&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Thu Jun 21 04:51:26 2012
@@ -149,14 +149,12 @@
 endmacro(add_llvm_external_project)
 
 # Generic support for adding a unittest.
-function(add_unittest test_suite test_dirname)
-  string(REGEX MATCH "([^/]+)$" test_name ${test_dirname})
+function(add_unittest test_suite test_name)
   if (CMAKE_BUILD_TYPE)
     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
-      ${CMAKE_CURRENT_BINARY_DIR}/${test_dirname}/${CMAKE_BUILD_TYPE})
+      ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
   else()
-    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
-      ${CMAKE_CURRENT_BINARY_DIR}/${test_dirname})
+    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
   endif()
   if( NOT LLVM_BUILD_TESTS )
     set(EXCLUDE_FROM_ALL ON)

Modified: llvm/trunk/cmake/modules/LLVMProcessSources.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMProcessSources.cmake?rev=158909&r1=158908&r2=158909&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/LLVMProcessSources.cmake (original)
+++ llvm/trunk/cmake/modules/LLVMProcessSources.cmake Thu Jun 21 04:51:26 2012
@@ -81,10 +81,13 @@
   file(GLOB globbed *.cpp)
   foreach(g ${globbed})
     get_filename_component(fn ${g} NAME)
-    list(FIND listed ${fn} idx)
+    list(FIND LLVM_OPTIONAL_SOURCES ${fn} idx)
     if( idx LESS 0 )
-      message(SEND_ERROR "Found unknown source file ${g}
+      list(FIND listed ${fn} idx)
+      if( idx LESS 0 )
+        message(SEND_ERROR "Found unknown source file ${g}
 Please update ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt\n")
+      endif()
     endif()
   endforeach()
 endfunction(llvm_check_source_file_list)

Added: llvm/trunk/unittests/ADT/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/CMakeLists.txt?rev=158909&view=auto
==============================================================================
--- llvm/trunk/unittests/ADT/CMakeLists.txt (added)
+++ llvm/trunk/unittests/ADT/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -0,0 +1,32 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  )
+
+add_llvm_unittest(ADTTests
+  APFloatTest.cpp
+  APIntTest.cpp
+  BitVectorTest.cpp
+  DAGDeltaAlgorithmTest.cpp
+  DeltaAlgorithmTest.cpp
+  DenseMapTest.cpp
+  DenseSetTest.cpp
+  FoldingSet.cpp
+  HashingTest.cpp
+  ilistTest.cpp
+  ImmutableSetTest.cpp
+  IntEqClassesTest.cpp
+  IntervalMapTest.cpp
+  IntrusiveRefCntPtrTest.cpp
+  PackedVectorTest.cpp
+  SCCIteratorTest.cpp
+  SmallPtrSetTest.cpp
+  SmallStringTest.cpp
+  SmallVectorTest.cpp
+  SparseBitVectorTest.cpp
+  SparseSetTest.cpp
+  StringMapTest.cpp
+  StringRefTest.cpp
+  TripleTest.cpp
+  TwineTest.cpp
+  VariadicFunctionTest.cpp
+ )

Added: llvm/trunk/unittests/Analysis/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/CMakeLists.txt?rev=158909&view=auto
==============================================================================
--- llvm/trunk/unittests/Analysis/CMakeLists.txt (added)
+++ llvm/trunk/unittests/Analysis/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -0,0 +1,7 @@
+set(LLVM_LINK_COMPONENTS
+  Analysis
+  )
+
+add_llvm_unittest(AnalysisTests
+  ScalarEvolutionTest.cpp
+  )

Added: llvm/trunk/unittests/Bitcode/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Bitcode/CMakeLists.txt?rev=158909&view=auto
==============================================================================
--- llvm/trunk/unittests/Bitcode/CMakeLists.txt (added)
+++ llvm/trunk/unittests/Bitcode/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -0,0 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  BitReader
+  BitWriter
+  )
+
+add_llvm_unittest(BitcodeTests
+  BitReaderTest.cpp
+  )

Modified: llvm/trunk/unittests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CMakeLists.txt?rev=158909&r1=158908&r2=158909&view=diff
==============================================================================
--- llvm/trunk/unittests/CMakeLists.txt (original)
+++ llvm/trunk/unittests/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -5,151 +5,10 @@
   add_unittest(UnitTests ${test_dirname} ${ARGN})
 endfunction()
 
-set(LLVM_LINK_COMPONENTS
-  jit
-  interpreter
-  nativecodegen
-  BitWriter
-  BitReader
-  AsmParser
-  Core
-  Support
-  )
-
-add_llvm_unittest(ADTTests
-  ADT/APFloatTest.cpp
-  ADT/APIntTest.cpp
-  ADT/BitVectorTest.cpp
-  ADT/DAGDeltaAlgorithmTest.cpp
-  ADT/DeltaAlgorithmTest.cpp
-  ADT/DenseMapTest.cpp
-  ADT/DenseSetTest.cpp
-  ADT/FoldingSet.cpp
-  ADT/HashingTest.cpp
-  ADT/ilistTest.cpp
-  ADT/ImmutableSetTest.cpp
-  ADT/IntEqClassesTest.cpp
-  ADT/IntervalMapTest.cpp
-  ADT/IntrusiveRefCntPtrTest.cpp
-  ADT/PackedVectorTest.cpp
-  ADT/SCCIteratorTest.cpp
-  ADT/SmallPtrSetTest.cpp
-  ADT/SmallStringTest.cpp
-  ADT/SmallVectorTest.cpp
-  ADT/SparseBitVectorTest.cpp
-  ADT/SparseSetTest.cpp
-  ADT/StringMapTest.cpp
-  ADT/StringRefTest.cpp
-  ADT/TripleTest.cpp
-  ADT/TwineTest.cpp
-  ADT/VariadicFunctionTest.cpp
- )
-
-add_llvm_unittest(AnalysisTests
-  Analysis/ScalarEvolutionTest.cpp
-  )
-
-add_llvm_unittest(ExecutionEngineTests
-  ExecutionEngine/ExecutionEngineTest.cpp
-  )
-
-if( LLVM_USE_INTEL_JITEVENTS )
-  include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
-  link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
-  set(ProfileTestSources
-    ExecutionEngine/JIT/IntelJITEventListenerTest.cpp
-    )
-  set(LLVM_LINK_COMPONENTS
-    ${LLVM_LINK_COMPONENTS}
-    IntelJITEvents
-    ) 
-endif( LLVM_USE_INTEL_JITEVENTS )
-
-if( LLVM_USE_OPROFILE )
-  set(ProfileTestSources
-    ${ProfileTestSources}
-    ExecutionEngine/JIT/OProfileJITEventListenerTest.cpp
-    )
-  set(LLVM_LINK_COMPONENTS
-    ${LLVM_LINK_COMPONENTS}
-    OProfileJIT
-    )
-endif( LLVM_USE_OPROFILE )
-
-set(JITTestsSources
-  ExecutionEngine/JIT/JITEventListenerTest.cpp
-  ExecutionEngine/JIT/JITMemoryManagerTest.cpp
-  ExecutionEngine/JIT/JITTest.cpp
-  ExecutionEngine/JIT/MultiJITTest.cpp
-  ${ProfileTestSources}
-  )
-
-if(MSVC)
-  list(APPEND JITTestsSources ExecutionEngine/JIT/JITTests.def)
-endif()
-
-add_llvm_unittest(ExecutionEngine/JITTests
-  ${JITTestsSources}
-  )
-
-if(MINGW OR CYGWIN)
-  set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
-endif()
-
-add_llvm_unittest(Transforms/UtilsTests
-  Transforms/Utils/Cloning.cpp
-  )
-
-set(VMCoreSources
-  VMCore/ConstantsTest.cpp
-  VMCore/DominatorTreeTest.cpp
-  VMCore/InstructionsTest.cpp
-  VMCore/MetadataTest.cpp
-  VMCore/PassManagerTest.cpp
-  VMCore/ValueMapTest.cpp
-  VMCore/VerifierTest.cpp
-  )
-
-# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
-# See issue#331418 in Visual Studio.
-if(MSVC AND MSVC_VERSION LESS 1600)
-  list(REMOVE_ITEM VMCoreSources VMCore/ValueMapTest.cpp)
-endif()
-
-add_llvm_unittest(VMCoreTests
-  ${VMCoreSources}
-  )
-
-add_llvm_unittest(BitcodeTests
-  Bitcode/BitReaderTest.cpp
-  )
-
-set(LLVM_LINK_COMPONENTS
-  Support
-  Core
-  )
-
-add_llvm_unittest(SupportTests
-  Support/AlignOfTest.cpp
-  Support/AllocatorTest.cpp
-  Support/BlockFrequencyTest.cpp
-  Support/Casting.cpp
-  Support/CommandLineTest.cpp
-  Support/ConstantRangeTest.cpp
-  Support/DataExtractorTest.cpp
-  Support/EndianTest.cpp
-  Support/IntegersSubsetTest.cpp
-  Support/IRBuilderTest.cpp
-  Support/LeakDetectorTest.cpp
-  Support/ManagedStatic.cpp
-  Support/MathExtrasTest.cpp
-  Support/MDBuilderTest.cpp
-  Support/Path.cpp
-  Support/raw_ostream_test.cpp
-  Support/RegexTest.cpp
-  Support/SwapByteOrderTest.cpp
-  Support/TimeValue.cpp
-  Support/TypeBuilderTest.cpp
-  Support/ValueHandleTest.cpp
-  Support/YAMLParserTest.cpp
-  )
+add_subdirectory(ADT)
+add_subdirectory(Analysis)
+add_subdirectory(ExecutionEngine)
+add_subdirectory(Bitcode)
+add_subdirectory(Support)
+add_subdirectory(Transforms)
+add_subdirectory(VMCore)

Added: llvm/trunk/unittests/ExecutionEngine/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/CMakeLists.txt?rev=158909&view=auto
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/CMakeLists.txt (added)
+++ llvm/trunk/unittests/ExecutionEngine/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -0,0 +1,11 @@
+set(LLVM_LINK_COMPONENTS
+  jit
+  interpreter
+  nativecodegen
+  )
+
+add_llvm_unittest(ExecutionEngineTests
+  ExecutionEngineTest.cpp
+  )
+
+add_subdirectory(JIT)

Added: llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt?rev=158909&view=auto
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt (added)
+++ llvm/trunk/unittests/ExecutionEngine/JIT/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -0,0 +1,55 @@
+set(LLVM_LINK_COMPONENTS
+  jit
+  interpreter
+  nativecodegen
+  )
+
+# HACK: Declare a couple of source files as optionally compiled to satisfy the
+# missing-file-checker in LLVM's weird CMake build.
+set(LLVM_OPTIONAL_SOURCES
+  IntelJITEventListenerTest.cpp
+  OProfileJITEventListenerTest.cpp
+  )
+
+if( LLVM_USE_INTEL_JITEVENTS )
+  include_directories( ${LLVM_INTEL_JITEVENTS_INCDIR} )
+  link_directories( ${LLVM_INTEL_JITEVENTS_LIBDIR} )
+  set(ProfileTestSources
+    IntelJITEventListenerTest.cpp
+    )
+  set(LLVM_LINK_COMPONENTS
+    ${LLVM_LINK_COMPONENTS}
+    IntelJITEvents
+    ) 
+endif( LLVM_USE_INTEL_JITEVENTS )
+
+if( LLVM_USE_OPROFILE )
+  set(ProfileTestSources
+    ${ProfileTestSources}
+    OProfileJITEventListenerTest.cpp
+    )
+  set(LLVM_LINK_COMPONENTS
+    ${LLVM_LINK_COMPONENTS}
+    OProfileJIT
+    )
+endif( LLVM_USE_OPROFILE )
+
+set(JITTestsSources
+  JITEventListenerTest.cpp
+  JITMemoryManagerTest.cpp
+  JITTest.cpp
+  MultiJITTest.cpp
+  ${ProfileTestSources}
+  )
+
+if(MSVC)
+  list(APPEND JITTestsSources JITTests.def)
+endif()
+
+add_llvm_unittest(ExecutionEngine/JITTests
+  ${JITTestsSources}
+  )
+
+if(MINGW OR CYGWIN)
+  set_property(TARGET JITTests PROPERTY LINK_FLAGS -Wl,--export-all-symbols)
+endif()

Added: llvm/trunk/unittests/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/CMakeLists.txt?rev=158909&view=auto
==============================================================================
--- llvm/trunk/unittests/Support/CMakeLists.txt (added)
+++ llvm/trunk/unittests/Support/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -0,0 +1,29 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  Core
+  )
+
+add_llvm_unittest(SupportTests
+  AlignOfTest.cpp
+  AllocatorTest.cpp
+  BlockFrequencyTest.cpp
+  Casting.cpp
+  CommandLineTest.cpp
+  ConstantRangeTest.cpp
+  DataExtractorTest.cpp
+  EndianTest.cpp
+  IntegersSubsetTest.cpp
+  IRBuilderTest.cpp
+  LeakDetectorTest.cpp
+  ManagedStatic.cpp
+  MathExtrasTest.cpp
+  MDBuilderTest.cpp
+  Path.cpp
+  raw_ostream_test.cpp
+  RegexTest.cpp
+  SwapByteOrderTest.cpp
+  TimeValue.cpp
+  TypeBuilderTest.cpp
+  ValueHandleTest.cpp
+  YAMLParserTest.cpp
+  )

Added: llvm/trunk/unittests/Transforms/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/CMakeLists.txt?rev=158909&view=auto
==============================================================================
--- llvm/trunk/unittests/Transforms/CMakeLists.txt (added)
+++ llvm/trunk/unittests/Transforms/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -0,0 +1 @@
+add_subdirectory(Utils)

Added: llvm/trunk/unittests/Transforms/Utils/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/CMakeLists.txt?rev=158909&view=auto
==============================================================================
--- llvm/trunk/unittests/Transforms/Utils/CMakeLists.txt (added)
+++ llvm/trunk/unittests/Transforms/Utils/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -0,0 +1,8 @@
+set(LLVM_LINK_COMPONENTS
+  TransformUtils
+  )
+
+add_llvm_unittest(UtilsTests
+  Cloning.cpp
+  Local.cpp
+  )

Added: llvm/trunk/unittests/VMCore/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/CMakeLists.txt?rev=158909&view=auto
==============================================================================
--- llvm/trunk/unittests/VMCore/CMakeLists.txt (added)
+++ llvm/trunk/unittests/VMCore/CMakeLists.txt Thu Jun 21 04:51:26 2012
@@ -0,0 +1,27 @@
+set(LLVM_LINK_COMPONENTS
+  asmparser
+  analysis
+  core
+  ipa
+  target
+  )
+
+set(VMCoreSources
+  ConstantsTest.cpp
+  DominatorTreeTest.cpp
+  InstructionsTest.cpp
+  MetadataTest.cpp
+  PassManagerTest.cpp
+  ValueMapTest.cpp
+  VerifierTest.cpp
+  )
+
+# MSVC9 and 8 cannot compile ValueMapTest.cpp due to their bug.
+# See issue#331418 in Visual Studio.
+if(MSVC AND MSVC_VERSION LESS 1600)
+  list(REMOVE_ITEM VMCoreSources ValueMapTest.cpp)
+endif()
+
+add_llvm_unittest(VMCoreTests
+  ${VMCoreSources}
+  )





More information about the llvm-commits mailing list