CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 2009 - 2020, 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. ###########################################################################
  22. set(TARGET_LABEL_PREFIX "Test server ")
  23. if(MSVC)
  24. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4306")
  25. endif()
  26. function(SETUP_EXECUTABLE TEST_NAME) # ARGN are the files in the test
  27. add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
  28. add_dependencies(testdeps ${TEST_NAME})
  29. string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)
  30. include_directories(
  31. ${CURL_SOURCE_DIR}/lib # To be able to reach "curl_setup_once.h"
  32. ${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
  33. ${CURL_BINARY_DIR}/include # To be able to reach "curl/curl.h"
  34. )
  35. if(USE_ARES)
  36. include_directories(${CARES_INCLUDE_DIR})
  37. endif()
  38. target_link_libraries(${TEST_NAME} ${CURL_LIBS})
  39. # Test servers simply are standalone programs that do not use libcurl
  40. # library. For convenience and to ease portability of these servers,
  41. # some source code files from the libcurl subdirectory are also used
  42. # to build the servers. In order to achieve proper linkage of these
  43. # files on Win32 targets it is necessary to build the test servers
  44. # with CURL_STATICLIB defined, independently of how libcurl is built.
  45. if(BUILD_SHARED_LIBS)
  46. set_target_properties(${TEST_NAME} PROPERTIES
  47. COMPILE_DEFINITIONS CURL_STATICLIB) # ${UPPER_TEST_NAME}
  48. endif()
  49. set_target_properties(${TEST_NAME} PROPERTIES
  50. PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}")
  51. endfunction()
  52. transform_makefile_inc("Makefile.inc"
  53. "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
  54. include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
  55. foreach(EXECUTABLE_NAME ${noinst_PROGRAMS})
  56. setup_executable(${EXECUTABLE_NAME} ${${EXECUTABLE_NAME}_SOURCES})
  57. endforeach()
  58. # SET(useful
  59. # getpart.c getpart.h
  60. # ${CURL_SOURCE_DIR}/lib/strequal.c
  61. # ${CURL_SOURCE_DIR}/lib/base64.c
  62. # ${CURL_SOURCE_DIR}/lib/mprintf.c
  63. # ${CURL_SOURCE_DIR}/lib/memdebug.c
  64. # ${CURL_SOURCE_DIR}/lib/timeval.c
  65. # )
  66. # SETUP_EXECUTABLE(sws sws.c util.c util.h ${useful})
  67. # SETUP_EXECUTABLE(resolve resolve.c util.c util.h ${useful})
  68. # SETUP_EXECUTABLE(sockfilt sockfilt.c util.c util.h ${useful} ${CURL_SOURCE_DIR}/lib/inet_pton.c)
  69. # SETUP_EXECUTABLE(getpart testpart.c ${useful})
  70. # SETUP_EXECUTABLE(tftpd tftpd.c util.c util.h ${useful} tftp.h)