Skip to content

Commit

Permalink
Merge pull request #56021 from illegalprime/fix/cmake-cross
Browse files Browse the repository at this point in the history
cmake: add ability to cross-compile cmake
  • Loading branch information
matthewbauer authored Feb 20, 2019
2 parents 5d0b0bb + cbbde55 commit ae3e835
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkgs/development/tools/build-managers/cmake/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ stdenv, fetchurl, fetchpatch, pkgconfig
, bzip2, curl, expat, libarchive, xz, zlib, libuv, rhash
, buildPackages
# darwin attributes
, ps
, isBootstrap ? false
Expand Down Expand Up @@ -61,6 +62,8 @@ stdenv.mkDerivation rec {
++ optional useQt4 qt4
++ optional withQt5 qtbase;

depsBuildBuild = [ buildPackages.stdenv.cc ];

propagatedBuildInputs = optional stdenv.isDarwin ps;

preConfigure = ''
Expand All @@ -71,7 +74,8 @@ stdenv.mkDerivation rec {
--subst-var-by libc_lib ${getLib stdenv.cc.libc}
substituteInPlace Modules/FindCxxTest.cmake \
--replace "$""{PYTHON_EXECUTABLE}" ${stdenv.shell}
configureFlags="--parallel=''${NIX_BUILD_CORES:-1} $configureFlags"
# BUILD_CC and BUILD_CXX are used to bootstrap cmake
configureFlags="--parallel=''${NIX_BUILD_CORES:-1} CC=$BUILD_CC CXX=$BUILD_CXX $configureFlags"
'';

configureFlags = [
Expand All @@ -95,6 +99,11 @@ stdenv.mkDerivation rec {
# Avoid depending on frameworks.
++ optional (!useNcurses) "-DBUILD_CursesDialog=OFF";

# make install attempts to use the just-built cmake
preInstall = optional (stdenv.hostPlatform != stdenv.buildPlatform) ''
sed -i 's|bin/cmake|${buildPackages.cmake}/bin/cmake|g' Makefile
'';

dontUseCmakeConfigure = true;
enableParallelBuilding = true;

Expand Down

0 comments on commit ae3e835

Please sign in to comment.