PDA

View Full Version : Platform dependent source files: what is best?



ucomesdag
27th November 2006, 07:23
I'm writting somthing that runs on windows/mac osx/linux.
If got one set of source filles that is dependent on the platform ho do i best include them?

win32 {
#LIBS += ./WinMM.Lib
HEADERS += ./windows/midiIO.h
SOURCES += ./windows/midiIO.cpp
message(Including Windows specifique headers and sources...)
}
unix {
HEADERS += ./linux/midiIO.h
SOURCES += ./linux/midiIO.cpp
message(Including Linux specifique headers and sources...)
}
macx {
HEADERS += ./macosx/midiIO.h
SOURCES += ./macosx/midiIO.cpp
message(Including Mac OS X specifique headers and sources...)
}
If I put it like this in their own sub dir. it complains that it cant find #include "midiIO.h" when compiling so I have to include with the path to the sub dir. #include "windows/midiIO.h" so I have to change the include on every platform....????? :confused:

I'm a bit lost....
....any advise???

munna
27th November 2006, 08:14
this can help




win32 {
INCLUDEPATH += ./windows
...
}

unix {
INCLUDEPATH += ./linux
...
}

macx {
INCLUDEPATH += ./macosx
...
}

wysota
27th November 2006, 11:01
You can write yourself a macro (function) which will expand differently depending on the platform. See qmake docs for details.

ucomesdag
27th November 2006, 15:18
Is there a way to it without writting macros? It is still complaining about it can not finding the header files. Adding the path takes out the whole use fullness. Otherwise it's easier to replace manually the platfrom dependent files.

BTW I cant find the part about writting macros in the qmake manual, can you please point me at it, cause google won't...

I dont see the usefullness of telling qmake wich files to add if you have to write macros to include the correct file... Than a macro only would do it (if I could find the maco part in the manual)...

Maybe I'm missing something? I would prefer to do it without macros but how? Anyone?


win32 {
LIBS += WinMM.Lib
HEADERS += ./windows/midiIO.h
SOURCES += ./windows/midiIO.cpp
INCLUDEPATH += ./windows
message(Including Windows specifique headers and sources...)
}
unix {
HEADERS += ./linux/midiIO.h
SOURCES += ./linux/midiIO.cpp
INCLUDEPATH += ./unix
message(Including Linux specifique headers and sources...)
}
macx {
HEADERS += ./macosx/midiIO.h
SOURCES += ./macosx/midiIO.cpp
INCLUDEPATH += ./macosx
message(Including Mac OS X specifique headers and sources...)
}

adding INCLUDEPATH does the job... All fine now!

patrik08
27th November 2006, 17:47
I'm writting somthing that runs on windows/mac osx/linux.
If got one set of source filles that is dependent on the platform ho do i best include them?

win32 {
}
unix {

}
macx {

}
If I put it like this in their own sub dir. it complains that it cant find #include "midiIO.h" when compiling so I have to include with the path to the sub dir. #include "windows/midiIO.h" so I have to change the include on every platform....????? :confused:

I'm a bit lost....
....any advise???


i use on pro file the include params...

!include( win.pri ) : error( Unable to find win config )
!include( mac.pri ) : error( Unable to find mac config )
!include( linux.pri ) : error( Unable to find ubuntu config )

so if i append on file or moore by
qmake -project

i must past only 3 line.... :-) and i can recycle the pri file contains os libs e other.... include dir...

wysota
27th November 2006, 19:52
I would prefer to do it without macros but how? Anyone?

By a macro I meant a qmake macro, not an #ifndef section... There is nothing wrong with such macros if they are to ease your job.