RunCMakeTest.cmake 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. include(RunCMake)
  2. set(RunCMake_TEST_OPTIONS
  3. "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}"
  4. "-DPSEUDO_CPPLINT=${PSEUDO_CPPLINT}"
  5. "-DPSEUDO_IWYU=${PSEUDO_IWYU}"
  6. "-DPSEUDO_TIDY=${PSEUDO_TIDY}"
  7. )
  8. function(run_multilint lang)
  9. # Use a single build tree for tests without cleaning.
  10. set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${lang}-build")
  11. set(RunCMake_TEST_NO_CLEAN 1)
  12. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  13. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  14. run_cmake(${lang})
  15. set(RunCMake_TEST_OUTPUT_MERGE 1)
  16. run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .)
  17. endfunction()
  18. run_multilint(C)
  19. run_multilint(CXX)
  20. if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
  21. run_multilint(C-launch)
  22. run_multilint(CXX-launch)
  23. run_multilint(genex)
  24. endif()
  25. function(run_skip_linting test_name prop_sf prop_tgt)
  26. set(RunCMake_TEST_VARIANT_DESCRIPTION " (prop_sf=${prop_sf}, prop_tgt=${prop_tgt})")
  27. list(APPEND RunCMake_TEST_OPTIONS "-Dprop_sf=${prop_sf}" "-Dprop_tgt=${prop_tgt}")
  28. set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${test_name}-build")
  29. set(RunCMake_TEST_NO_CLEAN 1)
  30. run_cmake(${test_name})
  31. set(RunCMake_TEST_OUTPUT_MERGE 1)
  32. run_cmake_command(${test_name}-Build ${CMAKE_COMMAND} --build .)
  33. endfunction()
  34. # There are a few `SKIP_LINTING` source/target propertiy combinations
  35. # that affect the final result:
  36. #
  37. # prop_sf prop_tgt result
  38. # ---------------------------
  39. # - - OFF
  40. # OFF - OFF
  41. # ON - ON
  42. # - OFF OFF
  43. # OFF OFF OFF
  44. # ON OFF ON
  45. # - ON ON
  46. # OFF ON OFF
  47. # ON ON ON
  48. #
  49. # where `-` means unset property.
  50. #
  51. # Here's the same table for convenience sorted by `result`:
  52. #
  53. # prop_sf prop_tgt result
  54. # ---------------------------
  55. # - - OFF
  56. # OFF - OFF
  57. # - OFF OFF
  58. # OFF OFF OFF
  59. # OFF ON OFF
  60. # ON - ON
  61. # ON OFF ON
  62. # - ON ON
  63. # ON ON ON
  64. foreach(lang IN ITEMS C CXX)
  65. # Testing `SKIP_LINTING=OFF` (first half of the table above)
  66. set(prop_sf_OFF_variants "-" OFF "-" OFF OFF)
  67. set(prop_tgt_OFF_variants "-" "-" OFF OFF ON)
  68. foreach(prop_fs prop_tgt IN ZIP_LISTS prop_sf_OFF_variants prop_tgt_OFF_variants)
  69. run_skip_linting(${lang}_skip_linting_OFF "${prop_fs}" "${prop_tgt}")
  70. endforeach()
  71. # Testing `SKIP_LINTING=ON` (second half of the table above)
  72. set(prop_sf_ON_variants ON ON "-" ON)
  73. set(prop_tgt_ON_variants "-" OFF ON ON)
  74. foreach(prop_fs prop_tgt IN ZIP_LISTS prop_sf_ON_variants prop_tgt_ON_variants)
  75. run_skip_linting(${lang}_skip_linting_ON "${prop_fs}" "${prop_tgt}")
  76. if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
  77. run_skip_linting(${lang}-launch_skip_linting_ON "${prop_fs}" "${prop_tgt}")
  78. endif()
  79. endforeach()
  80. endforeach()