How to check whether a target has been added or not?

后端 未结 2 1879
悲&欢浪女
悲&欢浪女 2021-02-07 05:20

Assume I have a cmake macro that adds target (library or executable) based on some conditions

macro (conditionally_add target_name target_src condition)
  if (co         


        
2条回答
  •  后悔当初
    2021-02-07 06:10

    It seems, there is still no way to iterate over targets in the CMake, so you'd need to do it yourself.

    You'll need to create a custom variant of add_executable() and add_library() functions, which would do something like

    function(my_add_executable TARGET)
      list(APPEND MY_TARGETS ${TARGET})
      add_executable(${TARGET} ${ARGN}
    endfunction()function(my_add_executable TARGET)
    

提交回复
热议问题