push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
index e95da44ea4..bdf4155232 100644
--- a/Modules/Platform/UnixPaths.cmake
+++ b/Modules/Platform/UnixPaths.cmake
@@ -71,28 +71,38 @@
/lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
)
-if(CMAKE_SYSROOT_COMPILE)
- set(_cmake_sysroot_compile "${CMAKE_SYSROOT_COMPILE}")
+# Add the Nix C library paths.
+if(DEFINED ENV{NIX_CC}
+ AND IS_DIRECTORY "$ENV{NIX_CC}"
+ AND EXISTS "$ENV{NIX_CC}/nix-support/orig-libc"
+ AND EXISTS "$ENV{NIX_CC}/nix-support/orig-libc-dev")
+ file(STRINGS "$ENV{NIX_CC}/nix-support/orig-libc" _nix_cmake_libc)
+ file(STRINGS "$ENV{NIX_CC}/nix-support/orig-libc-dev" _nix_cmake_libc_dev)
else()
- set(_cmake_sysroot_compile "${CMAKE_SYSROOT}")
+ set(_nix_cmake_libc @libc_lib@)
+ set(_nix_cmake_libc_dev @libc_dev@)
endif()
+list(APPEND CMAKE_SYSTEM_INCLUDE_PATH "${_nix_cmake_libc_dev}/include")
+list(APPEND CMAKE_SYSTEM_LIBRARY_PATH "${_nix_cmake_libc}/lib")
+list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_nix_cmake_libc}/lib")
# Default per-language values. These may be later replaced after
# parsing the implicit directory information from compiler output.
set(_CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES_INIT
${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}
- "${_cmake_sysroot_compile}/usr/include"
+ "${_nix_cmake_libc_dev}/include"
)
set(_CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES_INIT
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}
- "${_cmake_sysroot_compile}/usr/include"
+ "${_nix_cmake_libc_dev}/include"
)
set(_CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES_INIT
${CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES}
- "${_cmake_sysroot_compile}/usr/include"
+ "${_nix_cmake_libc_dev}/include"
)
-unset(_cmake_sysroot_compile)
+unset(_nix_cmake_libc)
+unset(_nix_cmake_libc_dev)
# Reminder when adding new locations computed from environment variables
# please make sure to keep Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst

View File

@@ -0,0 +1,18 @@
cmakePcfileCheckPhase() {
while IFS= read -rd $'\0' file; do
grepout=$(grep --line-number '}//nix/store' "$file" || true)
if [ -n "$grepout" ]; then
{
echo "Broken paths found in a .pc file! $file"
echo "The following lines have issues (specifically '//' in paths)."
echo "$grepout"
echo "It is very likely that paths are being joined improperly."
echo 'ex: "${prefix}/@CMAKE_INSTALL_LIBDIR@" should be "@CMAKE_INSTALL_FULL_LIBDIR@"'
echo "Please see https://github.com/NixOS/nixpkgs/issues/144170 for more details."
exit 1
} 1>&2
fi
done < <(find "${!outputDev}" -iname "*.pc" -print0)
}
postFixupHooks+=(cmakePcfileCheckPhase)

View File

