View previous topic :: View next topic |
Author |
Message |
nagmat84 Guru

Joined: 27 Mar 2007 Posts: 308
|
Posted: Wed Apr 23, 2025 6:39 am Post subject: How to set SRC dir S for eclass cmake with /src subdirectory |
|
|
Assume you have a project whose main CMakeLists.txt does not reside in the project's main directory but in a subdirectory /src. I want to use the eclass cmake and I am wondering wether- it is better to set the ebuild variable S to the sub-directory, or
- change the working dir to /src in src_compile?
Option 1 essentially looks like: Code: | EAPI=8
inherit cmake
S="${WORKDIR}/release-${PV}-stable/src" | Option 2 looks like: Code: | EAPI=8
inherit cmake
S="${WORKDIR}/release-${PV}-stable"
src_compile() {
cd src || die
cmake_src_compile
} |
The basic structure of the project is: Code: | release-x.y.z-stable
|-- doc
|-- lib
| `-- CMakeLists.txt
|-- src
| `-- CMakeLists.txt
|-- test
|-- tools
|-- BUILDING.md
|-- CHANGELOG.md
`-- README.md |
Things worth noting:- Option 1 is more succint, less boiler plate code.
- There are files above the /src subdirectory level inside /lib and /doc which needs to be installed, too. I don't know wether confining ${S} to /src might prevent this in a later emerge stage. I haven't come so far yet.
- With option 1, emerge creates the build directory "${WORKDIR}/release-${PV}-stable/src_build", i.e. the build directory resides within the extracted project next to ./src. With option 2, emerge creates the build directory "${WORKDIR}/release-${PV}-stable_build" outside the extracted project. The latter option feels as if this would be the correct way.
- With option 2, I change the working dir at the beginning of the compilation phase, before I call the default implementation of the eclass. I don't know where I also have to change the working dir in order to not accidentally break thing. Or stated differently: I don't know how many things inside the eclass rely on ${S} pointing to the directory with the main CMakeLists.txt.
|
|
Back to top |
|
 |
grknight Retired Dev

Joined: 20 Feb 2015 Posts: 2141
|
Posted: Wed Apr 23, 2025 12:27 pm Post subject: |
|
|
If you don't care about any other CMakeLists.txt except in src directory as the base, then use Option 3:
Code: | EAPI=8
CMAKE_USE_DIR="${S}/src"
inherit cmake |
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|