cgreen: CMake cannot generate gitrevision.h when cgreen is git submodule

It seams CMake cannot generate gitrevision.h when cgreen is included as git submodule.

Steps to reproduce

  1. Create empty repo mkdir poc && cd poc && git init
  2. Add cgreen as submodule git submodule add https://github.com/cgreen-devs/cgreen.git
  3. Configure it cd cgreen && cmake .
  4. Build make

Actual Result

The make tool reports that there are no .git/logs/HEAD

make[2]: *** No rule to make target '.git/logs/HEAD', needed by 'gitrevision.h'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:1122: src/CMakeFiles/cgreen_shared.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Expected result

Cgreen is built.

Additional info

Looks like when cgreen is included as a submodule, it doesn’t contain real .git directory. Instead, it contains .git file that points to real cgreen’s .git directory.

I know, it is not documented way to use cgreen, but it is really convenient in a CI environment.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (11 by maintainers)

Most upvoted comments

Re: place of gitrevision.h - well, kind of. But since it is included by the source it will be harder (as in more un-natural) to find in the build directory, won’t it?

Aah, yes, I didn’t spot that, and so yes, it would be better to have it at repo root.