This seems to me like a case where the project is the better place to put this logic, not the toolchain file. CMake wants to test the toolchain, but if you force it to use -fsanitize=fuzzer
for every compilation, that kinda breaks the model CMake has for what the flags and initial compiler setup does. That said, if you really want to stay on your current path, you can set CMAKE_TRY_COMPILE_TARGET_TYPE
to STATIC_LIBRARY
in your toolchain file. This will tell CMake to build a static library rather than an executable when doing its compiler checks. This effectively means the linker isn’t checked, and for the sort of platform you’re targeting, this feels to me like a bit of an abuse of what this variable was meant for, but it’s there if you decide you’re ok with it.
1 Like