I have a project coreApp using two libraries lib1 and lib2.
Each lib has a file Version.h specifying the lib version, each in the library namespace, example :
namespace lib1{
static const QString Version = "1.2";
}
In my coreApp .pro I have :
LIB1_PATH_VAR = $$(LIB1_PATH) (LIB1_PATH is an environment variable storing the path to the root directory of lib1)
LIBS += -L$$LIB1_PATH_VAR/bin/ -l1
LIB2_PATH_VAR = $$(LIB2_PATH)
LIBS += -L$$LIB2_PATH_VAR/bin/ -l2
I want to do something like this in my main.cpp of coreApp :
#include "$$LIB1_PATH_VAR/Version.h"
#include "$$LIB2_PATH_VAR/Version.h"
std::cout<<lib1::Version<<std::endl;
std::cout<<lib2::Version<<std::endl;
It would allow me to be independent from the library path (in the code) while using classes that have the same name in both libraries (here Version.h).
Would it be possible ?
Current Solution :
INCLUDEPATH += LIB1_PATH/..
to my coreApp.pro So that my main.cpp can look like this :
#include "path/to/lib1/Version.h"
#include "path/to/lib2/Version.h"
std::cout<<lib1::Version<<std::endl;
std::cout<<lib2::Version<<std::endl;
The problem is that the library path in written in the code, if I move the library to another location I have to change all my #include in the code