Exclude source from build



  • Hi Folks,

    My use case is the following:
    I have some classes (source and header) that implement Windows, Linux or MAC dependent part.
    How should I edit my .pro file for exclude the appropriate classes from the build, BUT they stay there in the project side bar for reading or even editing them?
    Can I do this via the .pro file?

    Regards,
    Norbert


  • Moderators

    @moravas
    i can only think of something like this:

    win32 {
        SOURCES += win.cpp
    } else {
        OTHER_FILES += win.cpp
    }
    

  • Qt Champions 2016

    I scope them as @raven-worx shows for the different platforms, but I don't use OTHER_FILES, they are visible in my Creator (4.2) even if not built.


  • Moderators

    @kshegunov
    that was what he requested ... as i understood it?
    If i am wrong, remove the else part.


  • Qt Champions 2016

    Yes, I know, I meant that OTHER_FILES += win.cpp shouldn't be needed. At least I don't need it for the files to show in Creator. For example I have:

    macx {
        SOURCES += \
            $$PWD/qdaemoncontroller_osx.cpp \
            $$PWD/qdaemon_osx.cpp
    } else: unix {
        SOURCES += \
            $$PWD/qdaemoncontroller_linux.cpp \
            $$PWD/qdaemon_linux.cpp
    }
    

    and I see all of them in the sidebar regardless of the platform.


  • Moderators

    @kshegunov
    ah ok, didn't know that.


  • Qt Champions 2016

    This might've been a change between Creator versions, that's why I'm raising it as a point (and providing my IDE's version). I think that on older versions this wasn't the case.



  • Hi,

    It seems to be what I want.
    Thank you!

    Regards,
    Norbert


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.