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 add existing files to a CMake project?
Forum Updated to NodeBB v4.3 + New Features

How to add existing files to a CMake project?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 4 Posters 4.4k Views 1 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.
  • idlefrogI Offline
    idlefrogI Offline
    idlefrog
    wrote on last edited by idlefrog
    #1

    Having converted to CMake. Does QtCreator allow you to add existing files to 'Sources'? This option is always greyed out from the project view context menu.
    Or should we always manually edit our CMakeLists.txt files?

    [QtCreator 4.15]

    cristian-adamC 1 Reply Last reply
    1
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @idlefrog said in How to add exiting files to a CMake project?:

      Or should we always manually edit our CMakeLists.txt files?

      You have to add them manually. Adding them automatically isn't really possible since the list of sources can be gathered from everywhere.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      idlefrogI 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        @idlefrog said in How to add exiting files to a CMake project?:

        Or should we always manually edit our CMakeLists.txt files?

        You have to add them manually. Adding them automatically isn't really possible since the list of sources can be gathered from everywhere.

        idlefrogI Offline
        idlefrogI Offline
        idlefrog
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thank you for the help & quick response!
        Now I've just got to understand why (after converting to cmake) I get the dreaded 'undefined reference to vtable for ...'
        I did think just run 'cmake'... but no change...any ideas?
        Sorry.. am a CMake beginner!

        jsulmJ 1 Reply Last reply
        0
        • idlefrogI idlefrog

          @Christian-Ehrlicher Thank you for the help & quick response!
          Now I've just got to understand why (after converting to cmake) I get the dreaded 'undefined reference to vtable for ...'
          I did think just run 'cmake'... but no change...any ideas?
          Sorry.. am a CMake beginner!

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @idlefrog Did you set AUTOMOC as suggested here: https://cmake.org/cmake/help/latest/prop_tgt/AUTOMOC.html ?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          idlefrogI 1 Reply Last reply
          3
          • jsulmJ jsulm

            @idlefrog Did you set AUTOMOC as suggested here: https://cmake.org/cmake/help/latest/prop_tgt/AUTOMOC.html ?

            idlefrogI Offline
            idlefrogI Offline
            idlefrog
            wrote on last edited by
            #5

            @jsulm Arrr!... Yes, sorry. Sometimes its probably best stepping back & having a coffee-break, (rather than stressing and staring wildly at the screen!).
            Many thanks!

            1 Reply Last reply
            0
            • idlefrogI idlefrog

              Having converted to CMake. Does QtCreator allow you to add existing files to 'Sources'? This option is always greyed out from the project view context menu.
              Or should we always manually edit our CMakeLists.txt files?

              [QtCreator 4.15]

              cristian-adamC Offline
              cristian-adamC Offline
              cristian-adam
              wrote on last edited by
              #6

              Qt Creator 11 will add the source files to the CMakeLists.txt. See below an example of a Widgets application:

              alt text

              1 Reply Last reply
              2

              • Login

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