Created attachment 371568 [details, diff] cross-cmake-ebuild.patch I have added cross-compile support to cmake.eclass in bug #503216 and I figured I would take the extra step of fixing the CMake ebuild itself. After bootstrapping, it uses itself to build so the eclass fix is necessary. Bootstrapping should be done using the build system toolchain and tc-env_build exists for that purpose so I have made use of that. There are a couple of configure checks that can't be done when cross-compiling. Assuming that KWSYS_LFS_WORKS=1 seems like a fairly safe bet on any Gentoo system, for the lack of any better alternative. Although I couldn't find a concrete list, KWSYS_CHAR_IS_SIGNED=0 appears to apply exclusively to ARM and PPC. Finally, CMake currently generates its documentation using its own binaries. This obviously won't work when cross-compiling so I am providing an additional patch that skips the documentation in this case. I was going to submit this upstream but they've completely changed the way their documentation is generated in 3.0, which is about to be released.
Created attachment 371570 [details, diff] cmake-2.8.12.2-no-cross-docs.patch
Comment on attachment 371568 [details, diff] cross-cmake-ebuild.patch >+ if use arm || use ppc ; then >+ mycmakeargs+=(-DKWSYS_CHAR_IS_SIGNED=0) >+ else >+ mycmakeargs+=(-DKWSYS_CHAR_IS_SIGNED=1) >+ fi hardcoding char behavior doesn't belong in here, not to mention this logic is horribly broken. for gcc, you need to query the compiler directly (in conjunction with $CFLAGS and such) and see if __CHAR_UNSIGNED__ is defined.
Okay, didn't know there was such a macro, I'll definitely use that instead. Maybe a toolchain-funcs helper would be appropriate here but are you saying that we shouldn't set KWSYS_CHAR_IS_SIGNED at all?
Created attachment 373934 [details, diff] cross-cmake-ebuild.patch Assuming that's not what you meant, here's a better attempt that adds a tc-has-unsigned-char function to toolchain-funcs.
We can't do anything unless the toolchain-funcs.eclass patch is applied. Also, it would be nice to send the no-cross-docs patch upstream.
What's the current status here?
Created attachment 650248 [details, diff] Patch against cmake-3.18.0.ebuild Things have obviously moved on a bit since. Luckily it's an easier fix now but still along the same lines. Bootstrapping appears to be conditional now, I don't think it was back then. has_version should check against BROOT, hence I've added the -b flag. I was able to successfully cross-compile for m68k, with and without bootstrapping.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=222acbcb270567379e34ebfdec3c0b5e6534628d commit 222acbcb270567379e34ebfdec3c0b5e6534628d Author: James Le Cuirot <chewi@gentoo.org> AuthorDate: 2020-07-22 22:24:17 +0000 Commit: James Le Cuirot <chewi@gentoo.org> CommitDate: 2020-08-23 17:10:42 +0000 dev-util/cmake: Fix cross-compiling in 3.18.1 Closes: https://bugs.gentoo.org/503218 Package-Manager: Portage-3.0.0, Repoman-2.3.23 Signed-off-by: James Le Cuirot <chewi@gentoo.org> dev-util/cmake/cmake-3.18.1.ebuild | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)