You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.4 KiB

  1. # This program source code file is part of KiCad, a free EDA CAD application.
  2. #
  3. # Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, you may find one here:
  17. # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  18. # or you may search the http://www.gnu.org website for the version 2 license,
  19. # or you may write to the Free Software Foundation, Inc.,
  20. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  21. #
  22. # Utility CMake functions and targets for marshalling the builds of QA
  23. # tests and tools
  24. #
  25. # CI tools can use this to force tests to output machine-readable formats
  26. # when possible
  27. option( KICAD_TEST_XML_OUTPUT
  28. "Cause unit tests to output xUnit results where possible for more granular CI reporting."
  29. OFF
  30. )
  31. mark_as_advanced( KICAD_TEST_XML_OUTPUT ) # Only CI tools need this
  32. # This is a "meta" target that is used to collect all tests
  33. add_custom_target( qa_all_tests )
  34. # This is a "meta" target used to collect all utility tools
  35. add_custom_target( qa_all_tools )
  36. # This "meta" target builds all QA tools, utils, etc
  37. add_custom_target( qa_all
  38. DEPENDS qa_all_tests qa_all_tools
  39. )
  40. # Add a target as a "QA test" executable:
  41. # * Added as a CTest test with the given name
  42. # * Excluded from ALL when KICAD_BUILD_QA_TESTS not set
  43. # * Is a dependency of qa_all_tests
  44. function( kicad_add_boost_test TEST_EXEC_TARGET TEST_NAME)
  45. set(BOOST_TEST_PARAMS "")
  46. if( KICAD_TEST_XML_OUTPUT )
  47. # Provide Boost-test-y XML params if asked
  48. # Due to Boost issue in 1.62, have to use the --logger parameter, rather than
  49. # separate --log_format, --log_sink, etc parameter
  50. # https://svn.boost.org/trac10/ticket/12507
  51. set(BOOST_TEST_PARAMS --logger=XML,all,${TEST_NAME}.boost-results.xml --report_level=no --result_code=no)
  52. endif()
  53. # Add the test to the CTest registry
  54. add_test( NAME ${TEST_NAME}
  55. COMMAND $<TARGET_FILE:${TEST_EXEC_TARGET}> ${BOOST_TEST_PARAMS}
  56. )
  57. # Make the overall test meta-target depend on this test
  58. add_dependencies( qa_all_tests ${TEST_EXEC_TARGET} )
  59. # If tests are not enabled by default, remove from the ALL target
  60. # They can still be built manually, or all together with the qa_all_test target
  61. if( NOT KICAD_BUILD_QA_TESTS )
  62. set_target_properties( ${TEST_EXEC_TARGET}
  63. PROPERTIES EXCLUDE_FROM_ALL TRUE
  64. )
  65. endif()
  66. endfunction()
  67. # Add a target as a "QA tool" executable:
  68. # * Excluded from ALL when KICAD_BUILD_QA_TESTS not set
  69. # * Is a dependency of qa_all_tools
  70. function( kicad_add_utils_executable TARGET)
  71. # If tests are not enabled by default, remove from the ALL target
  72. # They can still be built manually, or all together with the qa_all_tools
  73. if( NOT KICAD_BUILD_QA_TESTS )
  74. set_target_properties( ${TARGET}
  75. PROPERTIES EXCLUDE_FROM_ALL TRUE
  76. )
  77. endif()
  78. # Make the overall test meta-target depend on this test
  79. add_dependencies( qa_all_tools ${TARGET} )
  80. endfunction()