Important: Please read the Qt Code of Conduct -

CMake CUDA QTCreator

  • OK so i setup a cmake project in QTCreator and my cuda program compiles correctly.
    But I get a warning: This file is not part of any project. The code model might have issues parsing this file properly.

    also qt creator goes not give any include headers in the auto complete.

    cmake tells me this is enough but i d like to get atlest come kind of code completion. can i fix this in any way?
    link text

    this is the contents of my cmake file

    cmake_minimum_required(VERSION 3.17)
    project(cutest LANGUAGES CUDA)

  • ok late reply. found an easy fix for this. go to
    Tools -> Options -> Environment -> MIME Types

    type .cu in the Filter tab. (just to search for the right type)
    click on text/vnd.nvidia.cuda.csrc and clear the*.cu in the patterns tab.

    now type c++ in the Filter tab.
    click on text/x-c++src and add*.cu;*.cuh in the patters tab. dont clear whats alredy here.

  • This "solution" is just to enable syntax highlighting. Try the following very basic code:

    __global__ void hello() {
        printf("This is a test");
    int main(int argc, char* argv[])
        return 0;

    The code above is a very basic example for CUDA source file that includes a kernel definition and will cause a lot of problems with Qt Creator. I am guessing the same will happen if we use __device__. Adjusting the MIME type for C++ to include CUDA helps only with the syntax highlighting. Ultimately CUDA, while being very, very similar to C/C++, is a different language that requires its own language model that is not included in Qt Creator as well as a compiler, which - through CMake - can somewhat be integrated into the IDE. If you want to develop with CUDA and CMake I would suggest using VS Code or Visual Studio with the second still (2019 edition) having a not that great support for CMake). Last but not least the devs from NVidia have done a really sloppy job in regards to offering integration of the CUDA infrastructure in popular IDEs. It takes hours if not days to make a setup that just works.