I was able to fix this by adding --debug-trycompile to cmake arguments which has the side effect of not deleting the TryCompile/* directories.
--debug-trycompile