How to programmatically determine the project folder name?
-
Hi and welcome to devnet,
Why do you need that information ?
-
This may not be the short answer but:
1 add this to your profile:`DEFINES += MYPROJDIR=$$_PRO_FILE_PWD_ `` 2. code should be something like:
#define xstr(s) str(s)
#define str(s) #sint main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString projdir = QString(xstr(MYPROJDIR));
qDebug() << "Source Directory = " << projdir;
return a.exec();
} -
This may not be the short answer but:
1 add this to your profile:`DEFINES += MYPROJDIR=$$_PRO_FILE_PWD_ `` 2. code should be something like:
#define xstr(s) str(s)
#define str(s) #sint main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString projdir = QString(xstr(MYPROJDIR));
qDebug() << "Source Directory = " << projdir;
return a.exec();
} -
I wouldnt worry to much about QMake being deprecated. Its going to be around for a while.
The point of it is to pass the current directory as a define -D to the compiler. Its just as easily done in CMake or the command line,
The hard part is getting the quote pasting correct. -
@mranger90 that is an interesting solution. Thank you. However it depends on
qmake
which is "deprecated" according to this blog post."Longer term, we plan to switch to CMake for building Qt itself"
-
@vrcmr-0 said in How to programmatically determine the project folder name?:
this
Where in that link does it say qmake will be deprecated? It is talking about deprecating Qbs!!