CMakeLists.txt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Render the header file with source path macro
  2. configure_file(testConfig.h.in testConfig.h @ONLY)
  3. include_directories(
  4. ${CMAKE_CURRENT_BINARY_DIR}
  5. ${CMake_BINARY_DIR}/Source
  6. ${CMake_SOURCE_DIR}/Source
  7. ${CMake_SOURCE_DIR}/Source/CTest
  8. )
  9. set(CMakeLib_TESTS
  10. testAssert.cxx
  11. testArgumentParser.cxx
  12. testCTestBinPacker.cxx
  13. testCTestResourceAllocator.cxx
  14. testCTestResourceSpec.cxx
  15. testCTestResourceGroups.cxx
  16. testDateTime.cxx
  17. testDebug.cxx
  18. testDocumentationFormatter.cxx
  19. testGccDepfileReader.cxx
  20. testGeneratedFileStream.cxx
  21. testJSONHelpers.cxx
  22. testRST.cxx
  23. testRange.cxx
  24. testOptional.cxx
  25. testPathResolver.cxx
  26. testSPDXSerializer.cxx
  27. testStdIo.cxx
  28. testString.cxx
  29. testStringAlgorithms.cxx
  30. testSystemTools.cxx
  31. testUTF8.cxx
  32. testXMLParser.cxx
  33. testXMLSafe.cxx
  34. testFindPackageCommand.cxx
  35. testUVHandlePtr.cxx
  36. testUVJobServerClient.cxx
  37. testUVPatches.cxx
  38. testUVProcessChain.cxx
  39. testUVRAII.cxx
  40. testUVStreambuf.cxx
  41. testCMExtMemory.cxx
  42. testCMExtAlgorithm.cxx
  43. testCMExtEnumSet.cxx
  44. testList.cxx
  45. testCMakePath.cxx
  46. )
  47. if(CMake_ENABLE_DEBUGGER)
  48. list(APPEND CMakeLib_TESTS
  49. testDebuggerAdapter.cxx
  50. testDebuggerAdapterPipe.cxx
  51. testDebuggerBreakpointManager.cxx
  52. testDebuggerVariables.cxx
  53. testDebuggerVariablesHelper.cxx
  54. testDebuggerVariablesManager.cxx
  55. testDebuggerThread.cxx
  56. )
  57. endif()
  58. if (CMake_TEST_FILESYSTEM_PATH OR NOT CMake_HAVE_CXX_FILESYSTEM)
  59. list(APPEND CMakeLib_TESTS testCMFilesystemPath.cxx)
  60. endif()
  61. add_executable(testUVProcessChainHelper testUVProcessChainHelper.cxx)
  62. target_link_libraries(testUVProcessChainHelper CMakeLib)
  63. target_compile_definitions(testUVProcessChainHelper PRIVATE WIN32_LEAN_AND_MEAN)
  64. set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
  65. set(testUVProcessChain_ARGS $<TARGET_FILE:testUVProcessChainHelper>)
  66. set(testUVStreambuf_ARGS $<TARGET_FILE:cmake>)
  67. set(testCTestResourceSpec_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
  68. set(testGccDepfileReader_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
  69. if(WIN32)
  70. list(APPEND CMakeLib_TESTS
  71. testVisualStudioSlnParser.cxx
  72. )
  73. endif()
  74. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testUVProcessChainInput.txt" "HELLO WORLD!")
  75. create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS})
  76. add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS})
  77. target_link_libraries(CMakeLibTests PRIVATE CTestLib CMakeLib)
  78. if(CMake_BUILD_PCH)
  79. target_precompile_headers(CMakeLibTests PRIVATE "<iostream>" "<cm3p/uv.h>")
  80. target_compile_definitions(CMakeLibTests PRIVATE "NOMINMAX")
  81. endif()
  82. if(WIN32)
  83. target_compile_definitions(CMakeLibTests PRIVATE WIN32_LEAN_AND_MEAN)
  84. endif()
  85. set_property(TARGET CMakeLibTests PROPERTY C_CLANG_TIDY "")
  86. set_property(TARGET CMakeLibTests PROPERTY CXX_CLANG_TIDY "")
  87. add_executable(testEncoding testEncoding.cxx)
  88. target_link_libraries(testEncoding cmsys)
  89. foreach(testfile ${CMakeLib_TESTS})
  90. get_filename_component(test "${testfile}" NAME_WE)
  91. add_test(NAME CMakeLib.${test} COMMAND CMakeLibTests ${test} ${${test}_ARGS})
  92. endforeach()
  93. if(TEST_CompileCommandOutput)
  94. add_executable(runcompilecommands run_compile_commands.cxx)
  95. target_link_libraries(runcompilecommands CMakeLib)
  96. endif()
  97. add_subdirectory(PseudoMemcheck)
  98. add_executable(testAffinity testAffinity.cxx)
  99. target_link_libraries(testAffinity CMakeLib)
  100. if(CMake_ENABLE_DEBUGGER)
  101. add_executable(testDebuggerNamedPipe testDebuggerNamedPipe.cxx)
  102. target_link_libraries(testDebuggerNamedPipe PRIVATE CMakeLib)
  103. set(testDebuggerNamedPipe_Project_ARGS
  104. "$<TARGET_FILE:cmake>" -S ${CMAKE_CURRENT_SOURCE_DIR}/DebuggerSample -B ${CMAKE_CURRENT_BINARY_DIR}/DebuggerSample
  105. --fresh -G ${CMAKE_GENERATOR}
  106. )
  107. if(CMAKE_GENERATOR_PLATFORM)
  108. list(APPEND testDebuggerNamedPipe_Project_ARGS -A "${CMAKE_GENERATOR_PLATFORM}")
  109. endif()
  110. if(CMAKE_GENERATOR_TOOLSET)
  111. list(APPEND testDebuggerNamedPipe_Project_ARGS -T "${CMAKE_GENERATOR_TOOLSET}")
  112. endif()
  113. if(CMAKE_GENERATOR_INSTANCE)
  114. list(APPEND testDebuggerNamedPipe_Project_ARGS "-DCMAKE_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE}")
  115. endif()
  116. set(testDebuggerNamedPipe_Script_ARGS
  117. "$<TARGET_FILE:cmake>" -P ${CMAKE_CURRENT_SOURCE_DIR}/DebuggerSample/script.cmake
  118. )
  119. foreach(case Project Script)
  120. add_test(NAME CMakeLib.testDebuggerNamedPipe-${case} COMMAND testDebuggerNamedPipe ${testDebuggerNamedPipe_${case}_ARGS})
  121. set_property(TEST CMakeLib.testDebuggerNamedPipe-${case} PROPERTY TIMEOUT 300)
  122. endforeach()
  123. if(WIN32)
  124. target_compile_definitions(testDebuggerNamedPipe PRIVATE WIN32_LEAN_AND_MEAN)
  125. endif()
  126. endif()