Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Easy cross platform way to detect architecture in Qt Pro or QMake system?
Forum Updated to NodeBB v4.3 + New Features

Easy cross platform way to detect architecture in Qt Pro or QMake system?

Scheduled Pinned Locked Moved Qt Creator and other tools
4 Posts 2 Posters 3.8k Views 1 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.
  • T Offline
    T Offline
    tmason101
    wrote on last edited by
    #1

    Hello,

    I am wondering how I can create a Qt Creator / Qmake .pro file which can detect whether I am building for a 32-bit or 64-bit environment

    See the following code below for my current, working .pro file. The section that I commented out is for 64-bit builds.

    *What I would love is that there is a way for the build system to detect the 64-bit section based on architecture and activate that section in the same way that I can activate the sections for debug versus release.

    Bonus if this can be cross-platform.

    Thank you for your time!*

    @
    #-------------------------------------------------

    Project created by QtCreator 2015-01-21T16:01:26

    #-------------------------------------------------

    QT += core gui xml network

    CONFIG += c++11

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = CoolApp
    TEMPLATE = app

    win32:RC_ICONS += Icons/CoolApp.ico

    VERSION += 1.0.1.0
    QMAKE_TARGET_COMPANY = "Standard Company"
    QMAKE_TARGET_DESCRIPTION = "My cool application."
    QMAKE_TARGET_COPYRIGHT = "Copyright 2015 Me."
    QMAKE_TARGET_PRODUCT = "Cool App"

    SOURCES += main.cpp
    qtprimaryapplicationwindow.cpp
    qtchoosecsvfiles.cpp
    qtviewconvertedfiles.cpp
    qtaboutapplicationdialog.cpp
    qtprocessingoptionsandoutput.cpp
    qtdeletablelistwidget.cpp
    qtprocessingoptionswidget.cpp
    qtapplicationsettings.cpp
    qtprocesscsvfiles.cpp
    qtapplicationupdate.cpp
    qtupdatedialog.cpp
    qtutilityfunctions.cpp

    HEADERS += qtprimaryapplicationwindow.h
    qtchoosecsvfiles.h
    qtviewconvertedfiles.h
    qtaboutapplicationdialog.h
    qtprocessingoptionsandoutput.h
    qtdeletablelistwidget.h
    qtprocessingoptionswidget.h
    qtapplicationsettings.h
    qtprocesscsvfiles.h
    qtapplicationupdate.h
    qtupdatedialog.h
    qtutilityfunctions.h

    FORMS += qtprimaryapplicationwindow.ui
    qtchoosecsvfiles.ui
    qtviewconvertedfiles.ui
    qtaboutapplicationdialog.ui
    qtprocessingoptionsandoutput.ui

    CONFIG(debug, debug|release) {

    LogoFiles.path = $$OUT_PWD/debug/Logos
    LogoFiles.files = Logos/*
    
    IconFiles.path = $$OUT_PWD/debug/Icons
    IconFiles.files = Icons/*
    
    LicenseFiles.path = $$OUT_PWD/debug/License
    LicenseFiles.files = License/*
    
    ConfigurationFiles.path = $$OUT_PWD/debug/Configuration
    ConfigurationFiles.files = Configuration/*
    

    } else {

    LogoFiles.path = $$OUT_PWD/release/Logos
    LogoFiles.files = Logos/*
    
    IconFiles.path = $$OUT_PWD/release/Icons
    IconFiles.files = Icons/*
    
    LicenseFiles.path = $$OUT_PWD/release/License
    LicenseFiles.files = License/*
    
    ConfigurationFiles.path = $$OUT_PWD/release/Configuration
    ConfigurationFiles.files = Configuration/*
    

    }

    #CONFIG(debug, debug|release) {

    LogoFiles.path = $$OUT_PWD/debug/Logos

    LogoFiles.files = Logos/*

    IconFiles.path = $$OUT_PWD/debug/Icons

    IconFiles.files = Icons/*

    LicenseFiles.path = $$OUT_PWD/debug/License

    LicenseFiles.files = License/*

    ConfigurationFiles.path = $$OUT_PWD/debug/Configuration

    ConfigurationFiles.files = Configuration/*

    #} else {

    LogoFiles.path = $$OUT_PWD/release/Logos

    LogoFiles.files = Logos/*

    IconFiles.path = $$OUT_PWD/release/Icons

    IconFiles.files = Icons/*

    LicenseFiles.path = $$OUT_PWD/release/License

    LicenseFiles.files = License/*

    ConfigurationFiles.path = $$OUT_PWD/release/Configuration

    ConfigurationFiles.files = Configuration/*

    #}

    INSTALLS += IconFiles LogoFiles LicenseFiles ConfigurationFiles
    @

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

      Hi,

      IIRC you can use

      @contains(QMAKE_TARGET.arch, x86_64) {
      // cool 64bit stuff
      }@

      for that

      Hope it helps

      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
      0
      • T Offline
        T Offline
        tmason101
        wrote on last edited by
        #3

        This works!

        What's great is that you can switch easily between 32-bit and 64-bit like so:

        @
        contains(QMAKE_TARGET.arch, x86_64) {
        // cool 64bit stuff
        }

        !contains(QMAKE_TARGET.arch, x86_64) {
        // cool 32bit stuff
        }
        @

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

          @
          contains(QMAKE_TARGET.arch, x86_64) {
          // cool 64bit stuff
          } else {
          // cool 32bit stuff
          }@

          Would be cleaner

          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