Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

250 lines
8.8 KiB

  1. ########################################################################
  2. # CMake build script for Google Test.
  3. #
  4. # To run the tests for Google Test 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. # When other libraries are using a shared version of runtime libraries,
  11. # Google Test also has to use one.
  12. option(
  13. gtest_force_shared_crt
  14. "Use shared (DLL) run-time lib even when Google Test is built as static lib."
  15. OFF)
  16. option(gtest_build_tests "Build all of gtest's own tests." OFF)
  17. option(gtest_build_samples "Build gtest's sample programs." OFF)
  18. option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
  19. # Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
  20. include(cmake/hermetic_build.cmake OPTIONAL)
  21. if (COMMAND pre_project_set_up_hermetic_build)
  22. pre_project_set_up_hermetic_build()
  23. endif()
  24. ########################################################################
  25. #
  26. # Project-wide settings
  27. # Name of the project.
  28. #
  29. # CMake files in this project can refer to the root source directory
  30. # as ${gtest_SOURCE_DIR} and to the root binary directory as
  31. # ${gtest_BINARY_DIR}.
  32. # Language "C" is required for find_package(Threads).
  33. project(gtest CXX C)
  34. cmake_minimum_required(VERSION 2.6.2)
  35. if (COMMAND set_up_hermetic_build)
  36. set_up_hermetic_build()
  37. endif()
  38. # Define helper functions and macros used by Google Test.
  39. include(cmake/internal_utils.cmake)
  40. config_compiler_and_linker() # Defined in internal_utils.cmake.
  41. # Where Google Test's .h files can be found.
  42. include_directories(
  43. ${gtest_SOURCE_DIR}/include
  44. ${gtest_SOURCE_DIR})
  45. # Where Google Test's libraries can be found.
  46. link_directories(${gtest_BINARY_DIR}/src)
  47. ########################################################################
  48. #
  49. # Defines the gtest & gtest_main libraries. User tests should link
  50. # with one of them.
  51. # Google Test libraries. We build them using more strict warnings than what
  52. # are used for other targets, to ensure that gtest can be compiled by a user
  53. # aggressive about warnings.
  54. cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
  55. cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
  56. target_link_libraries(gtest_main gtest)
  57. ########################################################################
  58. #
  59. # Samples on how to link user tests with gtest or gtest_main.
  60. #
  61. # They are not built by default. To build them, set the
  62. # gtest_build_samples option to ON. You can do it by running ccmake
  63. # or specifying the -Dbuild_gtest_samples=ON flag when running cmake.
  64. if (gtest_build_samples)
  65. cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc)
  66. cxx_executable(sample2_unittest samples gtest_main samples/sample2.cc)
  67. cxx_executable(sample3_unittest samples gtest_main)
  68. cxx_executable(sample4_unittest samples gtest_main samples/sample4.cc)
  69. cxx_executable(sample5_unittest samples gtest_main samples/sample1.cc)
  70. cxx_executable(sample6_unittest samples gtest_main)
  71. cxx_executable(sample7_unittest samples gtest_main)
  72. cxx_executable(sample8_unittest samples gtest_main)
  73. cxx_executable(sample9_unittest samples gtest)
  74. cxx_executable(sample10_unittest samples gtest)
  75. endif()
  76. ########################################################################
  77. #
  78. # Google Test's own tests.
  79. #
  80. # You can skip this section if you aren't interested in testing
  81. # Google Test itself.
  82. #
  83. # The tests are not built by default. To build them, set the
  84. # gtest_build_tests option to ON. You can do it by running ccmake
  85. # or specifying the -Dgtest_build_tests=ON flag when running cmake.
  86. if (gtest_build_tests)
  87. # This must be set in the root directory for the tests to be run by
  88. # 'make test' or ctest.
  89. enable_testing()
  90. ############################################################
  91. # C++ tests built with standard compiler flags.
  92. cxx_test(gtest-death-test_test gtest_main)
  93. cxx_test(gtest_environment_test gtest)
  94. cxx_test(gtest-filepath_test gtest_main)
  95. cxx_test(gtest-linked_ptr_test gtest_main)
  96. cxx_test(gtest-listener_test gtest_main)
  97. cxx_test(gtest_main_unittest gtest_main)
  98. cxx_test(gtest-message_test gtest_main)
  99. cxx_test(gtest_no_test_unittest gtest)
  100. cxx_test(gtest-options_test gtest_main)
  101. cxx_test(gtest-param-test_test gtest
  102. test/gtest-param-test2_test.cc)
  103. cxx_test(gtest-port_test gtest_main)
  104. cxx_test(gtest_pred_impl_unittest gtest_main)
  105. cxx_test(gtest-printers_test gtest_main)
  106. cxx_test(gtest_prod_test gtest_main
  107. test/production.cc)
  108. cxx_test(gtest_repeat_test gtest)
  109. cxx_test(gtest_sole_header_test gtest_main)
  110. cxx_test(gtest_stress_test gtest)
  111. cxx_test(gtest-test-part_test gtest_main)
  112. cxx_test(gtest_throw_on_failure_ex_test gtest)
  113. cxx_test(gtest-typed-test_test gtest_main
  114. test/gtest-typed-test2_test.cc)
  115. cxx_test(gtest_unittest gtest_main)
  116. cxx_test(gtest-unittest-api_test gtest)
  117. ############################################################
  118. # C++ tests built with non-standard compiler flags.
  119. # MSVC 7.1 does not support STL with exceptions disabled.
  120. if (NOT MSVC OR MSVC_VERSION GREATER 1310)
  121. cxx_library(gtest_no_exception "${cxx_no_exception}"
  122. src/gtest-all.cc)
  123. cxx_library(gtest_main_no_exception "${cxx_no_exception}"
  124. src/gtest-all.cc src/gtest_main.cc)
  125. endif()
  126. cxx_library(gtest_main_no_rtti "${cxx_no_rtti}"
  127. src/gtest-all.cc src/gtest_main.cc)
  128. cxx_test_with_flags(gtest-death-test_ex_nocatch_test
  129. "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=0"
  130. gtest test/gtest-death-test_ex_test.cc)
  131. cxx_test_with_flags(gtest-death-test_ex_catch_test
  132. "${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1"
  133. gtest test/gtest-death-test_ex_test.cc)
  134. cxx_test_with_flags(gtest_no_rtti_unittest "${cxx_no_rtti}"
  135. gtest_main_no_rtti test/gtest_unittest.cc)
  136. cxx_shared_library(gtest_dll "${cxx_default}"
  137. src/gtest-all.cc src/gtest_main.cc)
  138. cxx_executable_with_flags(gtest_dll_test_ "${cxx_default}"
  139. gtest_dll test/gtest_all_test.cc)
  140. set_target_properties(gtest_dll_test_
  141. PROPERTIES
  142. COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
  143. if (NOT MSVC OR NOT MSVC_VERSION EQUAL 1600)
  144. # The C++ Standard specifies tuple_element<int, class>.
  145. # Yet MSVC 10's <utility> declares tuple_element<size_t, class>.
  146. # That declaration conflicts with our own standard-conforming
  147. # tuple implementation. Therefore using our own tuple with
  148. # MSVC 10 doesn't compile.
  149. cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
  150. src/gtest-all.cc src/gtest_main.cc)
  151. cxx_test_with_flags(gtest-tuple_test "${cxx_use_own_tuple}"
  152. gtest_main_use_own_tuple test/gtest-tuple_test.cc)
  153. cxx_test_with_flags(gtest_use_own_tuple_test "${cxx_use_own_tuple}"
  154. gtest_main_use_own_tuple
  155. test/gtest-param-test_test.cc test/gtest-param-test2_test.cc)
  156. endif()
  157. ############################################################
  158. # Python tests.
  159. cxx_executable(gtest_break_on_failure_unittest_ test gtest)
  160. py_test(gtest_break_on_failure_unittest)
  161. # MSVC 7.1 does not support STL with exceptions disabled.
  162. if (NOT MSVC OR MSVC_VERSION GREATER 1310)
  163. cxx_executable_with_flags(
  164. gtest_catch_exceptions_no_ex_test_
  165. "${cxx_no_exception}"
  166. gtest_main_no_exception
  167. test/gtest_catch_exceptions_test_.cc)
  168. endif()
  169. cxx_executable_with_flags(
  170. gtest_catch_exceptions_ex_test_
  171. "${cxx_exception}"
  172. gtest_main
  173. test/gtest_catch_exceptions_test_.cc)
  174. py_test(gtest_catch_exceptions_test)
  175. cxx_executable(gtest_color_test_ test gtest)
  176. py_test(gtest_color_test)
  177. cxx_executable(gtest_env_var_test_ test gtest)
  178. py_test(gtest_env_var_test)
  179. cxx_executable(gtest_filter_unittest_ test gtest)
  180. py_test(gtest_filter_unittest)
  181. cxx_executable(gtest_help_test_ test gtest_main)
  182. py_test(gtest_help_test)
  183. cxx_executable(gtest_list_tests_unittest_ test gtest)
  184. py_test(gtest_list_tests_unittest)
  185. cxx_executable(gtest_output_test_ test gtest)
  186. py_test(gtest_output_test)
  187. cxx_executable(gtest_shuffle_test_ test gtest)
  188. py_test(gtest_shuffle_test)
  189. # MSVC 7.1 does not support STL with exceptions disabled.
  190. if (NOT MSVC OR MSVC_VERSION GREATER 1310)
  191. cxx_executable(gtest_throw_on_failure_test_ test gtest_no_exception)
  192. set_target_properties(gtest_throw_on_failure_test_
  193. PROPERTIES
  194. COMPILE_FLAGS "${cxx_no_exception}")
  195. py_test(gtest_throw_on_failure_test)
  196. endif()
  197. cxx_executable(gtest_uninitialized_test_ test gtest)
  198. py_test(gtest_uninitialized_test)
  199. cxx_executable(gtest_xml_outfile1_test_ test gtest_main)
  200. cxx_executable(gtest_xml_outfile2_test_ test gtest_main)
  201. py_test(gtest_xml_outfiles_test)
  202. cxx_executable(gtest_xml_output_unittest_ test gtest)
  203. py_test(gtest_xml_output_unittest)
  204. endif()