[CMake] cmake - two targets that depends on single static library that should be compiled based on the target that is being built

ugesh reddy abhiugeshreddy at gmail.com
Tue Jul 2 08:18:07 EDT 2019


Hello,

I couldn't find any solution's for this problem even after posting the
question on Reddit/stack overflow, so I am posting it here.

My question is as follows:

I have a static library and two target executables, let's call them
**libA**, **EXE1**, **EXE2**.

**libA** has pre-processor macros which needs to be enabled or disabled and
another static library which needs to be linked or ignored based on the
target executable that I am building.

Let's say, if I am building EXE1. Then I need to enable the macros in libA
and link another static library to it.

If I am building EXE2, I need to disabled the macros in libA and don't link
to another library.

I don't want to create two targets with same source files.

I am confused on how to solve this issue. Please kindly help in solving
this issue.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190702/7320e6c2/attachment.html>


More information about the CMake mailing list