Skip to content

Commit

Permalink
cmake: setup-hooks.sh: add genCmakeDefaultFlags
Browse files Browse the repository at this point in the history
Extract the code constructing the cmakeDefaultFlags into a Bash function
genCmakeDefaultFlags.
  • Loading branch information
ShamrockLee committed Aug 21, 2024
1 parent d00607f commit a3cfdba
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions pkgs/by-name/cm/cmake/setup-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,7 @@ fixCmakeFiles() {
done
}

cmakeConfigurePhase() {
runHook preConfigure

# default to CMake defaults if unset
: ${cmakeBuildDir:=build}

export CTEST_OUTPUT_ON_FAILURE=1
if [ -n "${enableParallelChecking-1}" ]; then
export CTEST_PARALLEL_LEVEL=$NIX_BUILD_CORES
fi

if [ -z "${dontFixCmake-}" ]; then
fixCmakeFiles .
fi

if [ -z "${dontUseCmakeBuildDir-}" ]; then
mkdir -p "$cmakeBuildDir"
cd "$cmakeBuildDir"
: ${cmakeDir:=..}
else
: ${cmakeDir:=.}
fi

genCmakeDefaultFlags() {
declare -ga cmakeDefaultFlags=()

# The docdir flag needs to include PROJECT_NAME as per GNU guidelines,
Expand Down Expand Up @@ -126,6 +104,32 @@ cmakeConfigurePhase() {
if [ "${buildPhase-}" = ninjaBuildPhase ]; then
cmakeDefaultFlags+=("-GNinja")
fi
}

cmakeConfigurePhase() {
runHook preConfigure

# default to CMake defaults if unset
: ${cmakeBuildDir:=build}

export CTEST_OUTPUT_ON_FAILURE=1
if [ -n "${enableParallelChecking-1}" ]; then
export CTEST_PARALLEL_LEVEL=$NIX_BUILD_CORES
fi

if [ -z "${dontFixCmake-}" ]; then
fixCmakeFiles .
fi

if [ -z "${dontUseCmakeBuildDir-}" ]; then
mkdir -p "$cmakeBuildDir"
cd "$cmakeBuildDir"
: ${cmakeDir:=..}
else
: ${cmakeDir:=.}
fi

genCmakeDefaultFlags

local flagsArray=()
concatTo flagsArray cmakeDefaultFlags cmakeFlags cmakeFlagsArray
Expand Down

0 comments on commit a3cfdba

Please sign in to comment.