Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How does AUTOMOC and CMake determine which sources toscan?

How does AUTOMOC and CMake determine which sources toscan?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 518 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.
  • S Offline
    S Offline
    snoriman
    wrote on last edited by
    #1

    This is somewhatrelated to my previous post here: https://forum.qt.io/topic/162686/cmake-and-automoc-syntax-error-constant-when-using-fetchcontent. The subject says it all: I'm trying to understand how CMake/AUTOMOC work.

    I was having an issue where AUTOMOC was being used on a FetchContent dependency. I think the reason for this was that I was using include_directories() to add a directory to this FetchContent dependency. I fixed this by using target_link_libraries(mylib PRIVATE sqlite) and then using mylib with my Qt app.

    Can someone explain how CMake/AUTOMOC work together in deciding which files to scan/include?

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

      It simply scans all source files.

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

      S 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        It simply scans all source files.

        S Offline
        S Offline
        snoriman
        wrote on last edited by snoriman
        #3

        @Christian-Ehrlicher What do you mean by "all files", I mean, it's not scanning my home dir :). I think there is more to it then that because how would adding include_directories() trigger automoc on an external dependency (FetchContent).

        Christian EhrlicherC 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          All files you added to the target

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

          1 Reply Last reply
          0
          • S snoriman

            @Christian-Ehrlicher What do you mean by "all files", I mean, it's not scanning my home dir :). I think there is more to it then that because how would adding include_directories() trigger automoc on an external dependency (FetchContent).

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @snoriman said in How does AUTOMOC and CMake determine which sources toscan?:

            think there is more to it then that because how would adding include_directories() trigger automoc on an external dependency (

            It does not.

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

            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