aboutsummaryrefslogtreecommitdiff
path: root/cmake/DefCmdTarget.cmake
blob: 48e90cf5c8e6a8c580d1e8ef8773399759b20e34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Defines a target named ${target}. If ${prg} is undefined the target prints
# "not found".
#
# - Use add_custom_command(TARGET <target_name> ...) to append a command to the
# target.
function(def_cmd_target target prg prg_name prg_fatal)
  add_custom_target(${target})

  if(NOT prg)
    if(prg_fatal)
      add_custom_command(TARGET ${target}
        COMMAND ${CMAKE_COMMAND} -E echo "${target}: ${prg_name} not found"
        COMMAND false)
    else()
      add_custom_command(TARGET ${target}
        COMMAND ${CMAKE_COMMAND} -E echo "${target}: SKIP: ${prg_name} not found")
    endif()
  endif()
endfunction()