blob: 5b5cbf5d745f9b52921f7f6fce451b90a47b216f [file] [log] [blame]
Michael J. Spencer10d274d2010-09-24 09:01:13 +00001########################################################################
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.
15include_directories(
16 googletest/include
Chandler Carruth7c92fbb2013-11-15 10:20:45 +000017 googletest
Chandler Carruthbf6a4e02017-01-10 22:32:26 +000018 googlemock/include
19 googlemock
Michael J. Spencer10d274d2010-09-24 09:01:13 +000020 )
21
Zachary Turner94f50322017-10-27 21:12:28 +000022# LLVM requires C++11 but gtest doesn't correctly detect the availability
23# of C++11 on MSVC, so we force it on.
24add_definitions(-DGTEST_LANG_CXX11=1)
25add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
26
Michael J. Spencer10d274d2010-09-24 09:01:13 +000027if(WIN32)
28 add_definitions(-DGTEST_OS_WINDOWS=1)
29endif()
30
Chandler Carruth25657e82017-01-06 23:16:00 +000031if(SUPPORTS_VARIADIC_MACROS_FLAG)
Michael J. Spencer33a390e2010-10-07 18:12:54 +000032 add_definitions("-Wno-variadic-macros")
33endif()
Chandler Carruth25657e82017-01-06 23:16:00 +000034if(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG)
Chandler Carrutha9775822017-01-04 23:06:03 +000035 add_definitions("-Wno-gnu-zero-variadic-macro-arguments")
36endif()
37if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
38 add_definitions("-Wno-covered-switch-default")
39endif()
Michael J. Spencer33a390e2010-10-07 18:12:54 +000040
Oscar Fuentes889c1e72010-10-17 02:26:16 +000041set(LLVM_REQUIRES_RTTI 1)
42add_definitions( -DGTEST_HAS_RTTI=0 )
Oscar Fuentes889c1e72010-10-17 02:26:16 +000043
Duncan Sandsb33790d2013-05-14 13:29:16 +000044if (NOT LLVM_ENABLE_THREADS)
45 add_definitions( -DGTEST_HAS_PTHREAD=0 )
46endif()
47
Eric Fiselier87c87f42017-02-10 01:59:20 +000048find_library(LLVM_PTHREAD_LIBRARY_PATH pthread)
49if (LLVM_PTHREAD_LIBRARY_PATH)
Rafael Espindolacb274c02015-01-20 21:23:15 +000050 list(APPEND LIBS pthread)
51endif()
52
Oscar Fuentes46d8a932010-09-25 20:25:25 +000053add_llvm_library(gtest
Chandler Carruth7c92fbb2013-11-15 10:20:45 +000054 googletest/src/gtest-all.cc
Chandler Carruthbf6a4e02017-01-10 22:32:26 +000055 googlemock/src/gmock-all.cc
Michael J. Spencer10d274d2010-09-24 09:01:13 +000056
NAKAMURA Takumi96986862014-02-26 06:41:29 +000057 LINK_LIBS
Rafael Espindolacb274c02015-01-20 21:23:15 +000058 ${LIBS}
Andrew Wilkins095e22d2016-02-12 01:42:43 +000059
60 LINK_COMPONENTS
61 Support # Depends on llvm::raw_ostream
Michael Gottesman31e93632016-09-09 19:45:34 +000062
63 # This is a library meant only for the build tree.
64 BUILDTREE_ONLY
Rafael Espindolacb274c02015-01-20 21:23:15 +000065)
NAKAMURA Takumi0dc73df2014-02-10 11:27:41 +000066
NAKAMURA Takumi1f5cf852014-01-10 11:02:26 +000067add_subdirectory(UnitTestMain)