diff --git a/pkgs/development/tools/build-managers/cmake/default.nix b/pkgs/development/tools/build-managers/cmake/default.nix index fed88561cf9c..7dd97b8a2067 100644 --- a/pkgs/development/tools/build-managers/cmake/default.nix +++ b/pkgs/development/tools/build-managers/cmake/default.nix @@ -83,11 +83,25 @@ stdenv.mkDerivation rec { configureFlags = [ "--docdir=share/doc/${name}" ] ++ (if useSharedLibraries then [ "--no-system-jsoncpp" "--system-libs" ] else [ "--no-system-libs" ]) # FIXME: cleanup ++ optional (useQt4 || withQt5) "--qt-gui" - ++ optionals (!useNcurses) [ "--" "-DBUILD_CursesDialog=OFF" ]; + ++ ["--"] + ++ optionals (!useNcurses) [ "-DBUILD_CursesDialog=OFF" ] + ++ optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-DCMAKE_CXX_COMPILER=${stdenv.cc.targetPrefix}g++" + "-DCMAKE_C_COMPILER=${stdenv.cc.targetPrefix}gcc" + "-DCMAKE_AR=${getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ar" + "-DCMAKE_RANLIB=${getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ranlib" + "-DCMAKE_STRIP=${getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}strip" + # TODO: Why are ar and friends not provided by the bintools wrapper? + ]; dontUseCmakeConfigure = true; enableParallelBuilding = true; + # This isn't an autoconf configure script; triples are passed via + # CMAKE_SYSTEM_NAME, etc. + configurePlatforms = [ ]; + + meta = with stdenv.lib; { homepage = http://www.cmake.org/; description = "Cross-Platform Makefile Generator"; diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh index a0f1cf00814c..50e9e93b015f 100755 --- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh +++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh @@ -33,7 +33,15 @@ cmakeConfigurePhase() { # By now it supports linux builds only. We should set the proper # CMAKE_SYSTEM_NAME otherwise. # http://www.cmake.org/Wiki/CMake_Cross_Compiling - cmakeFlags="-DCMAKE_CXX_COMPILER=$crossConfig-g++ -DCMAKE_C_COMPILER=$crossConfig-gcc $cmakeFlags" + # + # Unfortunately cmake seems to expect absolute paths for ar, ranlib, and + # strip. Otherwise they are taken to be relative to the source root of + # the package being built. + cmakeFlags="-DCMAKE_CXX_COMPILER=$crossConfig-g++ $cmakeFlags" + cmakeFlags="-DCMAKE_C_COMPILER=$crossConfig-gcc $cmakeFlags" + cmakeFlags="-DCMAKE_AR=$(command -v $crossConfig-ar) $cmakeFlags" + cmakeFlags="-DCMAKE_RANLIB=$(command -v $crossConfig-ranlib) $cmakeFlags" + cmakeFlags="-DCMAKE_STRIP=$(command -v $crossConfig-strip) $cmakeFlags" fi # This installs shared libraries with a fully-specified install