check_library_exists fails for stdcall functions, because that check doesn't include the necessary headers (and thus fails with an undefined reference to _EnumProcessModules, when the import library symbol actually is called _EnumProcessModules@16).
Merge the two previous checks check_include_files and check_library_exists into one with check_c_source_compiles, and merge the variables that indicate whether it succeeded.