Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. .pro file win32 and unix conditionals
Forum Updated to NodeBB v4.3 + New Features

.pro file win32 and unix conditionals

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 5.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ilian
    wrote on last edited by A Former User
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.
      }
      

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      I 1 Reply Last reply
      3
      • SGaistS SGaist

        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.
        }
        
        I Offline
        I Offline
        ilian
        wrote on last edited by
        #3

        @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?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved