Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

FetchContent support #1063

Closed
Closed

Description

@valaxkong

I saw the README said glog can be incorporated into custom projects using the CMake command add_subdirectory. I tried it like this

FetchContent_Declare(
  glog
  GIT_REPOSITORY https://github.com/google/glog.git
  GIT_TAG        v0.6.0
)
FetchContent_GetProperties(glog)
if(NOT glog_POPULATED)
  FetchContent_Populate(glog)
  add_subdirectory(${glog_SOURCE_DIR})
endif()

When building as a submodule of my projects, I found those template codes in xxx.h.in files have not been replaced to generate xxx.h file. How to do things right? Thanks for your help.

Activity

  1. changed the title [-]Would you like to support FetchContent manner for CMake system?[/-] [+]FetchContent support[/+] on Jan 22, 2024
  2. valaxkong commented on Jan 22, 2024

    @valaxkong
    Author

    I found the solutions.

    FetchContent_Declare(
      glog
      GIT_REPOSITORY https://github.com/google/glog.git
      GIT_TAG        v0.6.0
    )
    FetchContent_GetProperties(glog)
    if(NOT glog_POPULATED)
      FetchContent_Populate(glog)
      add_subdirectory(${glog_SOURCE_DIR} ${glog_BINARY_DIR})
    endif()

    And I will give a PR later.

  3. sergiud commented on Jan 22, 2024

    @sergiud
    Contributor

    add_subdirectory mentioned in the docs does not use FetchContent. You need to specify the build directory only for the latter explicitly.

  4. sergiud commented on Jan 22, 2024

    @sergiud
    Contributor

    The issue is not actionable. You can however extend the README with a link to CMake reference documentation that explains how to use FetchContent correctly if you want.

  5. valaxkong commented on Jan 22, 2024

    @valaxkong
    Author

    @sergiud I opened a PR which gives an example to show the usage of FetchContent and add_subdirectory. #1067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions