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. Qt Creator Cmake Fail
Forum Updated to NodeBB v4.3 + New Features

Qt Creator Cmake Fail

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 4 Posters 3.0k Views 2 Watching
  • 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
    jlgerber
    wrote on last edited by
    #1

    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?

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

      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.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • J jlgerber

          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?

          A Offline
          A Offline
          ambershark
          wrote on last edited by
          #4

          @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?

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          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