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

后端 未结 2 2045
悲&欢浪女
悲&欢浪女 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:13

    Use the TARGET clause of the if command:

    conditionally_add (mylib mysrc.cc ${some_condition})
    if (TARGET mylib)
      # Do something when target found
    endif()
    

提交回复
热议问题