I believed correct syntax for the if(EQUAL) would be like
try_run(runcode buildOK ...)
if(runcode EQUAL 0)
endif()
That usually works, but I ran into a CentOS 8 system where even though message(STATUS ${runcode})
showed 0, the if(runcode EQUAL 0)
clause failed to be true. The system locale is English US. The statement does work on other systems.
On the problem system, the try_run() code does run correctly and gives expected RUN_OUTPUT_VARIABLE value as per my code (say hello.c).
To work around this I just simply ignored the runcode, and put a unique string into the run output variable so that I knew the program ran correctly.