File: AddCustomCommandOrTest.cmake

package info (click to toggle)
boost-ext-ut 2.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 620 kB
  • sloc: cpp: 6,773; makefile: 13; sh: 10
file content (25 lines) | stat: -rw-r--r-- 810 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
option(BOOST_UT_ENABLE_RUN_AFTER_BUILD "Automatically run built artifacts. If disabled, the tests can be run with ctest instead" ON)

function(ut_add_custom_command_or_test)
  # Define the supported set of keywords
  set(prefix "PARSE")
  set(noValues "")
  set(singleValues TARGET)
  set(multiValues COMMAND)

  # Process the arguments passed in
  include(CMakeParseArguments)
  cmake_parse_arguments("${prefix}" "${noValues}" "${singleValues}" "${multiValues}" ${ARGN})
  target_link_libraries(${PARSE_TARGET} PRIVATE Boost::ut)

  if(BOOST_UT_ENABLE_RUN_AFTER_BUILD)
    add_custom_command(
      TARGET ${PARSE_TARGET}
      POST_BUILD
      COMMAND ${PARSE_COMMAND}
      COMMENT "Running ${PARSE_TARGET}"
    )
  else()
    add_test(NAME ${PARSE_TARGET} COMMAND ${PARSE_COMMAND})
  endif()
endfunction()