Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Hi Guys!
I'm a newbie in Qt, I'm working on a project that has 1 root project and 3 subdirectory projects
ROOT.pro
|__
SUB1.pro
|__
SUB2.pro
|__
SUB3.pro
#####ROOT.pro
TEMPLATE = subdir
SUBDIRS += SUB1.pro\
SUB2.pro\
SUB3.pro
PATHSAMPLE = $$PWD/pathsampledir/
#####SUB1.pro
QT += core gui
TEMPLATE = app
SOURCES += sub1source.cpp
HEADERS += sub1header.h
FORMS += sub1form.ui
win32{
Debug{
DESTDIR = PATHSAMPLE
}
}
#####SUB2.pro
QT += core gui
TEMPLATE = app
SOURCES += sub2source.cpp
HEADERS += sub2header.h
FORMS += sub2form.ui
win32{
Debug{
DESTDIR = PATHSAMPLE
}
}
#####SUB3.pro
QT += core gui
TEMPLATE = app
SOURCES += sub3source.cpp
HEADERS += sub3header.h
FORMS += sub3form.ui
win32{
Debug{
DESTDIR = PATHSAMPLE
}
}
In this case, i would like to access PATHSAMPLE from the ROOT.pro to the SUBDIRECTORIES without using/including .pri. Can you help me guys? Is it possible? What can I do to solve this one? Thanks in advance
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
First of all it should be DESTDIR = $$PATHSAMPLE. Second of all what's wrong with pri files?
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Hi Sorry for that. Yeah it should be
DESTDIR = $$PATHSAMPLE
I just want to know if its possible without including PRI. Is it possible Sir?
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
As far as I remember with SUBDIR template some variables are being passed to child projects. If it doesn't work for you, you can always use environment variables.
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Thank You Sir.
Can you give example Sir. I'm a little bit confused about this. And how can I check the cvariables that are being passed to child projects?
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Quote:
Originally Posted by
iamDAMON
And how can I check the cvariables that are being passed to child projects?
Observe the console output when building the projects. And I'm sure you will notice if your variable is being passed or not based on the fact whether it is respected by the child project or not.
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
I'll check it Sir. Are you referring the Compile Output of Qt Creator?
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Quote:
15:54:01: Configuration unchanged, skipping qmake step.
Clean the project first.
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Hi Sir,
Here's the result after Cleaning and Building the project
COMPILE OUTPUT:
Reading C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB2/SUB2.pro
Reading C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB3/SUB3.pro
16:15:42: The process "c:\qtsdk\desktop\qt\4.7.4\mingw\bin\qmake.exe " exited normally.
16:15:42: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
cd SUB1\ && C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile
mingw32-make.exe[1]: Entering directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB1'
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug
mingw32-make.exe[2]: Entering directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB1'
c:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\uic.exe sub1.ui -o ui_sub1.h
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\main.o main.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\sub1.o sub1.cpp
C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -D__GNUC__ -DWIN32 sub1.h -o debug\moc_sub1.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\moc_sub1.o debug\moc_sub1.cpp
g++ -mthreads -Wl,-subsystem,windows -o debug\SUB1.exe debug/main.o debug/sub1.o debug/moc_sub1.o -L"c:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib
mingw32-make.exe[2]: Leaving directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB1'
mingw32-make.exe[1]: Leaving directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB1'
cd SUB2\ && C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile
mingw32-make.exe[1]: Entering directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB2'
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug
mingw32-make.exe[2]: Entering directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB2'
c:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\uic.exe sub2.ui -o ui_sub2.h
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\main.o main.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\sub2.o sub2.cpp
C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -D__GNUC__ -DWIN32 sub2.h -o debug\moc_sub2.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\moc_sub2.o debug\moc_sub2.cpp
g++ -mthreads -Wl,-subsystem,windows -o debug\SUB2.exe debug/main.o debug/sub2.o debug/moc_sub2.o -L"c:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib
mingw32-make.exe[2]: Leaving directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB2'
mingw32-make.exe[1]: Leaving directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB2'
cd SUB3\ && C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile
mingw32-make.exe[1]: Entering directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB3'
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug
mingw32-make.exe[2]: Entering directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB3'
c:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\uic.exe sub3.ui -o ui_sub3.h
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\main.o main.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\sub3.o sub3.cpp
C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -D__GNUC__ -DWIN32 sub3.h -o debug\moc_sub3.cpp
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCor e" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui " -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt " -I"debug" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\moc_sub3.o debug\moc_sub3.cpp
g++ -mthreads -Wl,-subsystem,windows -o debug\SUB3.exe debug/main.o debug/sub3.o debug/moc_sub3.o -L"c:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib
mingw32-make.exe[2]: Leaving directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB3'
mingw32-make.exe[1]: Leaving directory `C:/Users/aarrojo/Desktop/ROOT/ROOT/SUB3'
16:16:23: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited normally.
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Yeah, so it didn't work :)
You can do it this way, though:
qmake PATHSAMPLE=pathsampledir
Then qmake will be invoked with PATHSAMPLE=pathsampledir for all subprojects too.
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Hi Sir,
Where will i write this code "qmake PATHSAMPLE=pathsampledir" ?
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Either in the terminal or in QtCreator's project settings.
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Hi Sir,
Are you referring the terminal in LINUX/UBUNTU? Im using Windows Sir.
And for the Qt projects settings, is this the Qmake settings under Project Settings? Am i gonna include the "qmake PATHSAMPLE=pathsampledir" inside the "Additional Arguments"? Sorry for my questions Sir.
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
as wysota said you should do it qt command prompt click allprograms in qtcreator you can find qt command prompt and go to your working dir and do as wysota said
Re: Passing variables/paths from ROOT Project to SUBDIRECTORY Projects without PRI
Hi Sir Wysota,
I can now access the "PATHSAMPLE" from the subdirectory projects.
All I did was Add "PATHSAMPLE=pathsampledir" to Additional Arguments under Qmake settings in Project settings.
Thank you so much Sir. This really helps a lot.