Finding out which application is calling Lib in build tree
-
Hi, I have a parent project with three sub-projects (2 apps and 1 lib) in build tree which looks like:
Project
---Project.pro
-------------App1
------------------App1.pro
-------------App2
------------------App2.pro
-------------Lib
------------------Lib.proand the lib is used by both apps.
I've inserted a "DEFINES" keyword in the App1.pro and App2.pro as compiler C preprocessor macros to be able to check which application is called the lib. But, I can't find a way to send the macro over the lib.So, How can I find which application is calling the Lib? (I want to disable/enable some features in the Lib based on the app)
-
It sounds more like something you need to do at runtime and not compile time using DEFINES. Since your lib is built only once you cannot differentiate between different apps at compile time. Instead you can pass different parameters from these different apps to the lib, so the lib can adjust its behaviour.
-
@alizadeh91 Just to be sure: you want the lib to behave differently depending on which app is using it and you want to decide at compile time, right? In this case you will need to build the lib for each application. So, if you have two apps then you will have two binaries of your lib.
-
Yes, But the lib is in the same build tree as apps. So, I think there exist such a way to do that. Also, I want to for example change some minor things in the lib. If I duplicate the lib, then, I will be faced with serious issues with duplicating those codes later.
-
Hi,
What are these "minor things" ?