| Michael J. Spencer | 10d274d | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 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 |
| Chandler Carruth | 7c92fbb | 2013-11-15 10:20:45 +0000 | [diff] [blame] | 17 | googletest |
| Chandler Carruth | bf6a4e0 | 2017-01-10 22:32:26 +0000 | [diff] [blame] | 18 | googlemock/include |
| 19 | googlemock |
| Michael J. Spencer | 10d274d | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 20 | ) |
| 21 | |
| Zachary Turner | 94f5032 | 2017-10-27 21:12:28 +0000 | [diff] [blame] | 22 | # LLVM requires C++11 but gtest doesn't correctly detect the availability |
| 23 | # of C++11 on MSVC, so we force it on. |
| 24 | add_definitions(-DGTEST_LANG_CXX11=1) |
| 25 | add_definitions(-DGTEST_HAS_TR1_TUPLE=0) |
| 26 | |
| Michael J. Spencer | 10d274d | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 27 | if(WIN32) |
| 28 | add_definitions(-DGTEST_OS_WINDOWS=1) |
| 29 | endif() |
| 30 | |
| Chandler Carruth | 25657e8 | 2017-01-06 23:16:00 +0000 | [diff] [blame] | 31 | if(SUPPORTS_VARIADIC_MACROS_FLAG) |
| Michael J. Spencer | 33a390e | 2010-10-07 18:12:54 +0000 | [diff] [blame] | 32 | add_definitions("-Wno-variadic-macros") |
| 33 | endif() |
| Chandler Carruth | 25657e8 | 2017-01-06 23:16:00 +0000 | [diff] [blame] | 34 | if(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG) |
| Chandler Carruth | a977582 | 2017-01-04 23:06:03 +0000 | [diff] [blame] | 35 | add_definitions("-Wno-gnu-zero-variadic-macro-arguments") |
| 36 | endif() |
| 37 | if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG) |
| 38 | add_definitions("-Wno-covered-switch-default") |
| 39 | endif() |
| Michael J. Spencer | 33a390e | 2010-10-07 18:12:54 +0000 | [diff] [blame] | 40 | |
| Oscar Fuentes | 889c1e7 | 2010-10-17 02:26:16 +0000 | [diff] [blame] | 41 | set(LLVM_REQUIRES_RTTI 1) |
| 42 | add_definitions( -DGTEST_HAS_RTTI=0 ) |
| Oscar Fuentes | 889c1e7 | 2010-10-17 02:26:16 +0000 | [diff] [blame] | 43 | |
| Duncan Sands | b33790d | 2013-05-14 13:29:16 +0000 | [diff] [blame] | 44 | if (NOT LLVM_ENABLE_THREADS) |
| 45 | add_definitions( -DGTEST_HAS_PTHREAD=0 ) |
| 46 | endif() |
| 47 | |
| Eric Fiselier | 87c87f4 | 2017-02-10 01:59:20 +0000 | [diff] [blame] | 48 | find_library(LLVM_PTHREAD_LIBRARY_PATH pthread) |
| 49 | if (LLVM_PTHREAD_LIBRARY_PATH) |
| Rafael Espindola | cb274c0 | 2015-01-20 21:23:15 +0000 | [diff] [blame] | 50 | list(APPEND LIBS pthread) |
| 51 | endif() |
| 52 | |
| Oscar Fuentes | 46d8a93 | 2010-09-25 20:25:25 +0000 | [diff] [blame] | 53 | add_llvm_library(gtest |
| Chandler Carruth | 7c92fbb | 2013-11-15 10:20:45 +0000 | [diff] [blame] | 54 | googletest/src/gtest-all.cc |
| Chandler Carruth | bf6a4e0 | 2017-01-10 22:32:26 +0000 | [diff] [blame] | 55 | googlemock/src/gmock-all.cc |
| Michael J. Spencer | 10d274d | 2010-09-24 09:01:13 +0000 | [diff] [blame] | 56 | |
| NAKAMURA Takumi | 9698686 | 2014-02-26 06:41:29 +0000 | [diff] [blame] | 57 | LINK_LIBS |
| Rafael Espindola | cb274c0 | 2015-01-20 21:23:15 +0000 | [diff] [blame] | 58 | ${LIBS} |
| Andrew Wilkins | 095e22d | 2016-02-12 01:42:43 +0000 | [diff] [blame] | 59 | |
| 60 | LINK_COMPONENTS |
| 61 | Support # Depends on llvm::raw_ostream |
| Michael Gottesman | 31e9363 | 2016-09-09 19:45:34 +0000 | [diff] [blame] | 62 | |
| 63 | # This is a library meant only for the build tree. |
| 64 | BUILDTREE_ONLY |
| Rafael Espindola | cb274c0 | 2015-01-20 21:23:15 +0000 | [diff] [blame] | 65 | ) |
| NAKAMURA Takumi | 0dc73df | 2014-02-10 11:27:41 +0000 | [diff] [blame] | 66 | |
| NAKAMURA Takumi | 1f5cf85 | 2014-01-10 11:02:26 +0000 | [diff] [blame] | 67 | add_subdirectory(UnitTestMain) |