How not to be in "detached head" state, after CMake FetchContent through Git?

Viewed 205

I use CMake's FetchContent_Declare and FetchContent_Populate to download dependencies from a Git repository. It looks like this:

FetchContent_Declare(my_subproject
    GIT_REPOSITORY http://127.0.0.1/my_subproject.git
    GIT_TAG master
)

FetchContent_GetProperties(my_subproject)
if(NOT my_subproject_POPULATED)
    FetchContent_Populate( my_subproject )
endif()

target_link_libraries ( ${EXE_TARGET} my_subproject )

The download/clone looks fine, but my_subproject is in detached head state: it is pointing to "origin/master", instead of pointing to the local "master" branch.

Any tip on how to make "FetchContent_Populate" point to the local "master" branch?

I'm using CMake 3.21.1. This "issue" does not happen with CMake 3.17.2.

0 Answers
Related