lib.cmakeOptionType: Statically compute types list

This commit is contained in:
adisbladis 2023-12-11 16:45:25 +13:00
parent eec92ca9df
commit 2d47874820

View File

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