https://github.com/shiltian commented: A potentially better alternative would be to define a CMake variable when a target is enabled, and then check if the variable exists and is true when enabling tests. https://github.com/llvm/llvm-project/pull/119006