rt build fails with failure to find lensfun.h

Yes, it is a bug - in your C compiler:

internal compiler error: Segmentation fault

Right at the start of the compilation:

-- The C compiler identification is GNU 12.3.0
-- The CXX compiler identification is GNU 12.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- WARNING: gcc 12.3.0 is known to miscompile RawTherapee when using --ffp-contract=fast, forcing the option to be off

It seems that GCC version has a problem even if the flag is disabled.
See this related thread (same issue, just compiling darktable): Another error compiling darktable from git