<div dir="ltr">Ok, seems there is no other way then. Thank you for the clarification. <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 2, 2019 at 3:44 PM Kyle Edwards <<a href="mailto:kyle.edwards@kitware.com">kyle.edwards@kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 2019-07-02 at 14:18 +0200, ugesh reddy wrote:<br>
> Hello,<br>
> <br>
> I couldn't find any solution's for this problem even after posting<br>
> the question on Reddit/stack overflow, so I am posting it here.<br>
> <br>
> My question is as follows:<br>
> <br>
> I have a static library and two target executables, let's call them<br>
> **libA**, **EXE1**, **EXE2**.<br>
> <br>
> **libA** has pre-processor macros which needs to be enabled or<br>
> disabled and another static library which needs to be linked or<br>
> ignored based on the target executable that I am building.<br>
> <br>
> Let's say, if I am building EXE1. Then I need to enable the macros in<br>
> libA and link another static library to it.<br>
> <br>
> If I am building EXE2, I need to disabled the macros in libA and<br>
> don't link to another library.<br>
> <br>
> I don't want to create two targets with same source files.<br>
<br>
I'm sorry to say it, but creating two targets is actually exactly what<br>
you want to do here. If your concern is code duplication, you can make<br>
the code much shorter by using variables. Example:<br>
<br>
set(libA_SRCS<br>
  src1.c<br>
  src2.c<br>
  src3.c<br>
  # lots of other sources...<br>
  )<br>
add_library(libA1 STATIC ${libA_SRCS})<br>
target_link_libraries(libA1 otherlib)<br>
add_library(libA2 STATIC ${libA_SRCS})<br>
<br>
Kyle<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"> Ugesh</div>