CMakeLists.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. find_program(TEST_NGHTTPX "nghttpx")
  25. if(NOT TEST_NGHTTPX)
  26. set(TEST_NGHTTPX "nghttpx")
  27. endif()
  28. mark_as_advanced(TEST_NGHTTPX)
  29. # Consumed variables: TEST_NGHTTPX
  30. configure_file("config.in" "${CMAKE_CURRENT_BINARY_DIR}/config" @ONLY)
  31. add_custom_target(testdeps)
  32. add_subdirectory(http)
  33. add_subdirectory(http/clients)
  34. add_subdirectory(server)
  35. add_subdirectory(libtest)
  36. add_subdirectory(unit)
  37. add_subdirectory(certs EXCLUDE_FROM_ALL)
  38. function(add_runtests _targetname _test_flags)
  39. # Use a special '$TFLAGS' placeholder as last argument which will be
  40. # replaced by the contents of the environment variable in runtests.pl.
  41. # This is a workaround for CMake's limitation where commands executed by
  42. # 'make' or 'ninja' cannot portably reference environment variables.
  43. string(REPLACE " " ";" _test_flags_list "${_test_flags}")
  44. add_custom_target(${_targetname}
  45. COMMAND
  46. "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runtests.pl"
  47. ${_test_flags_list}
  48. "\$TFLAGS"
  49. DEPENDS testdeps
  50. VERBATIM USES_TERMINAL
  51. )
  52. endfunction()
  53. # Create configurehelp.pm, used by tests needing to run the C preprocessor.
  54. if(MSVC OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
  55. set(_cpp_cmd "\"${CMAKE_C_COMPILER}\" -E")
  56. if(APPLE AND CMAKE_OSX_SYSROOT)
  57. set(_cpp_cmd "${_cpp_cmd} -isysroot ${CMAKE_OSX_SYSROOT}")
  58. endif()
  59. # Add header directories, like autotools builds do.
  60. get_property(_include_dirs TARGET ${LIB_SELECTED} PROPERTY INCLUDE_DIRECTORIES)
  61. foreach(_include_dir IN LISTS _include_dirs)
  62. set(_cpp_cmd "${_cpp_cmd} -I${_include_dir}")
  63. endforeach()
  64. else()
  65. set(_cpp_cmd "cpp")
  66. endif()
  67. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/configurehelp.pm" "# This is a generated file. Do not edit.
  68. package configurehelp;
  69. use strict;
  70. use warnings;
  71. use Exporter;
  72. use vars qw(
  73. @ISA
  74. @EXPORT_OK
  75. \$Cpreprocessor
  76. );
  77. @ISA = qw(Exporter);
  78. @EXPORT_OK = qw(
  79. \$Cpreprocessor
  80. );
  81. \$Cpreprocessor = '${_cpp_cmd}';
  82. 1;
  83. ")
  84. add_runtests(test-quiet "-a -s")
  85. add_runtests(test-am "-a -am")
  86. add_runtests(test-full "-a -p -r")
  87. # ~flaky means that it ignores results of tests using the flaky keyword
  88. add_runtests(test-nonflaky "-a -p ~flaky ~timing-dependent")
  89. add_runtests(test-ci "-a -p ~flaky ~timing-dependent -r -rm -j2")
  90. add_runtests(test-torture "-a -t -j2")
  91. add_runtests(test-event "-a -e")