[Doc] Capturing Git scm information when `conanfile.py` is in subfolder
- Dominant language
- C++
- Stars
- 125
- Forks
- 382
- Avg merge
- 22h 39m
- Merged PRs (30d)
- 21
Description
Hi,
we are using the [Capturing Git scm information](https://docs.conan.io/2/examples/tools/scm/git/capture_scm/git_capture_scm.html) workflow to package our own Conan packages.
However, the use case as described in the documentation only works for the simple cases, where the `conanfile.py` is in the root of the git repository.
If not, it's difficult to get both the local development workflow via `conan build` and the cache workflow via `conan create` working simultaneously.
The solution we come up with looks like this:
```py
def layout(self):
# Needed for local developement workflow.
self.folders.root = "../../"
# But build folder etc. in the correct subfolder.
self.folders.subproject = "path/to/subfolder/in/repo"
cmake_layout(self)
# Set source to the git root, as the checkout via `source()` always clones the full repo.
self.folders.source = "."
def build(self):
cmake = CMake(self)
# As `self.source_folder` is the git root, we need to tell CMake where our "real" folder is.
cmake.configure(build_script_folder=self.folders.subproject)
...
```
* Is there a better way to achieve this?
* If not, I think this should be documented.
I feel like this case is not uncommon.
If you are having multiple Conan packages in a single git repository or don't have the Conan package at the root folder, this special handling is needed.
If you need to demonstrate the problem, you can use:
```
$ git clone https://github.com/conan-io/examples2.git
$ mkdir conan_capture_scm
$ cp -r examples2/examples/tools/scm/git/capture_scm conan_capture_scm/
$ cd conan_capture_scm/
$ git init
$ git add .
$ git commit -m WIP
$ cd capture_scm/
$ conan create .
$ conan build .
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the “Capturing Git scm information” page linked in the issue and reproduce the listed commands using the capture_scm example from examples2. Compare the conan build and conan create workflows when conanfile.py is in a subfolder. Done means either identifying a better supported approach or documenting the required layout and CMake handling for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, git, python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100