* 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 {
name = "cmake-2.6.2";
# We look for cmake modules in .../share/cmake-${majorVersion}/Modules.
majorVersion = "2.6";
setupHook = ./setup-hook.sh;
meta = {
homepage = http://www.cmake.org/;
description = "Cross-Platform Makefile Generator";
};
src = fetchurl {
url = "http://www.cmake.org/files/v2.6/${name}.tar.gz";
sha256 = "b3f5a9dfa97fb82cb1b7d78a62d949f93c8d4317af36674f337d27066fa6b7e9";
};
inherit ncurses;
propagatedBuildInputs = [replace];
postUnpack = "
source \${setupHook}; fixCmakeFiles \${sourceRoot};
echo 'SET (CMAKE_SYSTEM_PREFIX_PATH \"'\${ncurses}'\" CACHE FILEPATH \"Root for libs for cmake\" FORCE)' > \${sourceRoot}/cmakeInit.txt
";
postUnpack = ''
dontUseCmakeConfigure=1
source $setupHook
fixCmakeFiles $sourceRoot
echo 'SET (CMAKE_SYSTEM_PREFIX_PATH "'${ncurses}'" CACHE FILEPATH "Root for libs for cmake" FORCE)' > $sourceRoot/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
}
addCMakeParamsLibs()
{
addToSearchPath CMAKE_LIBRARY_PATH /lib "" $1
}
addCMakeModulePath()
{
addToSearchPath CMAKE_MODULE_PATH /share/cmake-2.4/Modules "" $1
addToSearchPath CMAKE_MODULE_PATH /share/cmake-@majorVersion@/Modules "" $1
}
fixCmakeFiles()
{
local replaceArgs;
echo "Fixing cmake files"
local replaceArgs
echo "fixing cmake files"
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}
}
cmakePostUnpack()
cmakeConfigurePhase()
{
sourceRoot=$sourceRoot/build
mkdir -v $sourceRoot
echo source root reset to $sourceRoot
if [ -z "$dontFixCmake" ]; then
eval "$preConfigure"
if test -z "$dontFixCmake"; then
fixCmakeFiles .
fi
if [ -z "$configureScript" ]; then
configureScript="cmake .."
if test -z "$dontUseCmakeBuildDir"; then
mkdir -p build
cd build
cmakeDir=..
fi
if [ -z "$dontAddPrefix" ]; then
dontAddPrefix=1
configureFlags="-DCMAKE_INSTALL_PREFIX=$out $configureFlags"
if test -z "$dontAddPrefix"; then
cmakeFlags="-DCMAKE_INSTALL_PREFIX=$prefix $cmakeFlags"
fi
echo "cmake flags: $cmakeFlags ${cmakeFlagsArray[@]}"
cmake ${cmakeDir:-.} $cmakeFlags ${cmakeFlagsArray[@]}
eval "$postConfigure"
}
if test -z "$dontUseCmakeConfigure"; then
configurePhase=cmakeConfigurePhase
fi
if [ -z "$noCmakeTewaks" ]; then
postUnpack="cmakePostUnpack${postUnpack:+; }${postUnpack}"
fi;
envHooks=(${envHooks[@]} addCMakeParamsInclude addCMakeParamsLibs addCMakeModulePath)
envHooks=(${envHooks[@]} addCMakeParams)