cmake: improve thrift detection