5

I compiling for QNX, ARM, My Host platform can be Win32/64 , Linux or Mac I want to find a way to see wheat is my host platform in my PRO file (on computer I building my project)

Apparently using:

win32 {}
unix {}
macx {}

does not work because on different OSes it will always report unix, so I assume this is target platform So what is the way to obtain current host platform to make PRO file flexible because on different platform I would like to do different things.

Thank you

xchg.ca
  • 1,154
  • 2
  • 15
  • 28
  • Those are for the **target**, which is QNX/ARM. You can look at the *HOST* variables in [configuring Qmake](http://qt-project.org/doc/qt-5/qmake-environment-reference.html). I don't know if the project files have conditional syntax for the host OS like you show for the target. Try `message(Host: $$[QT_HOST_PREFIX])` for example. Btw, I guess tag [tag:qt5] is relevant or are you on Qt4? – artless noise Sep 18 '14 at 17:10
  • Sure it one of the options! I think $$[QMAKE_SPEC] would be a bit better in my case. – xchg.ca Sep 23 '14 at 20:44

2 Answers2

8

Maybe QMAKE_HOST variable is the answer to your question?

Here's information from official Qt documentation:

QMAKE_HOST

Provides information about the host machine running qmake. For example, you can retrieve the host machine architecture from QMAKE_HOST.arch.

  • .arch - Host architecture
  • .os - Host OS
  • .cpu_count - Number of available cpus
  • .name - Host computer name
  • .version - Host OS version number
  • .version_string - Host OS version string

win32-g++:contains(QMAKE_HOST.arch, x86_64):{ message("Host is 64bit") ... }

Alexandr Zarubkin
  • 899
  • 1
  • 11
  • 26
4

Could not get anything better then:

QMAKE_SPEC_T = $$[QMAKE_SPEC]

contains(QMAKE_SPEC_T,.*win32.*){
    HOST_PLATFORM=WIN
    IS_WIN = 1
}

contains(QMAKE_SPEC_T,.*macx.*){
    HOST_PLATFORM=MAC
    IS_MAC = 1
}

contains(QMAKE_SPEC_T,.*linux.*){
    HOST_PLATFORM=LINUX
    IS_LINUX = 1
}

and then anywhere to check:

!isEmpty(IS_WIN):message($${HOST_PLATFORM})
!isEmpty(IS_MAC):message($${HOST_PLATFORM})
!isEmpty(IS_LINUX):message($${HOST_PLATFORM})
xchg.ca
  • 1,154
  • 2
  • 15
  • 28