1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 03:30:45 +00:00

Merge pull request #273474 from adisbladis/lib-cmakeOptionType-static-list

lib.cmakeOptionType: Statically compute types list
This commit is contained in:
Silvan Mosberger 2023-12-11 17:45:22 +01:00 committed by GitHub
commit 5812c533ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -771,12 +771,13 @@ rec {
cmakeOptionType "string" "ENGINE" "sdl2"
=> "-DENGINE:STRING=sdl2"
*/
cmakeOptionType = type: feature: value:
assert (lib.elem (lib.toUpper type)
[ "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL" ]);
assert (lib.isString feature);
assert (lib.isString value);
"-D${feature}:${lib.toUpper type}=${value}";
cmakeOptionType = let
types = [ "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL" ];
in type: feature: value:
assert (elem (toUpper type) types);
assert (isString feature);
assert (isString value);
"-D${feature}:${toUpper type}=${value}";
/* Create a -D<condition>={TRUE,FALSE} string that can be passed to typical
CMake invocations.