| OLD | NEW |
| (Empty) |
| 1 ######################################################################## | |
| 2 # Experimental CMake build script for Google Mock. | |
| 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 Mock 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 # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to | |
| 12 # make it prominent in the GUI. | |
| 13 option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) | |
| 14 | |
| 15 # Forses BUILD_SHARED_LIBS to OFF as Google Mock currently does not support | |
| 16 # working in a DLL. | |
| 17 # TODO(vladl@google.com): Implement building gMock as a DLL. | |
| 18 set(BUILD_SHARED_LIBS OFF) | |
| 19 | |
| 20 option(gmock_build_tests "Build all of Google Mock's own tests." OFF) | |
| 21 | |
| 22 # A directory to find Google Test sources. | |
| 23 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gtest/CMakeLists.txt") | |
| 24 set(gtest_dir gtest) | |
| 25 else() | |
| 26 set(gtest_dir ../gtest) | |
| 27 endif() | |
| 28 | |
| 29 include("${gtest_dir}/cmake/hermetic_build.cmake" OPTIONAL) | |
| 30 | |
| 31 if (COMMAND pre_project_set_up_hermetic_build) | |
| 32 # Google Test also calls hermetic setup functions from add_subdirectory, | |
| 33 # although its changes will not affect things at the current scope. | |
| 34 pre_project_set_up_hermetic_build() | |
| 35 endif() | |
| 36 | |
| 37 ######################################################################## | |
| 38 # | |
| 39 # Project-wide settings | |
| 40 | |
| 41 # Name of the project. | |
| 42 # | |
| 43 # CMake files in this project can refer to the root source directory | |
| 44 # as ${gmock_SOURCE_DIR} and to the root binary directory as | |
| 45 # ${gmock_BINARY_DIR}. | |
| 46 # Language "C" is required for find_package(Threads). | |
| 47 project(gmock CXX C) | |
| 48 cmake_minimum_required(VERSION 2.6.2) | |
| 49 | |
| 50 if (COMMAND set_up_hermetic_build) | |
| 51 set_up_hermetic_build() | |
| 52 endif() | |
| 53 | |
| 54 # Defines functions and variables used by Google Mock. | |
| 55 include("${gtest_dir}/cmake/internal_utils.cmake") | |
| 56 | |
| 57 # Google Test also calls this function from add_subdirectory, | |
| 58 # although its changes will not affect things at the current scope. | |
| 59 fix_default_settings() # Defined in internal_utils.cmake. | |
| 60 | |
| 61 # Instructs CMake to process Google Test's CMakeLists.txt and add its | |
| 62 # targets to the current scope. We are placing Google Test's binary | |
| 63 # directory in a subdirectory of our own as VC compilation may break if they | |
| 64 # are the same (the default). | |
| 65 add_subdirectory("${gtest_dir}" "${gmock_BINARY_DIR}/gtest") | |
| 66 | |
| 67 # Adds Google Mock's and Google Test's header directories to the search path. | |
| 68 include_directories("${gmock_SOURCE_DIR}/include" | |
| 69 "${gmock_SOURCE_DIR}" | |
| 70 "${gtest_SOURCE_DIR}/include" | |
| 71 # This directory is needed to build directly from Google | |
| 72 # Test sources. | |
| 73 "${gtest_SOURCE_DIR}") | |
| 74 | |
| 75 ######################################################################## | |
| 76 # | |
| 77 # Defines the gmock & gmock_main libraries. User tests should link | |
| 78 # with one of them. | |
| 79 | |
| 80 # Google Mock libraries. We build them using more strict warnings than what | |
| 81 # are used for other targets, to ensure that Google Mock can be compiled by | |
| 82 # a user aggressive about warnings. | |
| 83 cxx_library(gmock "${cxx_strict}" src/gmock-all.cc) | |
| 84 target_link_libraries(gmock gtest) | |
| 85 | |
| 86 cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc) | |
| 87 target_link_libraries(gmock_main gmock) | |
| 88 | |
| 89 ######################################################################## | |
| 90 # | |
| 91 # Google Mock's own tests. | |
| 92 # | |
| 93 # You can skip this section if you aren't interested in testing | |
| 94 # Google Mock itself. | |
| 95 # | |
| 96 # The tests are not built by default. To build them, set the | |
| 97 # gmock_build_tests option to ON. You can do it by running ccmake | |
| 98 # or specifying the -Dgmock_build_tests=ON flag when running cmake. | |
| 99 | |
| 100 if (gmock_build_tests) | |
| 101 # This must be set in the root directory for the tests to be run by | |
| 102 # 'make test' or ctest. | |
| 103 enable_testing() | |
| 104 | |
| 105 ############################################################ | |
| 106 # C++ tests built with standard compiler flags. | |
| 107 | |
| 108 cxx_test(gmock-actions_test gmock_main) | |
| 109 cxx_test(gmock-cardinalities_test gmock_main) | |
| 110 cxx_test(gmock-generated-actions_test gmock_main) | |
| 111 cxx_test(gmock-generated-function-mockers_test gmock_main) | |
| 112 cxx_test(gmock-generated-internal-utils_test gmock_main) | |
| 113 cxx_test(gmock-generated-matchers_test gmock_main) | |
| 114 cxx_test(gmock-internal-utils_test gmock_main) | |
| 115 cxx_test(gmock-matchers_test gmock_main) | |
| 116 cxx_test(gmock-more-actions_test gmock_main) | |
| 117 cxx_test(gmock-nice-strict_test gmock_main) | |
| 118 cxx_test(gmock-port_test gmock_main) | |
| 119 cxx_test(gmock-spec-builders_test gmock_main) | |
| 120 cxx_test(gmock_link_test gmock_main test/gmock_link2_test.cc) | |
| 121 # cxx_test(gmock_stress_test gmock) | |
| 122 cxx_test(gmock_test gmock_main) | |
| 123 | |
| 124 # gmock_all_test is commented to save time building and running tests. | |
| 125 # Uncomment if necessary. | |
| 126 # cxx_test(gmock_all_test gmock_main) | |
| 127 | |
| 128 ############################################################ | |
| 129 # C++ tests built with non-standard compiler flags. | |
| 130 | |
| 131 cxx_library(gmock_main_no_exception "${cxx_no_exception}" | |
| 132 "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) | |
| 133 cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" | |
| 134 "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) | |
| 135 cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}" | |
| 136 "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc) | |
| 137 | |
| 138 cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}" | |
| 139 gmock_main_no_exception test/gmock-more-actions_test.cc) | |
| 140 | |
| 141 cxx_test_with_flags(gmock_no_rtti_test "${cxx_no_rtti}" | |
| 142 gmock_main_no_rtti test/gmock-spec-builders_test.cc) | |
| 143 | |
| 144 cxx_test_with_flags(gmock_use_own_tuple_test "${cxx_use_own_tuple}" | |
| 145 gmock_main_use_own_tuple test/gmock-spec-builders_test.cc) | |
| 146 | |
| 147 ############################################################ | |
| 148 # Python tests. | |
| 149 | |
| 150 cxx_executable(gmock_leak_test_ test gmock_main) | |
| 151 py_test(gmock_leak_test) | |
| 152 | |
| 153 cxx_executable(gmock_output_test_ test gmock) | |
| 154 py_test(gmock_output_test) | |
| 155 endif() | |
| OLD | NEW |