cmake check_c_source_runs() examples

ornladios/ADIOS2 cmake/DetectOptions.cmake :145

check_c_source_runs("
#include <zfp.h>

int main()
{
  zfp_stream* stream = zfp_stream_open(NULL);
  return !zfp_stream_set_execution(stream, zfp_exec_cuda);
}"
ADIOS2_HAVE_ZFP_CUDA)

ornladios/ADIOS2 thirdparty/EVPath/EVPath/CMakeLists.txt :479

CHECK_C_SOURCE_RUNS("${_SOURCE}" GOOD_MEMLOCK_LIMIT)

curl/curl CMakeLists.txt :1926

check_c_source_runs("
  int main(int argc, char **argv)
  {
    (void)argc;
    argv[0][0] = ' ';
    return (argv[0][0] == ' ')?0:1;
  }" HAVE_WRITABLE_ARGV)

curl/curl CMakeLists.txt :1937

check_c_source_runs("
  #include <time.h>
  int main(void) {
    time_t t = -1;
    return t < 0;
  }" HAVE_TIME_T_UNSIGNED)

ValveSoftware/ffts CMakeLists.txt :171

check_c_source_runs("${TEST_SOURCE_CODE}" GCC_MARCH_NATIVE_FLAG_SUPPORTED)

ValveSoftware/ffts CMakeLists.txt :176

check_c_source_runs("${TEST_SOURCE_CODE}" GCC_MARCH_ARMV7A_FLAG_SUPPORTED)

ValveSoftware/ffts CMakeLists.txt :181

check_c_source_runs("${TEST_SOURCE_CODE}" GCC_MARCH_ARMV6_FLAG_SUPPORTED)

ValveSoftware/ffts CMakeLists.txt :219

check_c_source_runs("${TEST_SOURCE_CODE}" NEON_HARDFP_SUPPORTED)

ValveSoftware/ffts CMakeLists.txt :224

check_c_source_runs("${TEST_SOURCE_CODE}" NEON_SOFTFP_SUPPORTED)

ValveSoftware/ffts CMakeLists.txt :262

check_c_source_runs("${TEST_SOURCE_CODE}" VFP_SUPPORTED)

ValveSoftware/ffts CMakeLists.txt :283

check_c_source_runs("${TEST_SOURCE_CODE}" HARDFP_SUPPORTED)

ValveSoftware/ffts CMakeLists.txt :288

check_c_source_runs("${TEST_SOURCE_CODE}" SOFTFP_SUPPORTED)

FirebirdSQL/firebird builds/cmake/Configure.cmake :42

check_c_source_runs("main(){struct s{char a;${type} b;};exit((int)&((struct s*)0)->b);}" ${var})

arximboldi/immer cmake/FindBoehmGC.cmake :67

  check_c_source_runs(
    "#include <gc.h>
int main() {
int i= GC_get_parallel();
return 0;
}
"
    GC_GET_PARALLEL_WORKS)

InsightSoftwareConsortium/ITK Modules/ThirdParty/JPEG/src/itkjpeg-turbo/CMakeLists.txt :47

check_c_source_runs("
  #include <stdio.h>
  #include <stdlib.h>
  static int is_shifting_signed (long arg) {
    long res = arg >> 4;
    if (res == -0x7F7E80CL)
      return 1; /* right shift is signed */
    /* see if unsigned-shift hack will fix it. */
    /* we can't just test exact value since it depends on width of long... */
    res |= 0xFFFFFFFFL << (32-4);
    if (res == -0x7F7E80CL)
      return 0; /* right shift is unsigned */
    printf(\"Right shift isn't acting as I expect it to.\\\\n\");
    printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
    return 0; /* try it with unsigned anyway */
  }
  int main (void) {
    exit(is_shifting_signed(-0x7F7E80B1L));
  }" RIGHT_SHIFT_IS_UNSIGNED)

libevent/libevent cmake/CheckWorkingKqueue.cmake :3

check_c_source_runs(
"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/event.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int
main(int argc, char **argv)
{
    int kq;
    int n;
    int fd[2];
    struct kevent ev;
    struct timespec ts;
    char buf[80000];

    if (pipe(fd) == -1)
        exit(1);
    if (fcntl(fd[1], F_SETFL, O_NONBLOCK) == -1)
        exit(1);

    while ((n = write(fd[1], buf, sizeof(buf))) == sizeof(buf))
        ;

    if ((kq = kqueue()) == -1)
        exit(1);

    memset(&ev, 0, sizeof(ev));
    ev.ident = fd[1];
    ev.filter = EVFILT_WRITE;
    ev.flags = EV_ADD | EV_ENABLE;
    n = kevent(kq, &ev, 1, NULL, 0, NULL);
    if (n == -1)
        exit(1);

    read(fd[0], buf, sizeof(buf));

    ts.tv_sec = 0;
    ts.tv_nsec = 0;
    n = kevent(kq, NULL, 0, &ev, 1, &ts);
    if (n == -1 || n == 0)
        exit(1);

    exit(0);
}

" EVENT__HAVE_WORKING_KQUEUE)

librsync/librsync CMakeLists.txt :124

check_c_source_runs("#include <stdio.h>\nint main(){char o[8];sprintf(o, \"%zu\", (size_t)7);return o[0] != '7';}" HAVE_PRINTF_Z)

libsndfile/libsamplerate cmake/ClipMode.cmake :23

check_c_source_runs(
"
#include <math.h>
int main (void)
{   double  fval ;
    int k, ival ;

    fval = 1.0 * 0x7FFFFFFF ;
    for (k = 0 ; k < 100 ; k++)
    {   ival = (lrint (fval)) >> 24 ;
        if (ival != 127)
            return 1 ;

        fval *= 1.2499999 ;
        } ;

        return 0 ;
    }
"
CPU_CLIPS_POSITIVE)

libsndfile/libsamplerate cmake/ClipMode.cmake :44

check_c_source_runs(
  "
  #include <math.h>
  int main (void)
  {   double  fval ;
      int k, ival ;

      fval = -8.0 * 0x10000000 ;
      for (k = 0 ; k < 100 ; k++)
      {   ival = (lrint (fval)) >> 24 ;
          if (ival != -128)
              return 1 ;

          fval *= 1.2499999 ;
          } ;

          return 0 ;
      }
  "
  CPU_CLIPS_NEGATIVE)

LibVNC/libvncserver CMakeLists.txt :123

check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)

mfem/mfem config/cmake/modules/FindPackageMultipass.cmake :123

check_c_source_runs ("${source}" ${testname})

onnx/onnx cmake/external/FindSanitizer.cmake :98

check_c_source_runs("${_source_code}" __res)

onnx/onnx cmake/external/FindSanitizer.cmake :117

check_c_source_runs("${_bug_${sanitizer_name}_code}" __res)

ICLDisco/parsec CMakeLists.txt :673

        check_c_source_runs("
#include <mpi.h>
#include <hwloc.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
    printf(\"HWLOC headers version: %x.\\\\nCalling `hwloc_get_api_version()`...\\\\n\", HWLOC_API_VERSION); fflush(stdout);
    unsigned int lib_api_version = hwloc_get_api_version();
    printf(\"HWLOC library version: %x.\\\\n\", lib_api_version); fflush(stdout);
#if HWLOC_API_VERSION >= 0x00020000
    if (lib_api_version < 0x00020000) {
#else
    if (lib_api_version >= 0x00020000) {
#endif
        printf(\"Header and library versions are incompatible.\\\\n\"); fflush(stdout);
        return 1;
    }
    printf(\"Calling `MPI_Init()`...\\\\n\"); fflush(stdout);
    MPI_Init(&argc, &argv);
    MPI_Barrier(MPI_COMM_WORLD);
    MPI_Finalize();
    printf(\"HWLOC+MPI worked.\\\\n\");
    return 0;
    }" MPI_AND_HWLOC_COMPATIBLE)

ICLDisco/parsec cmake_modules/CheckAtomicIntrinsic.cmake :86

check_c_source_runs("
    #include <stdatomic.h>
    int main(void) {
      __int128_t where = 0, expected = 0;
      if( !atomic_compare_exchange_strong( (_Atomic __int128_t*)&where, &expected, 1 ) )
          return -1;
      return (atomic_is_lock_free(&where) ? 0 : 1);
    }
    " PARSEC_ATOMIC_USE_C11_128)

ICLDisco/parsec cmake_modules/CheckAtomicIntrinsic.cmake :100

check_c_source_runs("
    #include <stdatomic.h>
    int main(void) {
      __int128_t where = 0, expected = 0;
      if( !atomic_compare_exchange_strong( (_Atomic __int128_t*)&where, &expected, 1 ) )
          return -1;
      return (atomic_is_lock_free(&where) ? 0 : 1);
    }
    " PARSEC_ATOMIC_USE_C11_128)

ICLDisco/parsec cmake_modules/CheckAtomicIntrinsic.cmake :119

check_c_source_runs("
    #include <stdatomic.h>
    int main(void) {
      __int128_t where = 0, expected = 0;
      if( !atomic_compare_exchange_strong( (_Atomic __int128_t*)&where, &expected, 1 ) )
          return -1;
      return (atomic_is_lock_free(&where) ? 0 : 1);
    }
    " PARSEC_ATOMIC_USE_C11_128)

TigerVNC/tigervnc CMakeLists.txt :265

check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)