[Lldb-commits] [lldb] r232210 - Create a CMake build for the gtest unit tests.

Zachary Turner zturner at google.com
Fri Mar 13 13:54:21 PDT 2015


Author: zturner
Date: Fri Mar 13 15:54:21 2015
New Revision: 232210

URL: http://llvm.org/viewvc/llvm-project?rev=232210&view=rev
Log:
Create a CMake build for the gtest unit tests.

Added:
    lldb/trunk/gtest/CMakeLists.txt
    lldb/trunk/gtest/include/
    lldb/trunk/gtest/include/gtest_common.h
    lldb/trunk/gtest/unittest/CMakeLists.txt
    lldb/trunk/gtest/unittest/Host/CMakeLists.txt
    lldb/trunk/gtest/unittest/Plugins/CMakeLists.txt
    lldb/trunk/gtest/unittest/Plugins/Process/CMakeLists.txt
    lldb/trunk/gtest/unittest/Plugins/Process/Linux/CMakeLists.txt
    lldb/trunk/gtest/unittest/Utility/CMakeLists.txt
Modified:
    lldb/trunk/CMakeLists.txt
    lldb/trunk/cmake/modules/LLDBConfig.cmake

Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=232210&r1=232209&r2=232210&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Fri Mar 13 15:54:21 2015
@@ -10,6 +10,7 @@ endif ()
 add_subdirectory(source)
 add_subdirectory(test)
 add_subdirectory(tools)
+add_subdirectory(gtest)
 
 
 if ( LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION AND NOT LLDB_DISABLE_PYTHON )

