AUTOMOC is applied to SQLite3 sources when added as dependency resulting in compile error

This is kind of a silly one. Whenever I add SQLite via FetchContent and I’m building a Qt project I run into the following error:

sqlite\version(1,1): error C2059: syntax error: 'constant'

It seems that automoc is applied to the the sqlite sources somehow. Using a custom SOURCE_DIR seems to trigger this behavior. Removing SOURCE_DIR fixes the issue.

set(sqlite_prefix ${CMAKE_CURRENT_BINARY_DIR}/sqlite)

include(FetchContent)

FetchContent_Declare(
  sqlite-sources
  URL https://www.sqlite.org/2025/sqlite-autoconf-3500100.tar.gz
  DOWNLOAD_EXTRACT_TIMESTAMP FALSE
  SOURCE_DIR ${sqlite_prefix}
)

FetchContent_MakeAvailable(sqlite-sources)

include_directories(${sqlite_prefix}/)
add_library(sqlite STATIC ${sqlite_prefix}/sqlite3.c)

Why is automoc run over sqlite when I use SOURCE_DIR?

Based on just the code sample provided (we can’t see what the rest of your project is doing, such as how anything Qt-related is being set up), I’d guess it relates to the include_directories(${sqlite_prefix}/) call as well. If you remove that, what happens?