OSDN Git Service

[CMake] Fix pthread handling for out-of-tree builds
[android-x86/external-llvm.git] / utils / unittest / CMakeLists.txt
1 ########################################################################
2 # Experimental CMake build script for Google Test.
3 #
4 # Consider this a prototype.  It will change drastically.  For now,
5 # this is only for people on the cutting edge.
6 #
7 # To run the tests for Google Test itself on Linux, use 'make test' or
8 # ctest.  You can select which tests to run using 'ctest -R regex'.
9 # For more options, run 'ctest --help'.
10 ########################################################################
11 #
12 # Project-wide settings
13
14 # Where gtest's .h files can be found.
15 include_directories(
16   googletest/include
17   googletest
18   googlemock/include
19   googlemock
20   )
21
22 if(WIN32)
23   add_definitions(-DGTEST_OS_WINDOWS=1)
24 endif()
25
26 if(SUPPORTS_VARIADIC_MACROS_FLAG)
27   add_definitions("-Wno-variadic-macros")
28 endif()
29 if(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG)
30   add_definitions("-Wno-gnu-zero-variadic-macro-arguments")
31 endif()
32 if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
33   add_definitions("-Wno-covered-switch-default")
34 endif()
35
36 set(LLVM_REQUIRES_RTTI 1)
37 add_definitions( -DGTEST_HAS_RTTI=0 )
38
39 if (NOT LLVM_ENABLE_THREADS)
40   add_definitions( -DGTEST_HAS_PTHREAD=0 )
41 endif()
42
43 find_library(LLVM_PTHREAD_LIBRARY_PATH pthread)
44 if (LLVM_PTHREAD_LIBRARY_PATH)
45   list(APPEND LIBS pthread)
46 endif()
47
48 add_llvm_library(gtest
49   googletest/src/gtest-all.cc
50   googlemock/src/gmock-all.cc
51
52   LINK_LIBS
53   ${LIBS}
54
55   LINK_COMPONENTS
56   Support # Depends on llvm::raw_ostream
57
58   # This is a library meant only for the build tree.
59   BUILDTREE_ONLY
60 )
61
62 add_subdirectory(UnitTestMain)