depot/pkgs/build-support/lib/cmake.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

32 lines
1.4 KiB
Nix

{ stdenv, lib }:
let
inherit (lib) findFirst isString optional optionals;
cmakeFlags' =
optionals (stdenv.hostPlatform != stdenv.buildPlatform) ([
"-DCMAKE_SYSTEM_NAME=${findFirst isString "Generic" (optional (!stdenv.hostPlatform.isRedox) stdenv.hostPlatform.uname.system)}"
] ++ optionals (stdenv.hostPlatform.uname.processor != null) [
"-DCMAKE_SYSTEM_PROCESSOR=${stdenv.hostPlatform.uname.processor}"
] ++ optionals (stdenv.hostPlatform.uname.release != null) [
"-DCMAKE_SYSTEM_VERSION=${stdenv.hostPlatform.uname.release}"
] ++ optionals (stdenv.hostPlatform.isDarwin) [
"-DCMAKE_OSX_ARCHITECTURES=${stdenv.hostPlatform.darwinArch}"
] ++ optionals (stdenv.buildPlatform.uname.system != null) [
"-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}"
] ++ optionals (stdenv.buildPlatform.uname.processor != null) [
"-DCMAKE_HOST_SYSTEM_PROCESSOR=${stdenv.buildPlatform.uname.processor}"
] ++ optionals (stdenv.buildPlatform.uname.release != null) [
"-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}"
] ++ optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
"-DCMAKE_CROSSCOMPILING_EMULATOR=env"
] ++ optionals stdenv.hostPlatform.isStatic [
"-DCMAKE_LINK_SEARCH_START_STATIC=ON"
]);
makeCMakeFlags = { cmakeFlags ? [], ... }: cmakeFlags ++ cmakeFlags';
in
{
inherit makeCMakeFlags;
}