/testlibs/gmock/CMakeLists.txt

https://github.com/deltaforge/nebu-app-mongo · CMake · 151 lines · 60 code · 28 blank · 63 comment · 4 complexity · ad0d472573cb9200a07305b41ffade42 MD5 · raw file

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