Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 4,166
    • Issues 4,166
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #21748
Closed
Open
Issue created Jan 27, 2021 by Arcturus@arcturus140Contributor

FetchContent and ExternalProject fail when SOURCE_DIR changes

I open this issue in response to https://discourse.cmake.org/t/error-pathspec-did-not-match-any-file-s-known-to-git. Changing SOURCE_DIR for fetch content or external project results in fatal error for git. The only way to recover from this state is by manually deleting files inside the build directory.

a minimal example:

cmake_minimum_required( VERSION 3.16 )
project(MyProj VERSION 0 LANGUAGES NONE)
include(FetchContent)
FetchContent_Declare(myscript
  GIT_REPOSITORY git@gist.github.com:76c2097a0b6a74c870f6b50c2cf1f470.git
  SOURCE_DIR foo)

# FetchContent_GetProperties(myscript)
# if( NOT cmakebuild_POPULATED )
# 	FetchContent_Populate(myscript)
# endif()
FetchContent_MakeAvailable(myscript)

results in error: error: pathspec did not match any file(s) known to git

another example:

cmake_minimum_required( VERSION 3.16 )
project(MyProj VERSION 0 LANGUAGES NONE)
include(ExternalProject)
ExternalProject_Add(myscript
	GIT_REPOSITORY 	git@gist.github.com:76c2097a0b6a74c870f6b50c2cf1f470.git
	SOURCE_DIR        ${CMAKE_CURRENT_LIST_DIR}/foo
	CONFIGURE_COMMAND ""
	BUILD_COMMAND     ""
	INSTALL_COMMAND   ""
)

results in error: Failed to get the hash for HEAD

my setup: CMake 3.19, Gnu Makefile generator, Linux 64b

Edited Jan 29, 2021 by Craig Scott
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking