* cmake setup hook: override the whole configurePhase rather than

setting a postUnpack hook.

svn path=/nixpkgs/trunk/; revision=14074
This commit is contained in:
Eelco Dolstra 2009-02-13 14:43:01 +00:00
parent 6ed4d1fe5a
commit 62fa1a418f
2 changed files with 43 additions and 36 deletions

View File

@ -2,20 +2,30 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "cmake-2.6.2"; name = "cmake-2.6.2";
# We look for cmake modules in .../share/cmake-${majorVersion}/Modules.
majorVersion = "2.6";
setupHook = ./setup-hook.sh; setupHook = ./setup-hook.sh;
meta = { meta = {
homepage = http://www.cmake.org/;
description = "Cross-Platform Makefile Generator"; description = "Cross-Platform Makefile Generator";
}; };
src = fetchurl { src = fetchurl {
url = "http://www.cmake.org/files/v2.6/${name}.tar.gz"; url = "http://www.cmake.org/files/v2.6/${name}.tar.gz";
sha256 = "b3f5a9dfa97fb82cb1b7d78a62d949f93c8d4317af36674f337d27066fa6b7e9"; sha256 = "b3f5a9dfa97fb82cb1b7d78a62d949f93c8d4317af36674f337d27066fa6b7e9";
}; };
inherit ncurses;
propagatedBuildInputs = [replace]; postUnpack = ''
postUnpack = " dontUseCmakeConfigure=1
source \${setupHook}; fixCmakeFiles \${sourceRoot}; source $setupHook
echo 'SET (CMAKE_SYSTEM_PREFIX_PATH \"'\${ncurses}'\" CACHE FILEPATH \"Root for libs for cmake\" FORCE)' > \${sourceRoot}/cmakeInit.txt fixCmakeFiles $sourceRoot
"; echo 'SET (CMAKE_SYSTEM_PREFIX_PATH "'${ncurses}'" CACHE FILEPATH "Root for libs for cmake" FORCE)' > $sourceRoot/cmakeInit.txt
'';
configureFlags= [ " --init=cmakeInit.txt " ]; configureFlags= [ " --init=cmakeInit.txt " ];
postInstall="fixCmakeFiles \$out/share";
postInstall = "fixCmakeFiles $out/share";
} }

View File

@ -1,49 +1,46 @@
addCMakeParamsInclude() addCMakeParams()
{ {
addToSearchPath CMAKE_INCLUDE_PATH /include "" $1 addToSearchPath CMAKE_INCLUDE_PATH /include "" $1
}
addCMakeParamsLibs()
{
addToSearchPath CMAKE_LIBRARY_PATH /lib "" $1 addToSearchPath CMAKE_LIBRARY_PATH /lib "" $1
} addToSearchPath CMAKE_MODULE_PATH /share/cmake-@majorVersion@/Modules "" $1
addCMakeModulePath()
{
addToSearchPath CMAKE_MODULE_PATH /share/cmake-2.4/Modules "" $1
} }
fixCmakeFiles() fixCmakeFiles()
{ {
local replaceArgs; local replaceArgs
echo "Fixing cmake files" echo "fixing cmake files"
replaceArgs="-e -f -L -T /usr /FOO" replaceArgs="-e -f -L -T /usr /FOO"
replaceArgs="${replaceArgs} -a NO_DEFAULT_PATH \"\" -a NO_SYSTEM_PATH \"\"" replaceArgs="$replaceArgs -a NO_DEFAULT_PATH \"\" -a NO_SYSTEM_PATH \"\""
find $1 -type f -name "*.cmake" | xargs replace-literal ${replaceArgs} find $1 -type f -name "*.cmake" | xargs replace-literal ${replaceArgs}
} }
cmakePostUnpack() cmakeConfigurePhase()
{ {
sourceRoot=$sourceRoot/build eval "$preConfigure"
mkdir -v $sourceRoot
echo source root reset to $sourceRoot if test -z "$dontFixCmake"; then
if [ -z "$dontFixCmake" ]; then
fixCmakeFiles . fixCmakeFiles .
fi fi
if [ -z "$configureScript" ]; then if test -z "$dontUseCmakeBuildDir"; then
configureScript="cmake .." mkdir -p build
cd build
cmakeDir=..
fi fi
if [ -z "$dontAddPrefix" ]; then
dontAddPrefix=1 if test -z "$dontAddPrefix"; then
configureFlags="-DCMAKE_INSTALL_PREFIX=$out $configureFlags" cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix $cmakeFlags"
fi fi
echo "cmake flags: $cmakeFlags ${cmakeFlagsArray[@]}"
cmake ${cmakeDir:-.} $cmakeFlags ${cmakeFlagsArray[@]}
eval "$postConfigure"
} }
if test -z "$dontUseCmakeConfigure"; then
configurePhase=cmakeConfigurePhase
fi
if [ -z "$noCmakeTewaks" ]; then envHooks=(${envHooks[@]} addCMakeParams)
postUnpack="cmakePostUnpack${postUnpack:+; }${postUnpack}"
fi;
envHooks=(${envHooks[@]} addCMakeParamsInclude addCMakeParamsLibs addCMakeModulePath)