Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Customize my pro file according to my compiler



  • Hello Everyone,

    I am not an expert on compiling, and I have succeeded so far in using QT for building and running my code without requiring to go deep into compiling matters.

    I have recently interested myself to CUDA for optimizing my code, and I am now at the step of running CUDA code into my QT applications. So far I had no problem, there are resources on the Net which explain how to proceed, and I succeeded in sketching a .pro file which allowed me to integrate CUDA code into my C++ QT code. So far so good!

    However, in order to run CUDA, I need to recompile all my code with the Visual Studio Compiler, instead of MinGW. Ideally, I would like to keep the two installations , I mean having in separate folders object files compiled with the two compilers, and in separate binary folders the executables. This would allow me to benchmark the use of CUDA, vs not using it, for both compiler implementation.

    So far, I have always managed in tackling these issues by writing into the .pro file, I mean by specifying the variables OBJECTS_DIR and DEST_DIR. I had to do so because my code comprises several DLLs, which have to be in the same folder as the final binary.

    So I thought of a possibility to define OBJECTS_DIR and DEST_DIR conditionally to my compiler (and of course to the Debug|Release). I don't know if there is a way to do so in QT. Before digging too far into unknown areas, I thought that I could ask you guys the question of whether this is possible, and f not what approach is appropriate in QT.

    Many thanks by advance for your answer.


  • Lifetime Qt Champion

    These scopes for the compilers matches what you can find in the mkspecs folder in your Qt installation. Like win32-msvc and win32-g++.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You are looking for the scopes in qmake. See the documentation. Both the debug/release selection and platform scopes are described there in details.



  • Hi SGaist

    And thanks for your quick answer. Well I had a look at your doc and it doesn't learn me anything more than what I already know and used for my CUDA implementation.

    The conditions which are explained in the doc are win32/mac/linux and Debug/Release.

    My question is: where can I find a condition on the compiler (MSVC/MinGW)? If you have an answer for that I would be much welcome!


  • Lifetime Qt Champion

    These scopes for the compilers matches what you can find in the mkspecs folder in your Qt installation. Like win32-msvc and win32-g++.



  • Many thanks SGaist (and sorry for having mispelled your name in my previous answer).

    I have had a look at the mkspecs folder in the QT installation and I now understand much better the documentation. I had skipped this mkspecs part in my previous reading... sorry for that.

    Thanks again for your help.


  • Lifetime Qt Champion

    @KMead said in Customize my pro file according to my compiler:

    Many thanks SGaist (and sorry for having mispelled your name in my previous answer).

    You're welcome ! No worries for the spelling, if you want, you can edit your old posts to fix things :-)

    Now that you have things going the way you want it, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)


Log in to reply