Search code examples
c++qtvisual-c++g++qmake

qmake: handling options for both gcc and msvc


I would like to make a project file that would work both with msvc and gcc.

For instances, to optimize for speed you would do cl /O2 and g++ -O3.

But I don't know how to tell the project file to make the difference. I would like something like :

msvc:QMAKE_CXXFLAGS_RELEASE += /O2 /openmp /arch:AVX
else:QMAKE_CXXFLAGS_RELEASE += -O3 -march=native -fopenmp -D_GLIBCXX_PARALLEL

which doesn't work sadly.

Other way would be to change the mkspecs and bundle the new ones with my app, but it is not very portable. Thanks !


Solution

  • Jean, to be precise, you should use this based on your description:

    msvc:QMAKE_CXXFLAGS_RELEASE += /O2 /openmp /arch:AVX
    gcc:QMAKE_CXXFLAGS_RELEASE += -O3 -march=native -fopenmp -D_GLIBCXX_PARALLEL