cmake HAVE_CRC_FLAG examples

codership/galera cmake/crc32c.cmake :23

check_c_compiler_flag(-msse4.2 HAVE_CRC_FLAG)

codership/galera cmake/crc32c.cmake :30

check_c_source_compiles(
"
// Here we assume that CPU feature detection and
// CRC32 support in hardware is the same thing and
// if the former is not available, the latter is
// not available as well, so we test for both at
// the same time

#include <sys/auxv.h>
#include <arm_acle.h>

int main()
{
#if defined(__linux__)
    (void)getauxval(AT_HWCAP);
#elif defined(__FreeBSD__)
    unsigned long info;
    (void)elf_aux_info(AT_HWCAP, &info, sizeof(info));
#else
    #error Hardware feature detection for OS not supported
#endif

    (void)__crc32b(0, 0);
    (void)__crc32h(0, 0);
    (void)__crc32w(0, 0);
    (void)__crc32d(0, 0);

    return 0;
}
" HAVE_CRC_FLAG)