@@ -0,0 +1,61 @@
diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake
index 196ab18b0b..31dd4346b1 100644
--- a/Modules/Platform/Darwin-Initialize.cmake
+++ b/Modules/Platform/Darwin-Initialize.cmake
@@ -16,7 +16,7 @@
endif()
if(NOT CMAKE_CROSSCOMPILING)
- execute_process(COMMAND sw_vers -productVersion
+ execute_process(COMMAND @sw_vers@ -productVersion
OUTPUT_VARIABLE _CMAKE_HOST_OSX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index c65587edbe..0a7cc380c3 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -3833,7 +3833,7 @@
}
char const* names[3] = { "Pages wired down:", "Pages active:", nullptr };
long long values[2] = { 0 };
- int ierr = GetFieldsFromCommand("vm_stat", names, values);
+ int ierr = GetFieldsFromCommand("@vm_stat@", names, values);
if (ierr) {
return -1;
}
@@ -5586,7 +5586,7 @@
{
#ifdef __APPLE__
std::vector<char const*> args;
- args.push_back("sw_vers");
+ args.push_back("@sw_vers@");
args.push_back(arg);
args.push_back(nullptr);
ver = this->RunProcess(args);
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 15a1e2c0c3..33bb304cf7 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1958,7 +1958,7 @@
if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5)
if(NOT CMake_TEST_XCTest_DEPLOYMENT_TARGET)
execute_process(
- COMMAND sw_vers -productVersion
+ COMMAND @sw_vers@ -productVersion
OUTPUT_VARIABLE OSX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index ddc975c202..8ff651fd90 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -127,7 +127,7 @@
set(OSX_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET})
else()
execute_process(
- COMMAND sw_vers -productVersion
+ COMMAND @sw_vers@ -productVersion
OUTPUT_VARIABLE OSX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)

View File

@@ -0,0 +1,79 @@
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
index dc26258eac..dd8d30e3d9 100644
--- a/Modules/CMakeDetermineSystem.cmake
+++ b/Modules/CMakeDetermineSystem.cmake
@@ -68,7 +68,7 @@
endif()
if(_CMAKE_APPLE_SILICON_PROCESSOR)
if(";${_CMAKE_APPLE_SILICON_PROCESSOR};" MATCHES "^;(arm64|x86_64);$")
- execute_process(COMMAND sysctl -q hw.optional.arm64
+ execute_process(COMMAND @sysctl@ -q hw.optional.arm64
OUTPUT_VARIABLE _sysctl_stdout
ERROR_VARIABLE _sysctl_stderr
RESULT_VARIABLE _sysctl_result
diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake
index 31dd4346b1..7c4f123a1d 100644
--- a/Modules/Platform/Darwin-Initialize.cmake
+++ b/Modules/Platform/Darwin-Initialize.cmake
@@ -28,7 +28,7 @@
if(NOT CMAKE_CROSSCOMPILING AND
CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(arm64|x86_64)$")
- execute_process(COMMAND sysctl -q hw.optional.arm64
+ execute_process(COMMAND @sysctl@ -q hw.optional.arm64
OUTPUT_VARIABLE _sysctl_stdout
ERROR_VARIABLE _sysctl_stderr
RESULT_VARIABLE _sysctl_result
diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index 260b6631c0..ffb8fcd8d2 100644
--- a/Modules/ProcessorCount.cmake
+++ b/Modules/ProcessorCount.cmake
@@ -87,8 +87,7 @@
if(NOT count)
# Mac, FreeBSD, OpenBSD (systems with sysctl):
- find_program(ProcessorCount_cmd_sysctl sysctl
- PATHS /usr/sbin /sbin)
+ set(ProcessorCount_cmd_sysctl @sysctl@)
mark_as_advanced(ProcessorCount_cmd_sysctl)
if(ProcessorCount_cmd_sysctl)
execute_process(COMMAND ${ProcessorCount_cmd_sysctl} -n hw.ncpu
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index a918b8d9a7..36145707e1 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -2503,7 +2503,7 @@
have two integers to store: the pid and then the ppid. */
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
defined(__OpenBSD__) || defined(__GLIBC__) || defined(__GNU__)
-# define KWSYSPE_PS_COMMAND "ps axo pid,ppid"
+# define KWSYSPE_PS_COMMAND "@ps@ axo pid,ppid"
# define KWSYSPE_PS_FORMAT "%d %d\n"
#elif defined(__sun) && (defined(__SVR4) || defined(__svr4__)) /* Solaris */
# define KWSYSPE_PS_COMMAND "ps -e -o pid,ppid"
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 0a7cc380c3..9923dc4ab9 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -3876,7 +3876,7 @@
long long memUsed = 0;
pid_t pid = getpid();
std::ostringstream oss;
- oss << "ps -o rss= -p " << pid;
+ oss << "@ps@ -o rss= -p " << pid;
FILE* file = popen(oss.str().c_str(), "r");
if (!file) {
return -1;
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 33bb304cf7..7dbda40a81 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -216,7 +216,7 @@
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT DEFINED CMake_TEST_APPLE_SILICON)
- execute_process(COMMAND sysctl -q hw.optional.arm64
+ execute_process(COMMAND @sysctl@ -q hw.optional.arm64
OUTPUT_VARIABLE _sysctl_stdout
ERROR_VARIABLE _sysctl_stderr
RESULT_VARIABLE _sysctl_result

View File

@@ -0,0 +1,13 @@
diff --git a/Source/CTest/cmCTestCurl.h b/Source/CTest/cmCTestCurl.h
index 7836f4b9c78a1d103eee515d618856a6712b4480..9113890b5a12cb157b691b66d96e25d0fd4b50ef 100644
--- a/Source/CTest/cmCTestCurl.h
+++ b/Source/CTest/cmCTestCurl.h
@@ -52,7 +52,7 @@ private:
std::vector<std::string> HttpHeaders;
std::string HTTPProxyAuth;
std::string HTTPProxy;
- curl_proxytype HTTPProxyType;
+ long HTTPProxyType;
bool UseHttp10 = false;
bool Quiet = false;
int TimeOutSeconds = 0;

View File

@@ -0,0 +1,28 @@
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index b8d4765692..902c1e5290 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -312,6 +312,11 @@ void cmFindBase::FillCMakeEnvironmentPath()
// Add CMAKE_*_PATH environment variables
std::string var = cmStrCat("CMAKE_", this->CMakePathName, "_PATH");
paths.AddEnvPrefixPath("CMAKE_PREFIX_PATH");
+ if (this->CMakePathName != "PROGRAM") {
+ // Like CMAKE_PREFIX_PATH except when searching for programs. Programs need
+ // to be located via PATH
+ paths.AddEnvPrefixPath("NIXPKGS_CMAKE_PREFIX_PATH");
+ }
paths.AddEnvPath(var);
if (this->CMakePathName == "PROGRAM") {
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 6201894fd1..9533862a2b 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -2467,6 +2467,7 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
// And now the general CMake environment variables
paths.AddEnvPath("CMAKE_PREFIX_PATH");
+ paths.AddEnvPath("NIXPKGS_CMAKE_PREFIX_PATH");
if (this->DebugModeEnabled()) {
debugBuffer = cmStrCat(debugBuffer,
"CMAKE_PREFIX_PATH env variable "

View File

@@ -0,0 +1,219 @@
{
lib,
stdenv,
fetchurl,
replaceVars,
buildPackages,
bzip2,
curlMinimal,
expat,
libarchive,
libuv,
ncurses,
openssl,
pkg-config,
ps,
sysctl,
rhash,
sphinx,
texinfo,
xz,
zlib,
darwin,
isBootstrap ? null,
isMinimalBuild ? (
if isBootstrap != null then
lib.warn "isBootstrap argument is deprecated and will be removed; use isMinimalBuild instead" isBootstrap
else
false
),
useOpenSSL ? !isMinimalBuild,
useSharedLibraries ? (!isMinimalBuild && !stdenv.hostPlatform.isCygwin),
uiToolkits ? [ ], # can contain "ncurses" and/or "qt5"
buildDocs ? !(isMinimalBuild || (uiToolkits == [ ])),
libsForQt5,
gitUpdater,
}:
let
inherit (libsForQt5) qtbase wrapQtAppsHook;
cursesUI = lib.elem "ncurses" uiToolkits;
qt5UI = lib.elem "qt5" uiToolkits;
in
# Accepts only "ncurses" and "qt5" as possible uiToolkits
assert lib.subtractLists [ "ncurses" "qt5" ] uiToolkits == [ ];
# Minimal, bootstrap cmake does not have toolkits
assert isMinimalBuild -> (uiToolkits == [ ]);
stdenv.mkDerivation (finalAttrs: {
pname =
"cmake"
+ lib.optionalString isMinimalBuild "-minimal"
+ lib.optionalString cursesUI "-cursesUI"
+ lib.optionalString qt5UI "-qt5UI";
version = "4.1.1";
src = fetchurl {
url = "https://cmake.org/files/v${lib.versions.majorMinor finalAttrs.version}/cmake-${finalAttrs.version}.tar.gz";
hash = "sha256-sp9vGXM6oiS3djUHoQikJ+1Ixojh+vIrKcROHDBUkoI=";
};
patches = [
# Add NIXPKGS_CMAKE_PREFIX_PATH to cmake which is like CMAKE_PREFIX_PATH
# except it is not searched for programs
./nixpkgs-cmake-prefix-path.patch
# Add the libc paths from the compiler wrapper.
./add-nixpkgs-libc-paths.patch
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
(replaceVars ./darwin-binary-paths.patch {
sw_vers = lib.getExe' darwin.DarwinTools "sw_vers";
vm_stat = lib.getExe' darwin.system_cmds "vm_stat";
})
]
++ lib.optionals (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isFreeBSD) [
(replaceVars ./darwin-bsd-binary-paths.patch {
# `ps(1)` is theoretically used on Linux too, but only when
# `/proc` is inaccessible, so we can skip the dependency.
ps = lib.getExe ps;
sysctl = lib.getExe sysctl;
})
]
++ [
# Backport of https://gitlab.kitware.com/cmake/cmake/-/merge_requests/11134
./fix-curl-8.16.patch
# Remove references to nonNix search paths.
./remove-impure-search-paths.patch
];
outputs = [
"out"
]
++ lib.optionals buildDocs [
"man"
"info"
];
separateDebugInfo = true;
setOutputFlags = false;
setupHooks = [
./setup-hook.sh
./check-pc-files-hook.sh
];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs =
finalAttrs.setupHooks
++ [
pkg-config
]
++ lib.optionals buildDocs [ texinfo ]
++ lib.optionals qt5UI [ wrapQtAppsHook ];
buildInputs =
lib.optionals useSharedLibraries [
bzip2
curlMinimal
expat
libarchive
xz
zlib
libuv
rhash
]
++ lib.optional useOpenSSL openssl
++ lib.optional cursesUI ncurses
++ lib.optional qt5UI qtbase;
preConfigure = ''
substituteInPlace Modules/Platform/UnixPaths.cmake \
--subst-var-by libc_bin ${lib.getBin stdenv.cc.libc} \
--subst-var-by libc_dev ${lib.getDev stdenv.cc.libc} \
--subst-var-by libc_lib ${lib.getLib stdenv.cc.libc}
# CC_FOR_BUILD and CXX_FOR_BUILD are used to bootstrap cmake
configureFlags="--parallel=''${NIX_BUILD_CORES:-1} CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD $configureFlags $cmakeFlags"
'';
# The configuration script is not autoconf-based, although being similar;
# triples and other interesting info are passed via CMAKE_* environment
# variables and commandline switches
configurePlatforms = [ ];
configureFlags = [
"--docdir=share/doc/${finalAttrs.pname}-${finalAttrs.version}"
]
++ (
if useSharedLibraries then
[
"--no-system-cppdap"
"--no-system-jsoncpp"
"--system-libs"
]
else
[
"--no-system-libs"
]
) # FIXME: cleanup
++ lib.optional qt5UI "--qt-gui"
++ lib.optionals buildDocs [
"--sphinx-build=${sphinx}/bin/sphinx-build"
"--sphinx-info"
"--sphinx-man"
]
++ [
"--"
# We should set the proper `CMAKE_SYSTEM_NAME`.
# http://www.cmake.org/Wiki/CMake_Cross_Compiling
#
# 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.
(lib.cmakeFeature "CMAKE_CXX_COMPILER" "${stdenv.cc.targetPrefix}c++")
(lib.cmakeFeature "CMAKE_C_COMPILER" "${stdenv.cc.targetPrefix}cc")
(lib.cmakeFeature "CMAKE_AR" "${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ar")
(lib.cmakeFeature "CMAKE_RANLIB" "${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}ranlib")
(lib.cmakeFeature "CMAKE_STRIP" "${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}strip")
(lib.cmakeBool "CMAKE_USE_OPENSSL" useOpenSSL)
(lib.cmakeBool "BUILD_CursesDialog" cursesUI)
];
# make install attempts to use the just-built cmake
preInstall = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
sed -i 's|bin/cmake|${buildPackages.cmakeMinimal}/bin/cmake|g' Makefile
'';
dontUseCmakeConfigure = true;
enableParallelBuilding = true;
doCheck = false; # fails
passthru.updateScript = gitUpdater {
url = "https://gitlab.kitware.com/cmake/cmake.git";
rev-prefix = "v";
ignoredVersions = "-"; # -rc1 and friends
};
meta = {
homepage = "https://cmake.org/";
description = "Cross-platform, open-source build system generator";
longDescription = ''
CMake is an open-source, cross-platform family of tools designed to build,
test and package software. CMake is used to control the software
compilation process using simple platform and compiler independent
configuration files, and generate native makefiles and workspaces that can
be used in the compiler environment of your choice.
'';
changelog = "https://cmake.org/cmake/help/v${lib.versions.majorMinor finalAttrs.version}/release/${lib.versions.majorMinor finalAttrs.version}.html";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [
ttuegel
lnl7
];
platforms = lib.platforms.all;
mainProgram = "cmake";
broken = (qt5UI && stdenv.hostPlatform.isDarwin);
};
})

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,174 @@
addCMakeParams() {
# NIXPKGS_CMAKE_PREFIX_PATH is like CMAKE_PREFIX_PATH except cmake
# will not search it for programs
addToSearchPath NIXPKGS_CMAKE_PREFIX_PATH $1
}
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 "${dontUseCmakeBuildDir-}" ]; then
mkdir -p "$cmakeBuildDir"
cd "$cmakeBuildDir"
: ${cmakeDir:=..}
else
: ${cmakeDir:=.}
fi
if [ -z "${dontAddPrefix-}" ]; then
prependToVar cmakeFlags "-DCMAKE_INSTALL_PREFIX=$prefix"
fi
# We should set the proper `CMAKE_SYSTEM_NAME`.
# http://www.cmake.org/Wiki/CMake_Cross_Compiling
#
# 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.
prependToVar cmakeFlags "-DCMAKE_CXX_COMPILER=$CXX"
prependToVar cmakeFlags "-DCMAKE_C_COMPILER=$CC"
prependToVar cmakeFlags "-DCMAKE_AR=$(command -v $AR)"
prependToVar cmakeFlags "-DCMAKE_RANLIB=$(command -v $RANLIB)"
prependToVar cmakeFlags "-DCMAKE_STRIP=$(command -v $STRIP)"
# on macOS we want to prefer Unix-style headers to Frameworks
# because we usually do not package the framework
prependToVar cmakeFlags "-DCMAKE_FIND_FRAMEWORK=LAST"
# correctly detect our clang compiler
prependToVar cmakeFlags "-DCMAKE_POLICY_DEFAULT_CMP0025=NEW"
# This installs shared libraries with a fully-specified install
# name. By default, cmake installs shared libraries with just the
# basename as the install name, which means that, on Darwin, they
# can only be found by an executable at runtime if the shared
# libraries are in a system path or in the same directory as the
# executable. This flag makes the shared library accessible from its
# nix/store directory.
prependToVar cmakeFlags "-DCMAKE_INSTALL_NAME_DIR=${!outputLib}/lib"
# The docdir flag needs to include PROJECT_NAME as per GNU guidelines,
# try to extract it from CMakeLists.txt.
if [[ -z "$shareDocName" ]]; then
local cmakeLists="${cmakeDir}/CMakeLists.txt"
if [[ -f "$cmakeLists" ]]; then
local shareDocName="$(grep --only-matching --perl-regexp --ignore-case '\bproject\s*\(\s*"?\K([^[:space:]")]+)' < "$cmakeLists" | head -n1)"
fi
# The argument sometimes contains garbage or variable interpolation.
# When that is the case, lets fall back to the derivation name.
if [[ -z "$shareDocName" ]] || echo "$shareDocName" | grep -q '[^a-zA-Z0-9_+-]'; then
if [[ -n "${pname-}" ]]; then
shareDocName="$pname"
else
shareDocName="$(echo "$name" | sed 's/-[^a-zA-Z].*//')"
fi
fi
fi
# This ensures correct paths with multiple output derivations
# It requires the project to use variables from GNUInstallDirs module
# https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
prependToVar cmakeFlags "-DCMAKE_INSTALL_BINDIR=${!outputBin}/bin"
prependToVar cmakeFlags "-DCMAKE_INSTALL_SBINDIR=${!outputBin}/sbin"
prependToVar cmakeFlags "-DCMAKE_INSTALL_INCLUDEDIR=${!outputInclude}/include"
prependToVar cmakeFlags "-DCMAKE_INSTALL_MANDIR=${!outputMan}/share/man"
prependToVar cmakeFlags "-DCMAKE_INSTALL_INFODIR=${!outputInfo}/share/info"
prependToVar cmakeFlags "-DCMAKE_INSTALL_DOCDIR=${!outputDoc}/share/doc/${shareDocName}"
prependToVar cmakeFlags "-DCMAKE_INSTALL_LIBDIR=${!outputLib}/lib"
prependToVar cmakeFlags "-DCMAKE_INSTALL_LIBEXECDIR=${!outputLib}/libexec"
prependToVar cmakeFlags "-DCMAKE_INSTALL_LOCALEDIR=${!outputLib}/share/locale"
# Dont build tests when doCheck = false
if [ -z "${doCheck-}" ]; then
prependToVar cmakeFlags "-DBUILD_TESTING=OFF"
fi
# Always build Release, to ensure optimisation flags
prependToVar cmakeFlags "-DCMAKE_BUILD_TYPE=${cmakeBuildType:-Release}"
# Disable user package registry to avoid potential side effects
# and unecessary attempts to access non-existent home folder
# https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#disabling-the-package-registry
prependToVar cmakeFlags "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON"
prependToVar cmakeFlags "-DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF"
prependToVar cmakeFlags "-DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF"
if [ "${buildPhase-}" = ninjaBuildPhase ]; then
prependToVar cmakeFlags "-GNinja"
fi
local flagsArray=()
concatTo flagsArray cmakeFlags cmakeFlagsArray
echoCmd 'cmake flags' "${flagsArray[@]}"
cmake "$cmakeDir" "${flagsArray[@]}"
if ! [[ -v enableParallelBuilding ]]; then
enableParallelBuilding=1
echo "cmake: enabled parallel building"
fi
if [[ "$enableParallelBuilding" -ne 0 ]]; then
export CMAKE_BUILD_PARALLEL_LEVEL=$NIX_BUILD_CORES
fi
if ! [[ -v enableParallelInstalling ]]; then
enableParallelInstalling=1
echo "cmake: enabled parallel installing"
fi
runHook postConfigure
}
if [ -z "${dontUseCmakeConfigure-}" -a -z "${configurePhase-}" ]; then
setOutputFlags=
configurePhase=cmakeConfigurePhase
fi
addEnvHooks "$targetOffset" addCMakeParams
makeCmakeFindLibs() {
isystem_seen=
iframework_seen=
for flag in ${NIX_CFLAGS_COMPILE-} ${NIX_LDFLAGS-}; do
if test -n "$isystem_seen" && test -d "$flag"; then
isystem_seen=
addToSearchPath CMAKE_INCLUDE_PATH "${flag}"
elif test -n "$iframework_seen" && test -d "$flag"; then
iframework_seen=
addToSearchPath CMAKE_FRAMEWORK_PATH "${flag}"
else
isystem_seen=
iframework_seen=
case $flag in
-I*)
addToSearchPath CMAKE_INCLUDE_PATH "${flag:2}"
;;
-L*)
addToSearchPath CMAKE_LIBRARY_PATH "${flag:2}"
;;
-F*)
addToSearchPath CMAKE_FRAMEWORK_PATH "${flag:2}"
;;
-isystem)
isystem_seen=1
;;
-iframework)
iframework_seen=1
;;
esac
fi
done
}
# not using setupHook, because it could be a setupHook adding additional
# include flags to NIX_CFLAGS_COMPILE
postHooks+=(makeCmakeFindLibs)