CMakeLists.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. set(CMAKE_UNITY_BUILD 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. # Use a special '$TFLAGS' placeholder as last argument which will be
  41. # replaced by the contents of the environment variable in runtests.pl.
  42. # This is a workaround for CMake's limitation where commands executed by
  43. # 'make' or 'ninja' cannot portably reference environment variables.
  44. string(REPLACE " " ";" _test_flags_list "${_test_flags}")
  45. add_custom_target(${_targetname}
  46. COMMAND
  47. "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runtests.pl"
  48. ${_test_flags_list}
  49. "\$TFLAGS"
  50. DEPENDS testdeps
  51. VERBATIM USES_TERMINAL
  52. )
  53. endfunction()
  54. # Create configurehelp.pm, used by tests needing to run the C preprocessor.
  55. if(MSVC OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
  56. set(_cpp_cmd "\"${CMAKE_C_COMPILER}\" -E")
  57. if(APPLE AND CMAKE_OSX_SYSROOT)
  58. set(_cpp_cmd "${_cpp_cmd} -isysroot ${CMAKE_OSX_SYSROOT}")
  59. endif()
  60. # Add header directories, like autotools builds do.
  61. get_property(_include_dirs TARGET ${LIB_SELECTED} PROPERTY INCLUDE_DIRECTORIES)
  62. foreach(_include_dir IN LISTS _include_dirs)
  63. set(_cpp_cmd "${_cpp_cmd} -I${_include_dir}")
  64. endforeach()
  65. else()
  66. set(_cpp_cmd "cpp")
  67. endif()
  68. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/configurehelp.pm" "# This is a generated file. Do not edit.
  69. package configurehelp;
  70. use strict;
  71. use warnings;
  72. use Exporter;
  73. use vars qw(
  74. @ISA
  75. @EXPORT_OK
  76. \$Cpreprocessor
  77. );
  78. @ISA = qw(Exporter);
  79. @EXPORT_OK = qw(
  80. \$Cpreprocessor
  81. );
  82. \$Cpreprocessor = '${_cpp_cmd}';
  83. 1;
  84. ")
  85. # Save build info for test runner to pick up and log
  86. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/buildinfo.txt" "# This is a generated file. Do not edit.
  87. configure.tool: cmake
  88. configure.command: ${CMAKE_COMMAND}
  89. configure.version: ${CMAKE_VERSION}
  90. configure.os: ${CMAKE_SYSTEM}
  91. configure.args:${_cmake_args}
  92. configure.generator: ${CMAKE_GENERATOR}
  93. configure.make: ${CMAKE_MAKE_PROGRAM}
  94. host.os: ${CMAKE_HOST_SYSTEM_NAME}
  95. host.cpu: ${CMAKE_HOST_SYSTEM_PROCESSOR}
  96. target: ${CMAKE_C_COMPILER_TARGET}
  97. target.os: ${CMAKE_SYSTEM_NAME}
  98. target.cpu: ${CMAKE_SYSTEM_PROCESSOR}
  99. target.flags:${_target_flags}
  100. compiler: ${CMAKE_C_COMPILER_ID}
  101. compiler.version: ${CMAKE_C_COMPILER_VERSION}
  102. ")
  103. add_runtests(test-quiet "-a -s")
  104. add_runtests(test-am "-a -am")
  105. add_runtests(test-full "-a -p -r")
  106. # ~flaky means that it ignores results of tests using the flaky keyword
  107. add_runtests(test-nonflaky "-a -p ~flaky ~timing-dependent")
  108. add_runtests(test-ci "-a -p ~flaky ~timing-dependent -r -rm -j2")
  109. add_runtests(test-torture "-a -t")
  110. add_runtests(test-event "-a -e")