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. Setting up QtCreator to correctly work with CMake
QtWS25 Last Chance

Setting up QtCreator to correctly work with CMake

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 1.8k Views
  • 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.
  • J Offline
    J Offline
    Justin Sayne
    wrote on last edited by
    #1

    Hi,

    my setup:
    Qt Creator 4.5.1
    CMake 3.9.4

    I'm trying to get a simple CMake HelloWorld to build with QtCreator. I just have a HelloWorld.cpp and a CMakeLists.txt with the following contents:

    #include<iostream>
     
    int main(int argc, char *argv[]){
       std::cout << "Hello World!" << std::endl;
       return 0;
    }
    
    cmake_minimum_required(VERSION 3.9.4)
    project (hello)
    add_executable(hello helloworld.cpp)
    

    If I import the CMakeLists.txt into QtCreator it tells me the file has successfully been parsed and I'm asked to select a Qt kit for building, in my case Qt 5.9.2 msvc2017.

    First weird thing happening. My project view looks like this:
    0_1519386476862_project_view.png
    Why is every file showing up 4 times?

    If I then try to build my project, it fails with the inexpressive message "File not found: MSBUILD"
    After digging around, I found out it's because the default build step for all of the 5 targets (default, Release, Debug, RelWithDebugInfo, MinSizeRelease) is cmake --build . --target all and the system is then missing a project file all.vcxproj, so I have to manually change this to sth reasonable for my project (why?)

    Still, building works then but again, I have 4 run configurations for my project each of them with the exact same parameters. None of them works however because they all point the the following directory:

    <my project root>\build-helloworld-Qt_5_9_2_msvc2017_64-Debug\RelWithDebInfo\hello.exe
    

    and none of them builds there. I.e. the run config for RelWithDebugInfo builds in

    <my project root>\build-helloworld-Qt_5_9_2_msvc2017_64-Release with Debug Information\Debug
    

    I tried to generate a new run configuration adjusting the output path but if I try to run this one, it also fails with the error message:

    You asked to build the current Run Configuration's build target only, but it is not associated with a build target. Update the Make Step in your build settings.
    

    So everything appears to be totally messed up. What am I doing wrong here?!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #2

      For the kit you selected, what is the 'CMake Generator' set to? You probably want to set it to 'NMake Makefiles'

      Go to options ->Build & Run -> Kits
      For your selected kit, go down to the 'CMake Generator' setting and hit the 'Change' button on the far right and change the generator to 'NMake Makefiles'.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved