123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- option(gmock_build_tests "Build all of Google Mock's own tests." OFF)
- if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gtest/CMakeLists.txt")
- set(gtest_dir gtest)
- else()
- set(gtest_dir ../googletest)
- endif()
- include("${gtest_dir}/cmake/hermetic_build.cmake" OPTIONAL)
- if (COMMAND pre_project_set_up_hermetic_build)
-
-
- pre_project_set_up_hermetic_build()
- endif()
- if (CMAKE_VERSION VERSION_LESS 3.0)
- project(gmock CXX C)
- else()
- cmake_policy(SET CMP0048 NEW)
- project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
- endif()
- cmake_minimum_required(VERSION 2.8.12)
- if (COMMAND set_up_hermetic_build)
- set_up_hermetic_build()
- endif()
- add_subdirectory("${gtest_dir}" "${gmock_BINARY_DIR}/${gtest_dir}")
- if(CMAKE_PROJECT_NAME STREQUAL "gmock" OR CMAKE_PROJECT_NAME STREQUAL "googletest-distribution")
-
-
- option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
- else()
- mark_as_advanced(gmock_build_tests)
- endif()
- config_compiler_and_linker()
- set(gmock_build_include_dirs
- "${gmock_SOURCE_DIR}/include"
- "${gmock_SOURCE_DIR}"
- "${gtest_SOURCE_DIR}/include"
-
- "${gtest_SOURCE_DIR}")
- include_directories(${gmock_build_include_dirs})
- if (MSVC)
- cxx_library(gmock
- "${cxx_strict}"
- "${gtest_dir}/src/gtest-all.cc"
- src/gmock-all.cc)
- cxx_library(gmock_main
- "${cxx_strict}"
- "${gtest_dir}/src/gtest-all.cc"
- src/gmock-all.cc
- src/gmock_main.cc)
- else()
- cxx_library(gmock "${cxx_strict}" src/gmock-all.cc)
- target_link_libraries(gmock PUBLIC gtest)
- set_target_properties(gmock PROPERTIES VERSION ${GOOGLETEST_VERSION})
- cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc)
- target_link_libraries(gmock_main PUBLIC gmock)
- set_target_properties(gmock_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
- endif()
- if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
- target_include_directories(gmock SYSTEM INTERFACE
- "$<BUILD_INTERFACE:${gmock_build_include_dirs}>"
- "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
- target_include_directories(gmock_main SYSTEM INTERFACE
- "$<BUILD_INTERFACE:${gmock_build_include_dirs}>"
- "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
- endif()
- install_project(gmock gmock_main)
- if (gmock_build_tests)
-
-
- enable_testing()
- if (MINGW OR CYGWIN)
- if (CMAKE_VERSION VERSION_LESS "2.8.12")
- add_compile_options("-Wa,-mbig-obj")
- else()
- add_definitions("-Wa,-mbig-obj")
- endif()
- endif()
-
-
- cxx_test(gmock-actions_test gmock_main)
- cxx_test(gmock-cardinalities_test gmock_main)
- cxx_test(gmock_ex_test gmock_main)
- cxx_test(gmock-function-mocker_test gmock_main)
- cxx_test(gmock-internal-utils_test gmock_main)
- cxx_test(gmock-matchers_test gmock_main)
- cxx_test(gmock-more-actions_test gmock_main)
- cxx_test(gmock-nice-strict_test gmock_main)
- cxx_test(gmock-port_test gmock_main)
- cxx_test(gmock-spec-builders_test gmock_main)
- cxx_test(gmock_link_test gmock_main test/gmock_link2_test.cc)
- cxx_test(gmock_test gmock_main)
- if (DEFINED GTEST_HAS_PTHREAD)
- cxx_test(gmock_stress_test gmock)
- endif()
-
-
-
-
-
- if (MSVC)
- cxx_library(gmock_main_no_exception "${cxx_no_exception}"
- "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
- cxx_library(gmock_main_no_rtti "${cxx_no_rtti}"
- "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
- else()
- cxx_library(gmock_main_no_exception "${cxx_no_exception}" src/gmock_main.cc)
- target_link_libraries(gmock_main_no_exception PUBLIC gmock)
- cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" src/gmock_main.cc)
- target_link_libraries(gmock_main_no_rtti PUBLIC gmock)
- endif()
- cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}"
- gmock_main_no_exception test/gmock-more-actions_test.cc)
- cxx_test_with_flags(gmock_no_rtti_test "${cxx_no_rtti}"
- gmock_main_no_rtti test/gmock-spec-builders_test.cc)
- cxx_shared_library(shared_gmock_main "${cxx_default}"
- "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
-
-
-
-
-
- cxx_executable_with_flags(shared_gmock_test_ "${cxx_default}"
- shared_gmock_main test/gmock-spec-builders_test.cc)
- set_target_properties(shared_gmock_test_
- PROPERTIES
- COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
-
-
- cxx_executable(gmock_leak_test_ test gmock_main)
- py_test(gmock_leak_test)
- cxx_executable(gmock_output_test_ test gmock)
- py_test(gmock_output_test)
- endif()
|