CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. set(TARGET_LABEL_PREFIX "Test ")
  2. function(SETUP_TEST TEST_NAME) # ARGN are the files in the test
  3. add_executable( ${TEST_NAME} ${ARGN} )
  4. string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)
  5. include_directories(
  6. ${CURL_SOURCE_DIR}/lib # To be able to reach "setup_once.h"
  7. ${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h"
  8. ${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h"
  9. )
  10. if(CURL_USE_ARES)
  11. include_directories(${CARES_INCLUDE_DIR})
  12. endif()
  13. setup_curl_dependencies(${TEST_NAME})
  14. target_link_libraries( ${TEST_NAME} libcurl )
  15. set_target_properties(${TEST_NAME}
  16. PROPERTIES COMPILE_DEFINITIONS ${UPPER_TEST_NAME})
  17. set_target_properties(${TEST_NAME}
  18. PROPERTIES PROJECT_LABEL "${TARGET_LABEL_PREFIX}${TEST_NAME}")
  19. # Add the postfix to the executable since it is
  20. # not added automatically as for modules and shared libraries
  21. set_target_properties(${TEST_NAME}
  22. PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
  23. if(MSVC)
  24. if(NOT BUILD_RELEASE_DEBUG_DIRS)
  25. # Ugly workaround to remove the "/debug" or "/release" in each output
  26. set_target_properties(${TEST_NAME} PROPERTIES PREFIX "../")
  27. set_target_properties(${TEST_NAME} PROPERTIES IMPORT_PREFIX "../")
  28. endif()
  29. endif()
  30. endfunction()
  31. transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
  32. include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
  33. foreach(TEST_NAME ${noinst_PROGRAMS})
  34. setup_test(${TEST_NAME} ${${TEST_NAME}_SOURCES})
  35. endforeach()
  36. # # files used only in some libcurl test programs
  37. # SET(TESTUTIL testutil.c testutil.h)
  38. # # these files are used in every single test program below
  39. # SET(SUPPORTFILES first.c test.h)
  40. # # These are all libcurl test programs
  41. # SET(noinst_PROGRAMS
  42. # lib500 lib501 lib502 lib503 lib504 lib505 lib506
  43. # lib507 lib508 lib510 lib511 lib512 lib513 lib514 lib515 lib516
  44. # lib517 lib518 lib519 lib520 lib521 lib523 lib524 lib525 lib526
  45. # #lib527
  46. # #lib529
  47. # lib530
  48. # #lib532
  49. # lib533 lib536 lib537 lib540 lib541 lib542 lib543
  50. # lib544
  51. # #lib545
  52. # lib547
  53. # #lib548
  54. # lib549 lib552 lib553 lib554 lib555 lib556
  55. # lib539 lib557
  56. # lib560
  57. # )
  58. # SET(noinst_PROGRAMS_USE_TESTUTIL
  59. # lib502 lib503 lib504
  60. # lib507
  61. # lib525 lib526 lib527
  62. # lib529
  63. # lib530
  64. # lib532
  65. # lib533 lib536
  66. # lib555
  67. # )
  68. # MACRO(ADD_TESTUTIL_IF_NECESSARY TEST_NAME)
  69. # LIST(FIND noinst_PROGRAMS_USE_TESTUTIL ${TEST_NAME} USES_TESTUTIL)
  70. # IF(NOT ${USES_TESTUTIL} EQUAL -1)
  71. # LIST(APPEND SOURCE ${TESTUTIL}) # Need TestUtil
  72. # ENDIF()
  73. # ENDMACRO()
  74. # # General case
  75. # FOREACH(TEST_NAME ${noinst_PROGRAMS})
  76. # SET(SOURCE "${TEST_NAME}.c" ${SUPPORTFILES})
  77. # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
  78. # SETUP_TEST(${TEST_NAME} ${SOURCE})
  79. # ENDFOREACH()
  80. # # Special cases
  81. # SET(TEST_NAME lib527)
  82. # SET(SOURCE "lib526.c" ${SUPPORTFILES})
  83. # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
  84. # SETUP_TEST(${TEST_NAME} ${SOURCE})
  85. # SET(TEST_NAME lib529)
  86. # SET(SOURCE "lib525.c" ${SUPPORTFILES})
  87. # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
  88. # SETUP_TEST(${TEST_NAME} ${SOURCE})
  89. # SET(TEST_NAME lib532)
  90. # SET(SOURCE "lib526.c" ${SUPPORTFILES})
  91. # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
  92. # SETUP_TEST(${TEST_NAME} ${SOURCE})
  93. # SET(TEST_NAME lib545)
  94. # SET(SOURCE "lib544.c" ${SUPPORTFILES})
  95. # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
  96. # SETUP_TEST(${TEST_NAME} ${SOURCE})
  97. # SET(TEST_NAME lib548)
  98. # SET(SOURCE "lib547.c" ${SUPPORTFILES})
  99. # ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
  100. # SETUP_TEST(${TEST_NAME} ${SOURCE})