CMakeLists.txt 3.0 KB

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