Discussion:
Single source with multiple interdependent cmake packages
(too old to reply)
Enrico Zini
2024-12-20 18:40:01 UTC
Permalink
Hello,

I'm trying to make a Debian package out of
https://gitlab.eumetsat.int/open-source/data-tailor-plugins/fcidecomp

I managed to build it this way:

$ cd src/fcidecomp

$ # Build and install fcicomp-jpegls first
$ rm -r build/fcicomp-jpegls/
$ gen/build.sh fcicomp-jpegls/ release

$ # fcicomp-H5Zjpegls seems to need fcicomp-jpegls installed in order to build
$ (cd build/fcicomp-jpegls && make install DESTDIR=/tmp/fcicomp-jpegls)
$ rm -r build/fcicomp-H5Zjpegls/
$ CMAKE_PREFIX_PATH=/tmp/fcicomp-jpegls/usr/local/share/cmake/fcicomp_jpegls/ gen/build.sh fcicomp-H5Zjpegls/ release
$ (cd build/fcicomp-H5Zjpegls/ && make install DESTDIR=/tmp/fcicomp-H5Zjpegls)

(gen/build.sh is a wrapper that calls cmake, and can be replaced by a
cmake invocation)
From here to a Debian package the way doesn't seem to be
straightforward, as I can't install the first component before building
the second one, and probably there are better ways to do it.

Questions:

* Is there a way to tell cmake to build the two things together, or to
point at the build dir of the first one to build the second one,
without installing it first?
* Is there a clean way to tell debhelper that cmake and make need to be
called multiple times?
* Is there a better way to approach all this?

Thanks!

Enrico
--
GPG key: 4096R/634F4BD1E7AD5568 2009-05-08 Enrico Zini <***@enricozini.org>
Jochen Sprickerhof
2024-12-20 19:40:01 UTC
Permalink
Hi Enrico,
Post by Enrico Zini
* Is there a way to tell cmake to build the two things together, or to
point at the build dir of the first one to build the second one,
without installing it first?
I had a similar problem with the ros- packages and solved it with a top
level CMakeLists.txt doing add_subdirectory() for every project. Here is
an example:

https://sources.debian.org/src/ros-image-transport-plugins/1.15.0-3/debian/patches/0001-Add-CMakeLists.txt.patch/
Post by Enrico Zini
* Is there a clean way to tell debhelper that cmake and make need to be
called multiple times?
That's also possible but you would need to override all targets in
d/rules with the duplicated commands.

Cheers Jochen
Helmut Grohne
2024-12-22 07:50:01 UTC
Permalink
Hi Enrico,
Post by Enrico Zini
Hello,
I'm trying to make a Debian package out of
https://gitlab.eumetsat.int/open-source/data-tailor-plugins/fcidecomp
$ cd src/fcidecomp
$ # Build and install fcicomp-jpegls first
$ rm -r build/fcicomp-jpegls/
$ gen/build.sh fcicomp-jpegls/ release
$ # fcicomp-H5Zjpegls seems to need fcicomp-jpegls installed in order to build
$ (cd build/fcicomp-jpegls && make install DESTDIR=/tmp/fcicomp-jpegls)
$ rm -r build/fcicomp-H5Zjpegls/
$ CMAKE_PREFIX_PATH=/tmp/fcicomp-jpegls/usr/local/share/cmake/fcicomp_jpegls/ gen/build.sh fcicomp-H5Zjpegls/ release
$ (cd build/fcicomp-H5Zjpegls/ && make install DESTDIR=/tmp/fcicomp-H5Zjpegls)
(gen/build.sh is a wrapper that calls cmake, and can be replaced by a
cmake invocation)
From here to a Debian package the way doesn't seem to be
straightforward, as I can't install the first component before building
the second one, and probably there are better ways to do it.
* Is there a way to tell cmake to build the two things together, or to
point at the build dir of the first one to build the second one,
without installing it first?
In principle, there is. Jochen already pointed out that a subproject can
be added using add_subdirectory. If that doesn't work, the heavier
hammer is ExternalProject_Add. At that point your build will configure
and build the other CMake project (and you're responsible for forwarding
all the relevant variables including compiler and compiler flags).
Post by Enrico Zini
* Is there a clean way to tell debhelper that cmake and make need to be
called multiple times?
No. The closest thing solving this problem I encountered thus far is
cdbs, but I no longer remember how it solved that and I don't think we
want to revive it. However, Niels is working on such functionality as
part of his debputy work. The relevant issue is
https://salsa.debian.org/debian/debputy/-/issues/31. As far as I
understand your problem, it is vaguely similar to cmake vs
emacs-cmake-mode. Timo split the emacs-cmake-mode source package off the
cmake package for bootstrapping concerns (effectively duplicating the
source package). In your case, doing two source packages sharing the
same orig.tar would also solve your issues (at the inconvenience of
doing two uploads). There is no silver bullet at this time.

If continuing with debhelper, I suspect your best bet is to configure,
build, and install the first project in an
execute_before_dh_auto_configure handling the second one. I appreciate
if you continue calling cmake through dh_auto_configure, because that
tends to makes cross building just work.

Helmut
Enrico Zini
2024-12-27 13:30:01 UTC
Permalink
Post by Jochen Sprickerhof
I had a similar problem with the ros- packages and solved it with a top
level CMakeLists.txt doing add_subdirectory() for every project. Here is an
https://sources.debian.org/src/ros-image-transport-plugins/1.15.0-3/debian/patches/0001-Add-CMakeLists.txt.patch/
Thanks, that approach worked for me! The relevant cmake patchery is at:
https://salsa.debian.org/science-team/fcidecomp/-/commit/08ef2f18a6af813043a34d97b8bd9939b8f836f6
Post by Jochen Sprickerhof
If continuing with debhelper, I suspect your best bet is to configure,
build, and install the first project in an
execute_before_dh_auto_configure handling the second one. I appreciate
if you continue calling cmake through dh_auto_configure, because that
tends to makes cross building just work.
Thanks! In the end I managed to turn everything into a hopefully
well-behaved toplevel CMakeLists.txt, and go ahead with a standard
debian/rules: https://salsa.debian.org/science-team/fcidecomp


Enrico
--
GPG key: 4096R/634F4BD1E7AD5568 2009-05-08 Enrico Zini <***@enricozini.org>
Loading...