2
0

CMakeLists.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at https://curl.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. # SPDX-License-Identifier: curl
  22. #
  23. ###########################################################################
  24. option(CURL_TEST_BUNDLES "Bundle libtests/unittests into single binaries" OFF)
  25. find_program(TEST_NGHTTPX "nghttpx")
  26. if(NOT TEST_NGHTTPX)
  27. set(TEST_NGHTTPX "nghttpx")
  28. endif()
  29. mark_as_advanced(TEST_NGHTTPX)
  30. # Consumed variables: TEST_NGHTTPX
  31. configure_file("config.in" "${CMAKE_CURRENT_BINARY_DIR}/config" @ONLY)
  32. add_custom_target(testdeps)
  33. add_subdirectory(http)
  34. add_subdirectory(http/clients)
  35. add_subdirectory(server)
  36. add_subdirectory(libtest)
  37. add_subdirectory(unit)
  38. add_subdirectory(certs EXCLUDE_FROM_ALL)
  39. function(add_runtests _targetname _test_flags)
  40. if(CURL_TEST_BUNDLES)
  41. set(_test_flags "${_test_flags} -bundle")
  42. endif()
  43. # Skip walking through dependent targets before running tests in CI.
  44. # This avoids: GNU Make doing a slow re-evaluation of all targets and
  45. # skipping them, MSBuild doing a re-evaluation, and actually rebuilding them.
  46. unset(_depends)
  47. if(NOT _targetname STREQUAL "test-ci")
  48. set(_depends "testdeps")
  49. endif()
  50. # Use a special '$TFLAGS' placeholder as last argument which will be
  51. # replaced by the contents of the environment variable in runtests.pl.
  52. # This is a workaround for CMake's limitation where commands executed by
  53. # 'make' or 'ninja' cannot portably reference environment variables.
  54. string(REPLACE " " ";" _test_flags_list "${_test_flags}")
  55. add_custom_target(${_targetname}
  56. COMMAND
  57. "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runtests.pl"
  58. ${_test_flags_list}
  59. "\$TFLAGS"
  60. DEPENDS "${_depends}"
  61. VERBATIM USES_TERMINAL
  62. )
  63. endfunction()
  64. function(add_pytest _targetname _test_flags)
  65. unset(_depends)
  66. if(NOT _targetname STREQUAL "pytest-ci")
  67. set(_depends "test-http-clients")
  68. endif()
  69. string(REPLACE " " ";" _test_flags_list "${_test_flags}")
  70. add_custom_target(${_targetname}
  71. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  72. COMMAND pytest ${_test_flags_list} "${CMAKE_CURRENT_SOURCE_DIR}/http"
  73. DEPENDS "${_depends}"
  74. VERBATIM USES_TERMINAL
  75. )
  76. endfunction()
  77. # Create configurehelp.pm, used by tests needing to run the C preprocessor.
  78. if(MSVC OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
  79. set(CURL_CPP "\"${CMAKE_C_COMPILER}\" -E")
  80. if(APPLE AND CMAKE_OSX_SYSROOT)
  81. set(CURL_CPP "${CURL_CPP} -isysroot ${CMAKE_OSX_SYSROOT}")
  82. endif()
  83. # Add header directories, like autotools builds do.
  84. get_property(_include_dirs TARGET ${LIB_SELECTED} PROPERTY INCLUDE_DIRECTORIES)
  85. foreach(_include_dir IN LISTS _include_dirs)
  86. set(CURL_CPP "${CURL_CPP} -I${_include_dir}")
  87. endforeach()
  88. else()
  89. set(CURL_CPP "cpp")
  90. endif()
  91. # Generate version script for the linker, for versioned symbols.
  92. # Consumed variable:
  93. # CURL_CPP
  94. configure_file(
  95. "${CMAKE_CURRENT_SOURCE_DIR}/configurehelp.pm.in"
  96. "${CMAKE_CURRENT_BINARY_DIR}/configurehelp.pm" @ONLY)
  97. add_runtests(test-quiet "-a -s")
  98. add_runtests(test-am "-a -am")
  99. add_runtests(test-full "-a -p -r")
  100. # ~flaky means that it ignores results of tests using the flaky keyword
  101. add_runtests(test-nonflaky "-a -p ~flaky ~timing-dependent")
  102. add_runtests(test-ci "-a -p ~flaky ~timing-dependent -r -rm -j20")
  103. add_runtests(test-torture "-a -t -j2")
  104. add_runtests(test-event "-a -e")
  105. add_pytest(curl-pytest "")
  106. add_pytest(curl-pytest-ci "-v")