2024-05-02 00:46:19 +00:00
|
|
|
{ stdenv, lib }:
|
|
|
|
|
|
|
|
let
|
2024-06-30 08:12:46 +00:00
|
|
|
inherit (lib)
|
|
|
|
findFirst
|
|
|
|
isString
|
|
|
|
optional
|
|
|
|
optionals
|
|
|
|
;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
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) [
|
2024-05-02 00:46:19 +00:00
|
|
|
"-DCMAKE_SYSTEM_PROCESSOR=${stdenv.hostPlatform.uname.processor}"
|
2024-06-30 08:12:46 +00:00
|
|
|
]
|
|
|
|
++ optionals (stdenv.hostPlatform.uname.release != null) [
|
2024-05-02 00:46:19 +00:00
|
|
|
"-DCMAKE_SYSTEM_VERSION=${stdenv.hostPlatform.uname.release}"
|
2024-06-30 08:12:46 +00:00
|
|
|
]
|
|
|
|
++ optionals (stdenv.hostPlatform.isDarwin) [
|
2024-05-02 00:46:19 +00:00
|
|
|
"-DCMAKE_OSX_ARCHITECTURES=${stdenv.hostPlatform.darwinArch}"
|
2024-06-30 08:12:46 +00:00
|
|
|
]
|
|
|
|
++ optionals (stdenv.buildPlatform.uname.system != null) [
|
2024-05-02 00:46:19 +00:00
|
|
|
"-DCMAKE_HOST_SYSTEM_NAME=${stdenv.buildPlatform.uname.system}"
|
2024-06-30 08:12:46 +00:00
|
|
|
]
|
|
|
|
++ optionals (stdenv.buildPlatform.uname.processor != null) [
|
2024-05-02 00:46:19 +00:00
|
|
|
"-DCMAKE_HOST_SYSTEM_PROCESSOR=${stdenv.buildPlatform.uname.processor}"
|
2024-06-30 08:12:46 +00:00
|
|
|
]
|
|
|
|
++ optionals (stdenv.buildPlatform.uname.release != null) [
|
2024-05-02 00:46:19 +00:00
|
|
|
"-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}"
|
2024-06-30 08:12:46 +00:00
|
|
|
]
|
|
|
|
++ optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
|
2024-05-02 00:46:19 +00:00
|
|
|
"-DCMAKE_CROSSCOMPILING_EMULATOR=env"
|
2024-06-30 08:12:46 +00:00
|
|
|
]
|
|
|
|
++ optionals stdenv.hostPlatform.isStatic [ "-DCMAKE_LINK_SEARCH_START_STATIC=ON" ]
|
|
|
|
);
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
makeCMakeFlags =
|
|
|
|
{
|
|
|
|
cmakeFlags ? [ ],
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
cmakeFlags ++ cmakeFlags';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit makeCMakeFlags;
|
|
|
|
}
|