lol
at 18.03-beta 111 lines 3.7 kB view raw
1{ stdenv, fetchurl, pkgconfig 2, bzip2, curl, expat, libarchive, xz, zlib, libuv, rhash 3, majorVersion ? "3.10" 4# darwin attributes 5, ps 6, isBootstrap ? false 7, useSharedLibraries ? (!isBootstrap && !stdenv.isCygwin) 8, useNcurses ? false, ncurses 9, useQt4 ? false, qt4 10, withQt5 ? false, qtbase 11}: 12 13assert withQt5 -> useQt4 == false; 14assert useQt4 -> withQt5 == false; 15 16with stdenv.lib; 17 18with ( 19 { 20 "3.10" = { 21 minorVersion = "2"; 22 sha256 = "80d0faad4ab56de07aa21a7fc692c88c4ce6156d42b0579c6962004a70a3218b"; 23 }; 24 "3.9" = { 25 minorVersion = "6"; 26 sha256 = "7410851a783a41b521214ad987bb534a7e4a65e059651a2514e6ebfc8f46b218"; 27 }; 28 29 }.${majorVersion} 30 or (abort ''Unsupported configuration for cmake: majorVersion = "${majorVersion}";'') 31); 32 33let 34 os = stdenv.lib.optionalString; 35 version = "${majorVersion}.${minorVersion}"; 36in 37 38stdenv.mkDerivation rec { 39 name = "cmake-${os isBootstrap "boot-"}${os useNcurses "cursesUI-"}${os withQt5 "qt5UI-"}${os useQt4 "qt4UI-"}${version}"; 40 41 inherit majorVersion; 42 43 src = fetchurl { 44 url = "${meta.homepage}files/v${majorVersion}/cmake-${version}.tar.gz"; 45 # from https://cmake.org/files/v3.10/cmake-3.10.2-SHA-256.txt 46 inherit sha256; 47 }; 48 49 prePatch = optionalString (!useSharedLibraries) '' 50 substituteInPlace Utilities/cmlibarchive/CMakeLists.txt \ 51 --replace '"-framework CoreServices"' '""' 52 ''; 53 54 # Don't search in non-Nix locations such as /usr, but do search in our libc. 55 patches = [ ./search-path-3.9.patch ] 56 ++ optional stdenv.isCygwin ./3.2.2-cygwin.patch; 57 58 outputs = [ "out" ]; 59 setOutputFlags = false; 60 61 setupHook = ./setup-hook.sh; 62 63 buildInputs = 64 [ setupHook pkgconfig ] 65 ++ optionals useSharedLibraries [ bzip2 curl expat libarchive xz zlib libuv rhash ] 66 ++ optional useNcurses ncurses 67 ++ optional useQt4 qt4 68 ++ optional withQt5 qtbase; 69 70 propagatedBuildInputs = optional stdenv.isDarwin ps; 71 72 preConfigure = '' 73 fixCmakeFiles . 74 substituteInPlace Modules/Platform/UnixPaths.cmake \ 75 --subst-var-by libc_bin ${getBin stdenv.cc.libc} \ 76 --subst-var-by libc_dev ${getDev stdenv.cc.libc} \ 77 --subst-var-by libc_lib ${getLib stdenv.cc.libc} 78 substituteInPlace Modules/FindCxxTest.cmake \ 79 --replace "$""{PYTHON_EXECUTABLE}" ${stdenv.shell} 80 configureFlags="--parallel=''${NIX_BUILD_CORES:-1} $configureFlags" 81 ''; 82 83 configureFlags = [ "--docdir=share/doc/${name}" ] 84 ++ (if useSharedLibraries then [ "--no-system-jsoncpp" "--system-libs" ] else [ "--no-system-libs" ]) # FIXME: cleanup 85 ++ optional (useQt4 || withQt5) "--qt-gui" 86 ++ ["--"] 87 ++ optionals (!useNcurses) [ "-DBUILD_CursesDialog=OFF" ] 88 ++ optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ 89 "-DCMAKE_CXX_COMPILER=${stdenv.cc.targetPrefix}c++" 90 "-DCMAKE_C_COMPILER=${stdenv.cc.targetPrefix}cc" 91 "-DCMAKE_AR=${getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ar" 92 "-DCMAKE_RANLIB=${getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ranlib" 93 "-DCMAKE_STRIP=${getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}strip" 94 # TODO: Why are ar and friends not provided by the bintools wrapper? 95 ]; 96 97 dontUseCmakeConfigure = true; 98 enableParallelBuilding = true; 99 100 # This isn't an autoconf configure script; triples are passed via 101 # CMAKE_SYSTEM_NAME, etc. 102 configurePlatforms = [ ]; 103 104 105 meta = with stdenv.lib; { 106 homepage = http://www.cmake.org/; 107 description = "Cross-Platform Makefile Generator"; 108 platforms = if useQt4 then qt4.meta.platforms else platforms.all; 109 maintainers = with maintainers; [ ttuegel lnl7 ]; 110 }; 111}