Modified: lldb/trunk/cmake/modules/LLDBConfig.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBConfig.cmake?rev=232210&r1=232209&r2=232210&view=diff
==============================================================================
--- lldb/trunk/cmake/modules/LLDBConfig.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBConfig.cmake Fri Mar 13 15:54:21 2015
@@ -25,7 +25,7 @@ set(LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_
   "Enables using new Python scripts for SWIG API generation .")  
 
 set(LLDB_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/source")
-set(LLDB_INCLUDE_ROOT "${LLDB_INCLUDE_ROOT}/include")
+set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include")
 
 set(LLDB_DISABLE_PYTHON 0 CACHE BOOL "Disables the Python scripting integration.")
 

Added: lldb/trunk/gtest/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/CMakeLists.txt?rev=232210&view=auto
==============================================================================
--- lldb/trunk/gtest/CMakeLists.txt (added)
+++ lldb/trunk/gtest/CMakeLists.txt Fri Mar 13 15:54:21 2015
@@ -0,0 +1,21 @@
+add_custom_target(LLDBUnitTests)
+set_target_properties(LLDBUnitTests PROPERTIES FOLDER "LLDB tests")
+
+include_directories(${LLDB_SOURCE_ROOT})
+
+set(LLDB_GTEST_COMMON_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/gtest_common.h)
+if (MSVC)
+  list(APPEND LLVM_COMPILE_FLAGS /FI ${LLDB_GTEST_COMMON_INCLUDE})
+else ()
+  list(APPEND LLVM_COMPILE_FLAGS -include ${LLDB_GTEST_COMMON_INCLUDE})
+endif ()
+
+# add_lldb_unittest(test_dirname file1.cpp file2.cpp)
+#
+# Will compile the list of files together and link against the liblldb
+function(add_lldb_unittest test_name)
+  add_unittest(LLDBUnitTests ${test_name} ${ARGN})
+  target_link_libraries(${test_name} liblldb)
+endfunction()
+
+add_subdirectory(unittest)

Added: lldb/trunk/gtest/include/gtest_common.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/include/gtest_common.h?rev=232210&view=auto
==============================================================================
--- lldb/trunk/gtest/include/gtest_common.h (added)
+++ lldb/trunk/gtest/include/gtest_common.h Fri Mar 13 15:54:21 2015
@@ -0,0 +1,32 @@
+//===-- gtest_common.h ------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(LLDB_GTEST_COMMON_H)
+#error "gtest_common.h should not be included manually."
+#else
+#define LLDB_GTEST_COMMON_H
+#endif
+
+// This header file is force included by all of LLDB's unittest compilation
+// units.  Be very leary about putting anything in this file.
+
+#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
+// MSVC's STL implementation tries to work well with /EHs-c- and
+// _HAS_EXCEPTIONS=0.  But <thread> in particular doesn't work with it, because
+// it relies on <concrt.h> which tries to throw an exception without checking
+// for _HAS_EXCEPTIONS=0.  This causes the linker to require a definition of
+// __uncaught_exception(), but the STL doesn't define this function when
+// _HAS_EXCEPTIONS=0.  The workaround here is to just provide a stub
+// implementation to get it to link.
+inline bool
+__uncaught_exception()
+{
+    return true;
+}
+#endif

Added: lldb/trunk/gtest/unittest/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/unittest/CMakeLists.txt?rev=232210&view=auto
==============================================================================
--- lldb/trunk/gtest/unittest/CMakeLists.txt (added)
+++ lldb/trunk/gtest/unittest/CMakeLists.txt Fri Mar 13 15:54:21 2015
@@ -0,0 +1,3 @@
+add_subdirectory(Host)
+add_subdirectory(Plugins)
+add_subdirectory(Utility)

Added: lldb/trunk/gtest/unittest/Host/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/unittest/Host/CMakeLists.txt?rev=232210&view=auto
==============================================================================
--- lldb/trunk/gtest/unittest/Host/CMakeLists.txt (added)
+++ lldb/trunk/gtest/unittest/Host/CMakeLists.txt Fri Mar 13 15:54:21 2015
@@ -0,0 +1,5 @@
+add_lldb_unittest(HostTests
+  SocketAddressTest.cpp
+  SocketTest.cpp
+  SocketTestMock.cpp
+  )

Added: lldb/trunk/gtest/unittest/Plugins/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/unittest/Plugins/CMakeLists.txt?rev=232210&view=auto
==============================================================================
--- lldb/trunk/gtest/unittest/Plugins/CMakeLists.txt (added)
+++ lldb/trunk/gtest/unittest/Plugins/CMakeLists.txt Fri Mar 13 15:54:21 2015
@@ -0,0 +1 @@
+add_subdirectory(Process)

Added: lldb/trunk/gtest/unittest/Plugins/Process/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/unittest/Plugins/Process/CMakeLists.txt?rev=232210&view=auto
==============================================================================
--- lldb/trunk/gtest/unittest/Plugins/Process/CMakeLists.txt (added)
+++ lldb/trunk/gtest/unittest/Plugins/Process/CMakeLists.txt Fri Mar 13 15:54:21 2015
@@ -0,0 +1,3 @@
+if (CMAKE_SYSTEM_NAME MATCHES "Linux")
+  add_subdirectory(Linux)
+endif()

Added: lldb/trunk/gtest/unittest/Plugins/Process/Linux/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/unittest/Plugins/Process/Linux/CMakeLists.txt?rev=232210&view=auto
==============================================================================
--- lldb/trunk/gtest/unittest/Plugins/Process/Linux/CMakeLists.txt (added)
+++ lldb/trunk/gtest/unittest/Plugins/Process/Linux/CMakeLists.txt Fri Mar 13 15:54:21 2015
@@ -0,0 +1,4 @@
+add_lldb_unittest(ProcessLinuxTests
+  ThreadStateCoordinatorTest.cpp
+  ThreadStatecoordinatorMock.cpp
+  )

Added: lldb/trunk/gtest/unittest/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/gtest/unittest/Utility/CMakeLists.txt?rev=232210&view=auto
==============================================================================
--- lldb/trunk/gtest/unittest/Utility/CMakeLists.txt (added)
+++ lldb/trunk/gtest/unittest/Utility/CMakeLists.txt Fri Mar 13 15:54:21 2015
@@ -0,0 +1,4 @@
+add_lldb_unittest(UtilityTests
+  StringExtractorTest.cpp
+  UriParserTest.cpp
+  )





More information about the lldb-commits mailing list