I have subdir project :
//exaple.pro
TEMPLATE = subdirs
SUBDIRS += \
myLib \
executable_one \
executable_two
myLib
is static library with one function in it:
//MyLib.h
void foo();
//MyLib.cpp
#include "MyLib.h"
#include <iostream>
void foo()
{
# ifdef MY_DEFINE
std::cout << "MY_DEFINE is defined\n";
# else
std::cout << "MY_DEFINE is undefined\n";
# endif
}
And two other projects which are linking to this library executable_one
and executable_two
. In one I want to define MY_DEFINE
, in another one don't. So I've tried to add DEFINES += MY_DEFINE
in the executable_one.pro
file, but in both cases the output is "MY_DEFINE is undefined". I understand that myLib
was compiled without this flag before executable and then was just linked into it without changing, but is there any way to make the library be built twice and for one of the executables pass this compiler option to the library?