Warning, /JETSCAPE/external_packages/googletest/googlemock/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 ########################################################################
0002 # CMake build script for Google Mock.
0003 #
0004 # To run the tests for Google Mock itself on Linux, use 'make test' or
0005 # ctest. You can select which tests to run using 'ctest -R regex'.
0006 # For more options, run 'ctest --help'.
0007
0008 # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
0009 # make it prominent in the GUI.
0010 option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
0011
0012 option(gmock_build_tests "Build all of Google Mock's own tests." OFF)
0013
0014 # A directory to find Google Test sources.
0015 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gtest/CMakeLists.txt")
0016 set(gtest_dir gtest)
0017 else()
0018 set(gtest_dir ../googletest)
0019 endif()
0020
0021 # Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
0022 include("${gtest_dir}/cmake/hermetic_build.cmake" OPTIONAL)
0023
0024 if (COMMAND pre_project_set_up_hermetic_build)
0025 # Google Test also calls hermetic setup functions from add_subdirectory,
0026 # although its changes will not affect things at the current scope.
0027 pre_project_set_up_hermetic_build()
0028 endif()
0029
0030 ########################################################################
0031 #
0032 # Project-wide settings
0033
0034 # Name of the project.
0035 #
0036 # CMake files in this project can refer to the root source directory
0037 # as ${gmock_SOURCE_DIR} and to the root binary directory as
0038 # ${gmock_BINARY_DIR}.
0039 # Language "C" is required for find_package(Threads).
0040 project(gmock CXX C)
0041 cmake_minimum_required(VERSION 2.6.4)
0042
0043 if (COMMAND set_up_hermetic_build)
0044 set_up_hermetic_build()
0045 endif()
0046
0047 # Instructs CMake to process Google Test's CMakeLists.txt and add its
0048 # targets to the current scope. We are placing Google Test's binary
0049 # directory in a subdirectory of our own as VC compilation may break
0050 # if they are the same (the default).
0051 add_subdirectory("${gtest_dir}" "${gmock_BINARY_DIR}/gtest")
0052
0053 # Although Google Test's CMakeLists.txt calls this function, the
0054 # changes there don't affect the current scope. Therefore we have to
0055 # call it again here.
0056 config_compiler_and_linker() # from ${gtest_dir}/cmake/internal_utils.cmake
0057
0058 # Adds Google Mock's and Google Test's header directories to the search path.
0059 include_directories("${gmock_SOURCE_DIR}/include"
0060 "${gmock_SOURCE_DIR}"
0061 "${gtest_SOURCE_DIR}/include"
0062 # This directory is needed to build directly from Google
0063 # Test sources.
0064 "${gtest_SOURCE_DIR}")
0065
0066 # Summary of tuple support for Microsoft Visual Studio:
0067 # Compiler version(MS) version(cmake) Support
0068 # ---------- ----------- -------------- -----------------------------
0069 # <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple.
0070 # VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10
0071 # VS 2013 12 1800 std::tr1::tuple
0072 if (MSVC AND MSVC_VERSION EQUAL 1700)
0073 add_definitions(/D _VARIADIC_MAX=10)
0074 endif()
0075
0076 ########################################################################
0077 #
0078 # Defines the gmock & gmock_main libraries. User tests should link
0079 # with one of them.
0080
0081 # Google Mock libraries. We build them using more strict warnings than what
0082 # are used for other targets, to ensure that Google Mock can be compiled by
0083 # a user aggressive about warnings.
0084 cxx_library(gmock
0085 "${cxx_strict}"
0086 "${gtest_dir}/src/gtest-all.cc"
0087 src/gmock-all.cc)
0088
0089 cxx_library(gmock_main
0090 "${cxx_strict}"
0091 "${gtest_dir}/src/gtest-all.cc"
0092 src/gmock-all.cc
0093 src/gmock_main.cc)
0094
0095 # If the CMake version supports it, attach header directory information
0096 # to the targets for when we are part of a parent build (ie being pulled
0097 # in via add_subdirectory() rather than being a standalone build).
0098 if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
0099 target_include_directories(gmock INTERFACE "${gmock_SOURCE_DIR}/include")
0100 target_include_directories(gmock_main INTERFACE "${gmock_SOURCE_DIR}/include")
0101 endif()
0102
0103 ########################################################################
0104 #
0105 # Install rules
0106 install(TARGETS gmock gmock_main
0107 DESTINATION lib)
0108 install(DIRECTORY ${gmock_SOURCE_DIR}/include/gmock
0109 DESTINATION include)
0110
0111 ########################################################################
0112 #
0113 # Google Mock's own tests.
0114 #
0115 # You can skip this section if you aren't interested in testing
0116 # Google Mock itself.
0117 #
0118 # The tests are not built by default. To build them, set the
0119 # gmock_build_tests option to ON. You can do it by running ccmake
0120 # or specifying the -Dgmock_build_tests=ON flag when running cmake.
0121
0122 if (gmock_build_tests)
0123 # This must be set in the root directory for the tests to be run by
0124 # 'make test' or ctest.
0125 enable_testing()
0126
0127 ############################################################
0128 # C++ tests built with standard compiler flags.
0129
0130 cxx_test(gmock-actions_test gmock_main)
0131 cxx_test(gmock-cardinalities_test gmock_main)
0132 cxx_test(gmock_ex_test gmock_main)
0133 cxx_test(gmock-generated-actions_test gmock_main)
0134 cxx_test(gmock-generated-function-mockers_test gmock_main)
0135 cxx_test(gmock-generated-internal-utils_test gmock_main)
0136 cxx_test(gmock-generated-matchers_test gmock_main)
0137 cxx_test(gmock-internal-utils_test gmock_main)
0138 cxx_test(gmock-matchers_test gmock_main)
0139 cxx_test(gmock-more-actions_test gmock_main)
0140 cxx_test(gmock-nice-strict_test gmock_main)
0141 cxx_test(gmock-port_test gmock_main)
0142 cxx_test(gmock-spec-builders_test gmock_main)
0143 cxx_test(gmock_link_test gmock_main test/gmock_link2_test.cc)
0144 cxx_test(gmock_test gmock_main)
0145
0146 if (CMAKE_USE_PTHREADS_INIT)
0147 cxx_test(gmock_stress_test gmock)
0148 endif()
0149
0150 # gmock_all_test is commented to save time building and running tests.
0151 # Uncomment if necessary.
0152 # cxx_test(gmock_all_test gmock_main)
0153
0154 ############################################################
0155 # C++ tests built with non-standard compiler flags.
0156
0157 cxx_library(gmock_main_no_exception "${cxx_no_exception}"
0158 "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
0159
0160 cxx_library(gmock_main_no_rtti "${cxx_no_rtti}"
0161 "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
0162
0163 if (NOT MSVC OR MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
0164 # Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
0165 # conflict with our own definitions. Therefore using our own tuple does not
0166 # work on those compilers.
0167 cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}"
0168 "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
0169
0170 cxx_test_with_flags(gmock_use_own_tuple_test "${cxx_use_own_tuple}"
0171 gmock_main_use_own_tuple test/gmock-spec-builders_test.cc)
0172 endif()
0173
0174 cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}"
0175 gmock_main_no_exception test/gmock-more-actions_test.cc)
0176
0177 cxx_test_with_flags(gmock_no_rtti_test "${cxx_no_rtti}"
0178 gmock_main_no_rtti test/gmock-spec-builders_test.cc)
0179
0180 cxx_shared_library(shared_gmock_main "${cxx_default}"
0181 "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
0182
0183 # Tests that a binary can be built with Google Mock as a shared library. On
0184 # some system configurations, it may not possible to run the binary without
0185 # knowing more details about the system configurations. We do not try to run
0186 # this binary. To get a more robust shared library coverage, configure with
0187 # -DBUILD_SHARED_LIBS=ON.
0188 cxx_executable_with_flags(shared_gmock_test_ "${cxx_default}"
0189 shared_gmock_main test/gmock-spec-builders_test.cc)
0190 set_target_properties(shared_gmock_test_
0191 PROPERTIES
0192 COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
0193
0194 ############################################################
0195 # Python tests.
0196
0197 cxx_executable(gmock_leak_test_ test gmock_main)
0198 py_test(gmock_leak_test)
0199
0200 cxx_executable(gmock_output_test_ test gmock)
0201 py_test(gmock_output_test)
0202 endif()