.pro file win32 and unix conditionals



  • Hello,
    I am writing an app that is unix and windows but requires specific include of file for both platforms. I have some conditional includes in the .pro file and some command calls with system . So assume the project file:

    TEMPLATE = app
    CONFIG += console c++11
    CONFIG -= app_bundle
    CONFIG -= qt
    
    unix{
        message("UNIX")
        LIBS += -lglfw
        LIBS += -lm
        LIBS += -lGL
        LIBS += -lGLEW
    }
    
    win32{
        message("WIN32")
        LIBS += -ld3d9
    }
    
    HEADERS += \
        framework/app.h \
        framework/window.h \
        framework/renderer.h \
        framework/vbo.h \
        utils/utils.h \
        vertex.h \
        models.h \
        logger.h \
        shaderbinary.h \
        framework/shader.h
    
    unix{
        HEADERS +=      glfw/glfwwindow.h \
                        ogl/glrenderer.h \
                        ogl/glapp.h \
                        ogl/texture.h \
                        ogl/glprogram.h \
                        ogl/glvbo.h
    
        SOURCES += glfw/glfwwindow.cpp \
                    ogl/glapp.cpp \
                    ogl/glrenderer.cpp \
                    ogl/texture.cpp \
                    ogl/glprogram.cpp \
                    ogl/glvbo.cpp \
    }
    
    win32{
        HEADERS += \
        winctx/win32window.h \
        winapp/win32app.h \
        d3d/d3drenderer.h \
        d3d/d3dvbo.h
    
        SOURCES +=  winctx/win32window.cpp \
        winapp/win32app.cpp \
        d3d/d3drenderer.cpp \
        d3d/d3dvbo.cpp
    }
    
    SOURCES += main.cpp \
        framework/app.cpp \
        utils/utils.cpp \
        vertex.cpp \
        models.cpp \
        utils/logger.cpp \
    
    
    
    DISTFILES += \
        shaders/vertex.frag \
        shaders/fragment_copy.frag \
        shaders/fragment.frag \
        shaders/vertex.vert \
        textures/wall_512_1_05.tga \
        textures/wall_512_2_05.tga \
        textures/wall_512_3_05.tga \
        textures/wall_512_4_05.tga \
        textures/wall_512_5_05.tga \
        textures/wall_1024_05.tga \
        textures/wall_1024_ivy_05.tga \
        textures/wall_1024_tex1_05.tga
    
    RES_DIR = $${OUT_PWD}
    SHADERS =$${_PRO_FILE_PWD_}/shaders/glsl
    TEXTURES =$${_PRO_FILE_PWD_}/textures
    
    unix{
    system($${_PRO_FILE_PWD_}/tools/g2bin $${SHADERS}/vertex.vert vertex1)
    system($${_PRO_FILE_PWD_}/tools/g2bin $${SHADERS}/fragment.frag frag1)
    system($${_PRO_FILE_PWD_}/tools/linksource $${_PRO_FILE_PWD_}/shaderbinary.h $${_PRO_FILE_PWD_}/vertex1.c $${_PRO_FILE_PWD_}/frag1.c)
    }
    
    win32{
    system($${_PRO_FILE_PWD_}/tools/g2binwin $${SHADERS}/vertex.vert vertex1)
    system($${_PRO_FILE_PWD_}/tools/g2binwin $${SHADERS}/fragment.frag frag1)
    system($${_PRO_FILE_PWD_}/tools/linksourcewin $${_PRO_FILE_PWD_}/shaderbinary.h $${_PRO_FILE_PWD_}/vertex1.c $${_PRO_FILE_PWD_}/frag1.c)
    }
    
    
    QMAKE_POST_LINK += $$quote(cp -rvf $${SHADERS} $${RES_DIR}$$escape_expand(\n\t))
    message("[INFO] Will copy $${SHADERS} to $${RES_DIR}")
    
    QMAKE_POST_LINK += $$quote(cp -rvf $${TEXTURES} $${RES_DIR}$$escape_expand(\n\t))
    message("[INFO] Will copy $${SHADERS} to $${RES_DIR}")
    
    #QMAKE_POST_LINK += $$quote(rm $${OUT_PWD}/*.c$$escape_expand(\n\t))
    

    It's okay in my unix machine, but on windows when I am using MinGW the "unix" tag reports me that I am on both windows and linux. Any other check to ensure I am only on Win32 machine. Thanks.


  • Lifetime Qt Champion

    Hi,

    You can use something like win32-msvc* for Microsoft specific stuff or add !win32-g++ for "non-Windows" unix scopes.

    You can also use the scope else construct e.g.

    win32 {
    # my win32 specifics
    } else {
    # All other platforms.
    }
    


  • @SGaist Thanks I will try the scope else construct. Hope that will solve the problem. However I didn't knew win32-msvc or win32-g++ Are they valid in .pro file?


  • Lifetime Qt Champion

    win32-g++ is for MinGW

    win32-msvc-something is for Visual Studio where you replace something with the matching version of Visual Studio.

    Yes they are.


Log in to reply
 

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