2
0

CMakeLists.txt 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. # Get 'LIBTESTPROGS', '*_SOURCES', 'TESTUTIL', 'TSTTRACE', 'WARNLESS', 'MULTIBYTE', 'INET_PTON', 'TIMEDIFF', 'THREADS',
  25. # 'FIRSTFILES' variables
  26. curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
  27. include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
  28. set_source_files_properties("../../lib/curl_multibyte.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
  29. add_custom_command(
  30. OUTPUT "lib1521.c"
  31. COMMAND ${PERL_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl" < "${PROJECT_SOURCE_DIR}/include/curl/curl.h" "lib1521.c"
  32. DEPENDS
  33. "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl"
  34. "${PROJECT_SOURCE_DIR}/include/curl/curl.h"
  35. VERBATIM)
  36. if(CURL_TEST_BUNDLES)
  37. add_custom_command(
  38. OUTPUT "libtest_bundle.c"
  39. COMMAND ${PERL_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tests/mk-bundle.pl" "${CMAKE_CURRENT_SOURCE_DIR}" > "libtest_bundle.c"
  40. DEPENDS
  41. "${PROJECT_SOURCE_DIR}/tests/mk-bundle.pl" ${FIRSTFILES} "lib1521.c"
  42. "${CMAKE_CURRENT_SOURCE_DIR}/Makefile.inc"
  43. VERBATIM)
  44. set(LIBTESTPROGS "libtests")
  45. set(libtests_SOURCES "libtest_bundle.c")
  46. list(APPEND libtests_SOURCES ${TESTUTIL} ${TSTTRACE})
  47. if(LIB_SELECTED STREQUAL LIB_SHARED)
  48. # These are part of the libcurl static lib. Add them here when linking shared.
  49. list(APPEND libtests_SOURCES ${WARNLESS} ${MULTIBYTE} ${INET_PTON} ${TIMEDIFF} ${THREADS})
  50. endif()
  51. endif()
  52. foreach(_target IN LISTS LIBTESTPROGS)
  53. if(DEFINED ${_target}_SOURCES)
  54. set(_sources ${${_target}_SOURCES})
  55. else()
  56. set(_sources ${nodist_${_target}_SOURCES})
  57. endif()
  58. if(LIB_SELECTED STREQUAL LIB_STATIC)
  59. # These are part of the libcurl static lib. Do not compile/link them again.
  60. list(REMOVE_ITEM _sources ${WARNLESS} ${MULTIBYTE} ${INET_PTON} ${TIMEDIFF} ${THREADS})
  61. endif()
  62. string(TOUPPER ${_target} _upper_target)
  63. set(_target_name "${_target}")
  64. add_executable(${_target_name} EXCLUDE_FROM_ALL ${_sources})
  65. add_dependencies(testdeps ${_target_name})
  66. target_link_libraries(${_target_name} ${LIB_SELECTED} ${CURL_LIBS})
  67. target_include_directories(${_target_name} PRIVATE
  68. "${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"
  69. "${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h"
  70. "${PROJECT_SOURCE_DIR}/src" # for "tool_binmode.h"
  71. "${PROJECT_SOURCE_DIR}/tests/libtest" # to be able to build generated tests
  72. )
  73. if(NOT CURL_TEST_BUNDLES)
  74. set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS ${_upper_target})
  75. endif()
  76. set_property(TARGET ${_target_name} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_GETADDRINFO_OVERRIDE")
  77. set_target_properties(${_target_name} PROPERTIES
  78. OUTPUT_NAME "${_target}"
  79. PROJECT_LABEL "Test libtest ${_target}")
  80. endforeach()