Qt Creator Cmake Fail



  • I have a cmake project which I can build no problem on the command line with the following CMakeList.txt file:

     cmake_minimum_required(VERSION 3.7.1)
      project(configui)
      set(CMAKE_PREFIX_PATH /Users/jonathangerber/Qt/5.7/clang_64/)
      # Tell CMake to run moc when necessary:
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTOUIC ON)
      # As moc files are generated in the binary dir, tell CMake
      # to always look for includes there:
      set(CMAKE_INCLUDE_CURRENT_DIR ON)
    
      # Widgets finds its own dependencies.
      find_package(Qt5Widgets REQUIRED)
    
      file(GLOB cpps ../*.cpp)
      file(GLOB hpps ../*hpp)
      add_executable(resmanconfig ${cpps} ${hpps})
    
      qt5_use_modules(resmanconfig Widgets)
    

    I create a build directory in my project, cd into it and run cmake .., then make

    It builds without a problem.

    However, the same cannot be said for using Qt Creator. Attempting to load a CMakeLists.txt file It pops up the CMake GUI I point it at my build and source directories, hit configure and generate, then close it.
    Qt Creator pops up a dialog saying that it cannot find the executable ( weird because make hasn't been run so there is no executable yet ). If I run make on the command line and then point it at an executable , it crashes.

    don't know what I am doing wrong here. As a point of reference, CLion just works out of the box with the same CMakeLists.txt file. No muss no fuss....

    Is there some obvious step i am missing?



  • When you tell QtCreator where cmake is are you giving it command line version (in Options->Build & Run -> CMake)? cmake not ccmake or cmake-gui. Support for cmake has been improved in recent versions of QtCreator, so you might want to upgrade to the latest. I'm not surprised that it crashes in the last situation you mention (compile and run on command line) since it probably tries to use your system Qt instead of your local version. When it's working in QtCreator and you run within QtCreator, it will use the version you specify in your CMakeLists.txt.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    I'd remove the CMAKE_PREFIX_PATH from the CMakeLists.txt. Qt Creator sets this variable for you based on the Kit you are using so you don't have to fiddle with that variable.


  • Moderators

    @jlgerber First off I would just use clion. ;) It's an awesome IDE, no real need for Creator if you have that.

    Now on to the problem, can we see the actual error message? Screen shot maybe?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.