[Scons-users] qt5 question: how to handle header files in separate directories?
B.W.H. van Beest
bwvb at xs4all.nl
Tue Aug 5 13:14:09 EDT 2014
Hello Dirk,
Thanks for your response. It pointed me to how to approach the problem,
although I ended up with a completely different solution.
As it turned out, the solution seems to be quite simple, and no
additional functions need to be available.
To share my solution, have a look below the ==== line.
It would be even simpler, and very natural, if the function Moc5(...)
could take a list of files ...
Would that be possible?
Kind Regards,
Bertwim
================
The source tree of the library I'm building looks like:
..../MYPROJECT/include/<dir>/*.h // header files exposing API
..../MYPROJECT/src/<dir>/*.cpp , *.h // sources files + internal
headers.
where <dir> is one of a set of directories, together containing the
source files for the library to built.
The scons files are:
..../MYPROJECT/src/SConstruct
..../MYPROJECT/src/<dir>/SConscript
The SConstruct file has the qt5 tool initialisation code, as described
in the qtt tool guidel.
The SConscript files have a code snippet like:' ('gexplorer' is just one
of the directories <dir>)
#-----------------------------------------------------------------------------
# Source files
cppsources = Glob( '*.cpp' )
qrcsources = Glob( '*.qrc' )
# Assume all header files in "../../include to be moc-ed ...
mocsources = Glob( '../../include/gexplorer/*.h' )
mocresults = ""
for sss in mocsources:
mocresults += localenv.Moc5( sss )
# Targets: link and install
lib = localenv.SharedLibrary( target='gexplorer', source = cppsources +
qrcsources + mocresults )
dir = localenv.Install( localenv['DESTLIB'], source = lib )
localenv.Default( dir )
-----------------------------------------------------------------------------------
On 08/04/2014 09:31 PM, Dirk Bächle wrote:
> Hi Bertwin,
>
> thanks for coming over to the User mailing list.
>
> On 04.08.2014 20:38, B.W.H. van Beest wrote:
>> Hello, I have a question on the use of QT together with scons.
>> I am trying to use the tool 'qt5' to this end.
>>
>> In my case, I have header files (containing Q_OBJECT) residing in a
>> directory that is different from where the corresponding
>> implementation files reside. This situation is typical for the source
>> code of a library when you don't want to expose /all/ header files,
>> but only the ones that matter for the consumers of the library.
>>
>> I tried things like putting env.Moc5( "../include/*.h" ) in the
>> SConscript file, but I just cannot make it work. Bottomline is that
>> the generated moc_binaries never are linked together with the end
>> target, I always get linker errors.
>>
>> Are there any suggestions? Kind Regards,
>>
>
> Please find a simple example project for Qt4 attached, and check
> whether the structure is similar to your actual setup. I hope it gives
> you some new ideas at least.
>
> Best regards,
>
> Dirk
>
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20140805/9de29c70/attachment.html>
More information about the Scons-users
mailing list