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. How to prevent change to CMakeLists.txt when adding a new class?
Qt 6.11 is out! See what's new in the release blog

How to prevent change to CMakeLists.txt when adding a new class?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
3 Posts 2 Posters 1.1k 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.
  • H Offline
    H Offline
    hs_bx
    wrote on last edited by
    #1

    I'm using Qt Creator to work on a non-QT cmake project that uses file(GLOB_RECURSE VAR *.cpp) instead of listing source files explicitly.

    When I add a new class with Qt Creator it opens my CMakeLists.txt and inserts the newly created files into the add_executable directive.

    Example, existing CMakeLists.txt:

    cmake_minimum_required(VERSION 3.5)
    
    project(qt-cmake-test LANGUAGES CXX)
    
    file(GLOB_RECURSE FOO_SRC Foo/*.cpp Foo/*.h)
    add_executable(qt-cmake-test ${FOO_SRC})
    

    When I use the Wizard to add a new class Something in folder Foo/, Qt Creator opens CMakeLists.txt and changes the last line to:

    add_executable(qt-cmake-test ${FOO_SRC}
        Foo/Something.h Foo/Something.cpp)
    

    Now I have to delete those changes again. I could select "Add to project: <None>" on the last page of the Add Class Wizard but it does not remember that choice for next time and also still opens CMakeLists.txt (without modifying it).

    Is it possible to achieve some or all of the following?

    • disable automatic modifications to CMakeLists.txt
    • make Qt Creator remember the choice "Add to project: <None>" in the Add Class Wizard
    • disable opening of (and switching to) CMakeLists.txt, especially if no modifications were made
    • trigger an automatic re-run of CMake after adding a new class
    cristian-adamC 1 Reply Last reply
    0
    • H hs_bx

      I'm using Qt Creator to work on a non-QT cmake project that uses file(GLOB_RECURSE VAR *.cpp) instead of listing source files explicitly.

      When I add a new class with Qt Creator it opens my CMakeLists.txt and inserts the newly created files into the add_executable directive.

      Example, existing CMakeLists.txt:

      cmake_minimum_required(VERSION 3.5)
      
      project(qt-cmake-test LANGUAGES CXX)
      
      file(GLOB_RECURSE FOO_SRC Foo/*.cpp Foo/*.h)
      add_executable(qt-cmake-test ${FOO_SRC})
      

      When I use the Wizard to add a new class Something in folder Foo/, Qt Creator opens CMakeLists.txt and changes the last line to:

      add_executable(qt-cmake-test ${FOO_SRC}
          Foo/Something.h Foo/Something.cpp)
      

      Now I have to delete those changes again. I could select "Add to project: <None>" on the last page of the Add Class Wizard but it does not remember that choice for next time and also still opens CMakeLists.txt (without modifying it).

      Is it possible to achieve some or all of the following?

      • disable automatic modifications to CMakeLists.txt
      • make Qt Creator remember the choice "Add to project: <None>" in the Add Class Wizard
      • disable opening of (and switching to) CMakeLists.txt, especially if no modifications were made
      • trigger an automatic re-run of CMake after adding a new class
      cristian-adamC Offline
      cristian-adamC Offline
      cristian-adam
      wrote on last edited by
      #2

      @hs_bx Only if you create a bugreport / suggestion 😬

      H 1 Reply Last reply
      1
      • cristian-adamC cristian-adam

        @hs_bx Only if you create a bugreport / suggestion 😬

        H Offline
        H Offline
        hs_bx
        wrote on last edited by
        #3

        Done: https://bugreports.qt.io/browse/QTCREATORBUG-30445

        1 Reply Last reply
        1

        • Login

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