Skip to content

CMake FetchContent fails when called before idf_component_register (IDFGH-8469) #9929

@higaski

Description

@higaski

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

ESP-IDF v5.1-dev-992-gaf28c1fa21

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

No response

What is the expected behavior?

For some reason using the CMake FetchContent module before registering a component fails spectacularly.

include(FetchContent)  
FetchContent_Declare(...)

file(GLOB_RECURSE SOURCES *.c *.cpp)
idf_component_register(SRCS  ${SOURCES} ...)

What is the actual behavior?

CMake errors out. See "Build or installation Logs." for further details.

Steps to reproduce.

1.) Create new project from hello_world example
2.) Copy/paste any FetchContent_Declare call before idf_component_register, e.g:

      include(FetchContent)
      FetchContent_Declare(
        fmt
        GIT_REPOSITORY https://github.com/fmtlib/fmt.git
        GIT_TAG 9.1.0
        GIT_PROGRESS TRUE)
      FetchContent_MakeAvailable(fmt)

Build or installation Logs.

CMake Error at /home/vinci/esp/esp-idf/tools/cmake/component.cmake:224 (message):
  CMake Warning (dev) at build_properties.temp.cmake:8:

    Syntax Warning in cmake code at column 47

  

    Argument not separated from preceding token by whitespace.

  Call Stack (most recent call first):

    /home/vinci/esp/esp-idf/tools/cmake/scripts/component_get_requirements.cmake:3 (include)

  This warning is for project developers.  Use -Wno-dev to suppress it.

  

  fatal: not a git repository (or any parent up to mount point /)

  Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

  CMake Error at /usr/share/cmake/Modules/FetchContent.cmake:1149
  (define_property):

    define_property command is not scriptable

  Call Stack (most recent call first):

    /usr/share/cmake/Modules/FetchContent.cmake:1300:EVAL:1 (__FetchContent_declareDetails)
    /usr/share/cmake/Modules/FetchContent.cmake:1300 (cmake_language)
    /home/vinci/Develop/VSCode/hello_world/main/CMakeLists.txt:2 (FetchContent_Declare)
    /home/vinci/esp/esp-idf/tools/cmake/scripts/component_get_requirements.cmake:106 (include)
    /home/vinci/esp/esp-idf/tools/cmake/scripts/component_get_requirements.cmake:124 (__component_get_requirements)

More Information.

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions