Create a CMake build for the gtest unit tests.
authorZachary Turner <zturner@google.com>
Fri, 13 Mar 2015 20:54:21 +0000 (20:54 +0000)
committerZachary Turner <zturner@google.com>
Fri, 13 Mar 2015 20:54:21 +0000 (20:54 +0000)
llvm-svn: 232210

lldb/CMakeLists.txt
lldb/cmake/modules/LLDBConfig.cmake
lldb/gtest/CMakeLists.txt [new file with mode: 0644]
lldb/gtest/include/gtest_common.h [new file with mode: 0644]
lldb/gtest/unittest/CMakeLists.txt [new file with mode: 0644]
lldb/gtest/unittest/Host/CMakeLists.txt [new file with mode: 0644]
lldb/gtest/unittest/Plugins/CMakeLists.txt [new file with mode: 0644]
lldb/gtest/unittest/Plugins/Process/CMakeLists.txt [new file with mode: 0644]
lldb/gtest/unittest/Plugins/Process/Linux/CMakeLists.txt [new file with mode: 0644]
lldb/gtest/unittest/Utility/CMakeLists.txt [new file with mode: 0644]

index fa98bd3..4629f40 100644 (file)
@@ -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 )
index adfe804..a678eb5 100644 (file)
@@ -25,7 +25,7 @@ set(LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION ${LLDB_DEFAULT_ENABLE_PYTHON_
   "Enables using new Python scripts for SWIG API generation .")  \r
 \r
 set(LLDB_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/source")\r
-set(LLDB_INCLUDE_ROOT "${LLDB_INCLUDE_ROOT}/include")\r
+set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include")\r
 \r
 set(LLDB_DISABLE_PYTHON 0 CACHE BOOL "Disables the Python scripting integration.")\r
 \r
diff --git a/lldb/gtest/CMakeLists.txt b/lldb/gtest/CMakeLists.txt
new file mode 100644 (file)
index 0000000..467dd12
--- /dev/null
@@ -0,0 +1,21 @@
+add_custom_target(LLDBUnitTests)\r
+set_target_properties(LLDBUnitTests PROPERTIES FOLDER "LLDB tests")\r
+\r
+include_directories(${LLDB_SOURCE_ROOT})\r
+\r
+set(LLDB_GTEST_COMMON_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include/gtest_common.h)\r
+if (MSVC)\r
+  list(APPEND LLVM_COMPILE_FLAGS /FI ${LLDB_GTEST_COMMON_INCLUDE})\r
+else ()\r
+  list(APPEND LLVM_COMPILE_FLAGS -include ${LLDB_GTEST_COMMON_INCLUDE})\r
+endif ()\r
+\r
+# add_lldb_unittest(test_dirname file1.cpp file2.cpp)\r
+#\r
+# Will compile the list of files together and link against the liblldb\r
+function(add_lldb_unittest test_name)\r
+  add_unittest(LLDBUnitTests ${test_name} ${ARGN})\r
+  target_link_libraries(${test_name} liblldb)\r
+endfunction()\r
+\r
+add_subdirectory(unittest)\r
diff --git a/lldb/gtest/include/gtest_common.h b/lldb/gtest/include/gtest_common.h
new file mode 100644 (file)
index 0000000..228dfb0
--- /dev/null
@@ -0,0 +1,32 @@
+//===-- gtest_common.h ------------------------------------------*- C++ -*-===//\r
+//\r
+//                     The LLVM Compiler Infrastructure\r
+//\r
+// This file is distributed under the University of Illinois Open Source\r
+// License. See LICENSE.TXT for details.\r
+//\r
+//===----------------------------------------------------------------------===//\r
+\r
+#if defined(LLDB_GTEST_COMMON_H)\r
+#error "gtest_common.h should not be included manually."\r
+#else\r
+#define LLDB_GTEST_COMMON_H\r
+#endif\r
+\r
+// This header file is force included by all of LLDB's unittest compilation\r
+// units.  Be very leary about putting anything in this file.\r
+\r
+#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)\r
+// MSVC's STL implementation tries to work well with /EHs-c- and\r
+// _HAS_EXCEPTIONS=0.  But <thread> in particular doesn't work with it, because\r
+// it relies on <concrt.h> which tries to throw an exception without checking\r
+// for _HAS_EXCEPTIONS=0.  This causes the linker to require a definition of\r
+// __uncaught_exception(), but the STL doesn't define this function when\r
+// _HAS_EXCEPTIONS=0.  The workaround here is to just provide a stub\r
+// implementation to get it to link.\r
+inline bool\r
+__uncaught_exception()\r
+{\r
+    return true;\r
+}\r
+#endif\r
diff --git a/lldb/gtest/unittest/CMakeLists.txt b/lldb/gtest/unittest/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fd57dd9
--- /dev/null
@@ -0,0 +1,3 @@
+add_subdirectory(Host)\r
+add_subdirectory(Plugins)\r
+add_subdirectory(Utility)\r
diff --git a/lldb/gtest/unittest/Host/CMakeLists.txt b/lldb/gtest/unittest/Host/CMakeLists.txt
new file mode 100644 (file)
index 0000000..227e48c
--- /dev/null
@@ -0,0 +1,5 @@
+add_lldb_unittest(HostTests\r
+  SocketAddressTest.cpp\r
+  SocketTest.cpp\r
+  SocketTestMock.cpp\r
+  )\r
diff --git a/lldb/gtest/unittest/Plugins/CMakeLists.txt b/lldb/gtest/unittest/Plugins/CMakeLists.txt
new file mode 100644 (file)
index 0000000..422f203
--- /dev/null
@@ -0,0 +1 @@
+add_subdirectory(Process)\r
diff --git a/lldb/gtest/unittest/Plugins/Process/CMakeLists.txt b/lldb/gtest/unittest/Plugins/Process/CMakeLists.txt
new file mode 100644 (file)
index 0000000..bf3426c
--- /dev/null
@@ -0,0 +1,3 @@
+if (CMAKE_SYSTEM_NAME MATCHES "Linux")\r
+  add_subdirectory(Linux)\r
+endif()\r
diff --git a/lldb/gtest/unittest/Plugins/Process/Linux/CMakeLists.txt b/lldb/gtest/unittest/Plugins/Process/Linux/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3d71f9a
--- /dev/null
@@ -0,0 +1,4 @@
+add_lldb_unittest(ProcessLinuxTests\r
+  ThreadStateCoordinatorTest.cpp\r
+  ThreadStatecoordinatorMock.cpp\r
+  )\r
diff --git a/lldb/gtest/unittest/Utility/CMakeLists.txt b/lldb/gtest/unittest/Utility/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fea0f53
--- /dev/null
@@ -0,0 +1,4 @@
+add_lldb_unittest(UtilityTests\r
+  StringExtractorTest.cpp\r
+  UriParserTest.cpp\r
+  )\r