cmake check_cxx_source_compiles examples

Signatures

check_cxx_source_compiles(<code> <resultVar>
  [FAIL_REGEX <regex1> [<regex2>...]])

Examples

timi-liuliang/echo thirdparty/eigen-3.3.3/cmake/FindStandardMathLibrary.cmake :29

CHECK_CXX_SOURCE_COMPILES(
  "${find_standard_math_library_test_program}"
  standard_math_library_linked_to_automatically
)

geodynamics/aspect CMakeLists.txt :495

check_cxx_source_compiles("
#include <cstddef>
#include <dlfcn.h>

int main()
{
  void *handle = dlopen (\"somelib.so\", RTLD_LAZY);
  return handle == NULL || dlerror();
}
" HAVE_DLOPEN)

u3d-community/U3D cmake/Modules/CheckCompilerToolchain.cmake :148

check_cxx_source_compiles ("#include <type_traits>\nint main() { return std::${TYPE_TRAIT}<bool>::value; }" ${UPPERCASE_${TYPE_TRAIT}})

urho3d/urho3d cmake/Modules/CheckCompilerToolchain.cmake :129

check_cxx_source_compiles ("#include <type_traits>\nint main() { return std::${TYPE_TRAIT}<bool>::value; }" ${UPPERCASE_${TYPE_TRAIT}})

alicevision/AliceVision src/cmake/CheckCXXCompilerFlag.cmake :29

CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
     # Some compilers do not fail with a bad flag
     FAIL_REGEX "error: bad value (.*) for .* switch"       # GNU
     FAIL_REGEX "argument unused during compilation"        # clang
     FAIL_REGEX "is valid for .* but not for C\\\\+\\\\+"   # GNU
     FAIL_REGEX "unrecognized .*option"                     # GNU
     FAIL_REGEX "ignoring unknown option"                   # MSVC
     FAIL_REGEX "[Uu]nknown option"                         # HP
     FAIL_REGEX "[Ww]arning: [Oo]ption"                     # SunPro
     FAIL_REGEX "command option .* is not recognized"       # XL
     FAIL_REGEX "WARNING: unknown flag:"                    # Open64
     FAIL_REGEX " #10159: "                                 # ICC
     )

prusa3d/PrusaSlicer cmake/modules/CheckAtomic.cmake :12

CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
std::atomic<int> x;
int main() {
  return x;
}
" ${varname})

FreeCAD/FreeCAD cMake/FindNETGEN.cmake :133

check_cxx_source_compiles("#include <cstdio>\nint main(){}" CSTDIO_INCLUDE_TRY1)

anhttran/extreme_3d_faces lib/3rdParty/Eigen/cmake/FindStandardMathLibrary.cmake :29

CHECK_CXX_SOURCE_COMPILES(
  "${find_standard_math_library_test_program}"
  standard_math_library_linked_to_automatically
)

godlikepanos/anki-3d-engine ThirdParty/Sdl3/cmake/macros.cmake :319

check_cxx_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "(unsupported|syntax error)")

bambulab/BambuStudio cmake/modules/CheckAtomic.cmake :12

CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
std::atomic<int> x;
int main() {
  return x;
}
" ${varname})

google/draco cmake/draco_flags.cmake :203

check_cxx_source_compiles("${draco_cxx_main}" linker_flag_test_passed)

SoftFever/OrcaSlicer cmake/modules/CheckAtomic.cmake :12

CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
std::atomic<int> x;
int main() {
  return x;
}
" ${varname})

kcat/openal-soft CMakeLists.txt :298

check_cxx_source_compiles("#include <atomic>
std::atomic<int> foo{0};
int main() { return foo.fetch_add(2); }"
HAVE_LIBATOMIC)

anhttran/3dmm_basic lib/3rdParty/Eigen/cmake/FindStandardMathLibrary.cmake :29

CHECK_CXX_SOURCE_COMPILES(
  "${find_standard_math_library_test_program}"
  standard_math_library_linked_to_automatically
)

cadaver/turso3d ThirdParty/SDL/cmake/macros.cmake :319

check_cxx_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "(unsupported|syntax error)")

Hork-Engine/Hork-Source ThirdParty/SDL3/cmake/macros.cmake :319

check_cxx_source_compiles("int main(int argc,char*argv[]){(void)argc;(void)argv;return 0;}" ${VAR} FAIL_REGEX "(unsupported|syntax error)")

GlPortal/RadixEngine cmake/FindCXX14.cmake :55

check_cxx_source_compiles("${CXX14_TEST_SOURCE}" CXX14_FLAG_DETECTED)

STORM-IRIT/Radium-Engine cmake/FindFilesystem.cmake :114

check_cxx_source_compiles("${code}" ${var})

RavEngine/RavEngine deps/assimp/contrib/draco/cmake/draco_flags.cmake :203

check_cxx_source_compiles("${draco_cxx_main}" linker_flag_test_passed)

ZDoom/Raze source/CMakeLists.txt :174

CHECK_CXX_SOURCE_COMPILES("#include <ppl.h>
	int main() { concurrency::parallel_for(0, 1, 1, [](int) { } ); }"
	HAVE_PARALLEL_FOR)

hyye/dsl cmake/FindGflags.cmake :165

check_cxx_source_compiles(
    "#include <gflags/gflags.h>
     int main(int argc, char * argv[]) {
       google::ParseCommandLineFlags(&argc, &argv, true);
       return 0;
     }"
     GFLAGS_IN_GOOGLE_NAMESPACE)

keith2018/SoftGLRender third_party/assimp/contrib/draco/cmake/compiler_tests.cmake :71

check_cxx_source_compiles("${test_source} ${DRACO_CXX_MAIN}"
                              CXX_TEST_COMPILED)

AlizaMedicalImaging/AlizaMS CMakeLists.txt :327

check_cxx_source_compiles("#include <byteswap.h>\nint main(){return bswap_32(42);}" MDCM_HAVE_BYTESWAP_H)

kokkos/kokkos cmake/kokkos_arch.cmake :893

check_cxx_source_compiles(
        "
      #include <sycl/sycl.hpp>
      using namespace sycl::ext::oneapi::experimental;
      using namespace sycl;

      SYCL_EXTERNAL device_global<int, decltype(properties(device_image_scope))> Foo;

      void bar(queue q) {
        q.single_task([=] {
        Foo = 42;
      });
      }

      int main(){ return 0; }
      "
        KOKKOS_IMPL_SYCL_DEVICE_GLOBAL_SUPPORTED
      )

eclipse-ecal/ecal CMakeLists.txt :60

check_cxx_source_compiles("${ATOMIC_TEST_CODE}" ATOMIC_IS_BUILTIN)

epoupon/lms cmake/modules/FindFilesystem.cmake :185

check_cxx_source_compiles("${code}" CXX_FILESYSTEM_NO_LINK_NEEDED)

JGRennison/OpenTTD-patches cmake/FindBFD.cmake :10

check_cxx_source_compiles("
        #define PACKAGE 1
        #define PACKAGE_VERSION 1
        #include <bfd.h>
        #include <unistd.h>
        int main() {
            bfd_init();
            bfd *abfd = bfd_openr(\"test\", \"test\");
            bfd_check_format(abfd, bfd_object);
            bfd_get_file_flags(abfd);
            bfd_map_over_sections(abfd, (void (*)(bfd*, asection*, void*)) 0, (void *) 0);
            asymbol *syms = 0;
            long symcount = bfd_read_minisymbols(abfd, false, (void**) &syms, (unsigned int *) 0);
            bfd_get_section_flags(abfd, (asection*) 0);
            bfd_get_section_vma(abfd, (asection*) 0);
            bfd_section_size(abfd, (asection*) 0);
            bfd_find_nearest_line(abfd, (asection*) 0, (asymbol **) 0, (bfd_vma) 0, (const char **) 0, (const char **) 0, (unsigned int *) 0);
            return (int) symcount;
        }"
        ${var}0
    )

ANTsX/ANTs CMake/ITKSetStandardCompilerFlags.cmake :347

CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" have_gold)

pcb9382/FaceAlgorithm include/Eigen/cmake/FindStandardMathLibrary.cmake :29

CHECK_CXX_SOURCE_COMPILES(
  "${find_standard_math_library_test_program}"
  standard_math_library_linked_to_automatically
)

coin-or/CppAD cmake/compile_source_test.cmake :46

CHECK_CXX_SOURCE_COMPILES("${source}" ${variable} )

Kitware/kwiver CMake/FindTinyXML.cmake :39

CHECK_CXX_SOURCE_COMPILES("
      #include <tinyxml.h>
      int main() { TiXmlNode *node; std::cin >> *node; } "
      TinyXML_USE_STL_D
      )

RSIA-LIESMARS-WHU/LSHBOX include/eigen/cmake/FindStandardMathLibrary.cmake :29

CHECK_CXX_SOURCE_COMPILES(
  "${find_standard_math_library_test_program}"
  standard_math_library_linked_to_automatically
)

liminchen/OptCuts ext/libigl/external/cgal/src/CGAL_Project/cmake/modules/FindTBB.cmake :76

check_cxx_source_compiles("${TBB_try_ts_source}" ${result_var})

bareos/bareos core/cmake/BareosCheckFunctions.cmake :99

check_cxx_source_compiles(
  "
#include <source_location>
int main() {
 std::source_location l{};
 return 0;
}
"
  HAVE_SOURCE_LOCATION
)

mariadb-corporation/MaxScale cmake/CheckPlatform.cmake :63

check_cxx_source_compiles("
  #define _GNU_SOURCE 1
  #include <string.h>\n
  int main(){\n
      char errbuf[200];\n
      return strerror_r(13, errbuf, sizeof(errbuf)) == errbuf;\n
  }\n"
  HAVE_GLIBC)

facebook/rocksdb CMakeLists.txt :317

CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
std::atomic<uint64_t> x(0);
int main() {
  uint64_t i = x.load(std::memory_order_relaxed);
  bool b = x.is_lock_free();
  return 0;
}
" BUILTIN_ATOMIC)

lightspark/lightspark tests/test-runner/3rdparty/cpptrace/cmake/Autoconfig.cmake :8

check_cxx_source_compiles(${full_source} ${var})

gnss-sdr/gnss-sdr CMakeLists.txt :999

check_cxx_source_compiles("
        #include <string_view>
        int main()
        { std::string_view sv; }"
        has_string_view
    )

facebook/mvfst cmake/CheckAtomic.cmake :51

CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
int main() {
  struct Test { int val; };
  std::atomic<Test> s;
  s.is_lock_free();
}" ${varname})

ByConity/ByConity cmake/cpu_features.cmake :37

check_cxx_source_compiles("
        #include <tmmintrin.h>
        int main() {
            __m64 a = _mm_abs_pi8(__m64());
            (void)a;
            return 0;
        }
    " HAVE_SSSE3)

ossia/score cmake/modules/FindReadline.cmake :23

check_cxx_source_compiles("
		#include <stdio.h>
		#include <readline/readline.h>
		#if !defined(RL_VERSION_MAJOR) || !defined(RL_VERSION_MINOR)
		#error Ancient version of readline
		#endif
		int main() { return 0; }
		"
		_rl_version_check)

lizardfs/lizardfs cmake/CheckCXXExpression.cmake :43

CHECK_CXX_SOURCE_COMPILES("${_CHECK_CXX_EXPRESSION_SOURCE_CODE}" ${_RESULT})

vinipsmaker/tufao cmake/modules/FindCXX11.cmake :53

check_cxx_source_compiles("${CXX11_TEST_SOURCE}" CXX11_FLAG_DETECTED)

v6d-io/v6d cmake/CheckLinkerFlag.cmake :78

check_CXX_source_compiles("${_source}" ${_var} ${_common_patterns})

bitcoin-core/minisketch cmake/SystemIntrospection.cmake :11

check_cxx_source_compiles("
  #include <immintrin.h>
  #include <stdint.h>

  int main()
  {
    __m128i a = _mm_cvtsi64_si128((uint64_t)7);
    __m128i b = _mm_clmulepi64_si128(a, a, 37);
    __m128i c = _mm_srli_epi64(b, 41);
    __m128i d = _mm_xor_si128(b, c);
    uint64_t e = _mm_cvtsi128_si64(d);
    return e == 0;
  }
  " HAVE_CLMUL
)

IBAMR/IBAMR CMakeLists.txt :84

CHECK_CXX_SOURCE_COMPILES(
  "
  _Pragma(\"GCC diagnostic push\")
  _Pragma(\"GCC diagnostic ignored \\\\\\\"-Wunknown-pragmas\\\\\\\"\")
  _Pragma(\"GCC diagnostic ignored \\\\\\\"-Wpragmas\\\\\\\"\")
  _Pragma(\"GCC diagnostic ignored \\\\\\\"-Wextra\\\\\\\"\")
  _Pragma(\"GCC diagnostic pop\")
  int main() {}
  "
  IBTK_HAVE_PRAGMA_KEYWORD)

TheAssemblyArmada/Thyme cmake/modules/TargetExports.cmake :15

check_cxx_source_compiles("int main(int argc, char **argv){return 0;}" HAVE_LD_VERSION_SCRIPT)

NVIDIA/DALI cmake/modules/FindNVJPEG.cmake :53

check_cxx_source_compiles(
          "#include <nvjpeg.h>
          int main(){
            return NVJPEG_BACKEND_LOSSLESS_JPEG != 6;
          }"
          NVJPEG_LOSSLESS_SUPPORTED)

OSVR/SteamVR-OSVR src/CMakeLists.txt :21

check_cxx_source_compiles("#include <memory>\nint main(int, char**) { std::unique_ptr<int> i = std::make_unique<int>(0); }" OSVR_HAS_STD_MAKE_UNIQUE)

scanner-research/scanner cmake/Modules/FindIconv.cmake :27

check_cxx_source_compiles("
  #include <iconv.h>
  int main(){
    iconv_t conv = 0;
    const char* in = 0;
    size_t ilen = 0;
    char* out = 0;
    size_t olen = 0;
    iconv(conv, &in, &ilen, &out, &olen);
    return 0;
  }
" ICONV_SECOND_ARGUMENT_IS_CONST )

Amber-MD/cpptraj cmake-cpptraj/CheckLinkerFlag.cmake :39

check_cxx_source_compiles("int main(void) { return 0; }" ${RESULT}
			# Some compilers do not fail with a bad flag
			FAIL_REGEX "command line option .* is valid for .* but not for C++" # GNU
			${_CheckLinkerFlag_COMMON_PATTERNS})

DIPlib/diplib src/CMakeLists.txt :66

check_cxx_source_compiles("int main() { char const* name = __PRETTY_FUNCTION__; }" HAS_PRETTY_FUNCTION)

BRAINSia/BRAINSTools CMake/FindDCMTK.cmake :342

check_cxx_source_compiles("#include <dcmtk/config/osconfig.h>\n#include <dcmtk/ofstd/ofstream.h>\nint main(int,char*[]){return 0;}"
    DCMTK_HAVE_CONFIG_H_OPTIONAL
    )

Tulip-Dev/tulip cmake/FindFTGL.cmake :110

CHECK_CXX_SOURCE_COMPILES( "
           #include <OpenGL/glu.h>
           typedef GLvoid (*TF)(); 
           int main() { 
           gluTessCallback(0,GLU_TESS_END_DATA,(TF)0);
           return 1;
           }" FTGL_GLU_EMPTY)

gismo/gismo cmake/FindTR1.cmake :28

check_cxx_source_compiles(
    "
        #include <memory>
        int main() {
            std::tr1::shared_ptr<int> ptr;
            return 0;
        }
    "
    TR1_SHARED_PTR_FOUND)

mchalupa/dg CMakeLists.txt :162

check_cxx_source_compiles(
   "#include <cstddef>
    extern \"C\" int LLVMFuzzerTestOneInput(const void *, size_t) { return 0; }"
    HAS_FUZZER)

mne-tools/mne-cpp src/external/eigen-3.4.0/cmake/FindMPREAL.cmake :96

check_cxx_source_compiles("${MPREAL_TEST_PROGRAM}" MPREAL_WORKS)

GoSSIP-SJTU/TripleDoggy cmake/modules/CheckAtomic.cmake :12

CHECK_CXX_SOURCE_COMPILES("
#include <atomic>
std::atomic<int> x;
int main() {
  return x;
}
" ${varname})

ceph/ceph cmake/modules/CephChecks.cmake :92

check_cxx_source_compiles("
  #include <string.h>
  int main() { char x = *strerror_r(0, &x, sizeof(x)); return 0; }
  " STRERROR_R_CHAR_P)

nghttp2/nghttp2 CMakeLists.txt :142

check_cxx_source_compiles("
  #include <vector>
  #include <future>
  int main() { std::vector<std::future<int>> v; }" HAVE_STD_FUTURE)

gnuradio/gnuradio cmake/Modules/FindPORTAUDIO.cmake :30

check_cxx_source_compiles(
        "#include <portaudio.h>\nPaDeviceIndex pa_find_device_by_name(const char *name); int main () {return 0;}"
        PORTAUDIO2_FOUND)

TigerVNC/tigervnc CMakeLists.txt :307

check_cxx_source_compiles("#include <FL/Fl.H>\n#if FL_MAJOR_VERSION != 1 || FL_MINOR_VERSION != 3\n#error Wrong FLTK version\n#endif\nint main(int, char**) { return 0; }" OK_FLTK_VERSION)

Exiv2/exiv2 cmake/generateConfigFile.cmake :27

check_cxx_source_compiles("#include <format>\nint main(){std::format(\"t\");}" EXV_HAVE_STD_FORMAT)

apache/trafficserver CMakeLists.txt :530

check_cxx_source_compiles(
  "#include <openssl/crypto.h>
  #if __has_include(<openssl/ex_data.h>)
  #include <openssl/ex_data.h>
  #endif
  int main() {
  CRYPTO_EX_dup *cb = [] (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, void **from_d, int idx, long argl, void *argp) -> int { return 0; };
  return 0;
  }"
  HAVE_CRYPTO_EX_DUP_TYPE1
)

dartsim/dart cmake/DARTFindDependencies.cmake :39

check_cxx_source_compiles(
  "
  #include <assimp/scene.h>
  int main()
  {
    aiScene* scene = new aiScene;
    delete scene;
    return 1;
  }
  "
  ASSIMP_AISCENE_CTOR_DTOR_DEFINED)

simbody/simbody Platform/CMakeLists.txt :30

CHECK_CXX_SOURCE_COMPILES("#include <mutex>\nint main(){std::mutex m;return 0;}" GPP_SUPPORTS_STD_MUTEX)

iree-org/iree build_tools/cmake/iree_setup_toolchain.cmake :123

check_cxx_source_compiles("${MINIMAL_SRC}" CXX_SUPPORTS_CUSTOM_LINKER)

steemit/steem libraries/vendor/rocksdb/CMakeLists.txt :226

CHECK_CXX_SOURCE_COMPILES("
#include <cstdint>
#include <nmmintrin.h>
#include <wmmintrin.h>
int main() {
  volatile uint32_t x = _mm_crc32_u32(0, 0);
  const auto a = _mm_set_epi64x(0, 0);
  const auto b = _mm_set_epi64x(0, 0);
  const auto c = _mm_clmulepi64_si128(a, b, 0x00);
  auto d = _mm_cvtsi128_si64(c);
}
" HAVE_SSE42)

brndnmtthws/conky 3rdparty/Vc/CMakeLists.txt :147

CHECK_CXX_SOURCE_COMPILES("#include <stdexcept>
            #include <iostream>
            void foo() {
              std::cout << 'h' << std::flush << std::endl;
              throw std::exception();
            }
            int main() {
              try { foo(); }
              catch (int) { return 0; }
              return 1;
            }" libcxx_compiles)

root-project/root cmake/modules/CheckCompiler.cmake :270

check_cxx_source_compiles(
"
#include <string>
#if _GLIBCXX_USE_CXX11_ABI == 0
  #error NOCXX11
#endif
int main() {}
" GLIBCXX_USE_CXX11_ABI)

brainflow-dev/brainflow third_party/fmt/support/cmake/cxx14.cmake :52

check_cxx_source_compiles("
  void operator\"\" _udl(long double);
  int main() {}"
  SUPPORTS_USER_DEFINED_LITERALS)

webcamoid/webcamoid CMakeLists.txt :120

check_cxx_source_compiles("
    #ifndef __linux__
        #error Not Linux
    #endif

    int main()
    {
        return 0;
    }" IS_LINUX)

projectM-visualizer/projectm cmake/EnableCFlagsIfSupported.cmake :27

check_cxx_source_compiles("int main(){return 0;}" ${_supported_var})

google/filament third_party/abseil/CMake/AbseilDll.cmake :690

check_cxx_source_compiles(
  [==[
#ifdef _MSC_VER
#  if _MSVC_LANG < 201703L
#    error "The compiler defaults or is configured for C++ < 17"
#  endif
#elif __cplusplus < 201703L
#  error "The compiler defaults or is configured for C++ < 17"
#endif
int main() { return 0; }
]==]
  ABSL_INTERNAL_AT_LEAST_CXX17)

elemental/Elemental cmake/detect/CXX.cmake :28

check_cxx_source_compiles("${ALIAS_CODE}" EL_HAVE_TEMPLATE_ALIAS)

percona/percona-xtrabackup CMakeLists.txt :1005

CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT}
    FAIL_REGEX "unknown argument ignored"
    FAIL_REGEX "argument unused during compilation"
    FAIL_REGEX "unsupported .*option"
    FAIL_REGEX "unknown .*option"
    FAIL_REGEX "unrecognized .*option"
    FAIL_REGEX "ignoring unknown option"
    FAIL_REGEX "[Ww]arning: [Oo]ption"
    FAIL_REGEX "error: visibility"
    FAIL_REGEX "warning: visibility"
    )

seladb/PcapPlusPlus cmake/modules/FindPCAP.cmake :57

check_cxx_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO)

NREL/EnergyPlus third_party/eigen/cmake/FindStandardMathLibrary.cmake :29

CHECK_CXX_SOURCE_COMPILES(
  "${find_standard_math_library_test_program}"
  standard_math_library_linked_to_automatically
)

resiprocate/resiprocate CMakeLists.txt :87

check_cxx_source_compiles("
#include <string_view>
int main() {
    std::string_view sv = \"test\";
    return 0;
}
" RESIP_HAVE_STRING_VIEW)

mysql/mysql-server CMakeLists.txt :1008

CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT}
    FAIL_REGEX "unknown argument ignored"
    FAIL_REGEX "argument unused during compilation"
    FAIL_REGEX "unsupported .*option"
    FAIL_REGEX "unknown .*option"
    FAIL_REGEX "unrecognized .*option"
    FAIL_REGEX "ignoring unknown option"
    FAIL_REGEX "[Ww]arning: [Oo]ption"
    FAIL_REGEX "error: visibility"
    FAIL_REGEX "warning: visibility"
    )

robotology/yarp extern/thrift/thrift/build/cmake/ConfigureChecks.cmake :64

check_cxx_source_compiles(
  "
  #include <string.h>
  int main(){char b;char *a = strerror_r(0, &b, 0); static_cast<void>(a); return(0);}
  "
  STRERROR_R_CHAR_P)

mysql/mysql-router tests/fuzzers/CMakeLists.txt :74

check_cxx_source_compiles("extern \"C\" int LLVMFuzzerTestOneInput(void *, int) { return 0; }" CLANG_HAS_LIBFUZZER)

ebu/ear-production-suite cmake_modules/check_nng.cmake :11

CHECK_CXX_SOURCE_COMPILES(
  "#include <nng/nng.h>
  void cb(nng_pipe, nng_pipe_ev, void*) {}

  int main() {
    nng_socket s;
    nng_pipe_notify(s, NNG_PIPE_EV_ADD_PRE, cb, NULL);
  }
  " NEW_NNG_PIPE_NOTIFY_CALLBACK_SIGNATURE
)

apache/xerces-c cmake/XercesIconvConst.cmake :24

check_cxx_source_compiles("
#include <iconv.h>

int main(void) {
  const char *fromPtr=0;
  size_t     fromLen=0;
  char       *toPtr=0;
  size_t     toLen=0;
  iconv_t    cv=0;
  iconv(cv, &fromPtr, &fromLen, &toPtr, &toLen);
  return 0;
}"
  ICONV_USES_CONST_POINTER)

Icinga/icinga2 CMakeLists.txt :414

check_cxx_source_compiles("class Base { public: virtual void test(void) { } }; class Derived : public Base { virtual void test(void) override { } }; int main(){}" CXX_FEATURE_OVERRIDE)

KDE/qca src/CMakeLists.txt :8

CHECK_CXX_SOURCE_COMPILES("
# include <stdlib.h>
# include <sys/mman.h>
int main() { void *f = 0; return mlock(f,8); }
" MLOCK_TAKES_VOID)

manticoresoftware/manticoresearch cmake/check_atomic_intrinsics.cmake :3

CHECK_CXX_SOURCE_COMPILES ( "
int main() {
	volatile int ia=0;
	__sync_fetch_and_or( &ia, 1 );
	return 0;
}" HAVE_SYNC_FETCH )

stephenberry/glaze tests/networking_tests/https_test/CMakeLists.txt :13

check_cxx_source_compiles("
    #include <openssl/ssl.h>
    #include <openssl/opensslconf.h>
    #include <openssl/evp.h>
    #include <openssl/x509.h>
    #include <openssl/pem.h>
    int main() { return 0; }
" OPENSSL_HEADERS_AVAILABLE)

keepassxreboot/keepassxc CMakeLists.txt :373

check_cxx_source_compiles("#include <new>
        int main() { void * ptr = nullptr; std::size_t size = 1; ::operator delete(ptr, size); }"
        HAVE_DEALLOCATION_FUNCTIONS)

keepassx/keepassx CMakeLists.txt :166

check_cxx_source_compiles("
  #include <zlib.h>

  #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1200)
      #error zlib 1.2.x or higher is required to use the gzip format
  #endif

  int main() { return 0; }" ZLIB_SUPPORTS_GZIP)

pytorch/FBGEMM cmake/modules/FindGnuH2fIeee.cmake :14

CHECK_CXX_SOURCE_COMPILES("
    #include <arm_neon.h>
    int main() {
        float f = 1.0f;
        uint16_t h = __gnu_f2h_ieee(f);
        return 0;
    }
" HAVE_GNU_F2H_IEEE)

LLNL/SAMRAI cmake/CMakeConfigureFile.cmake :41

check_cxx_source_compiles("int test = std::isnan(0.0)" HAVE_ISNAN)

OSVR/OSVR-Core cmake-local/CompilerFeatures.cmake :23

check_cxx_source_compiles("#include <${HEADER}>\n int main() { ${TYPE} test; return 0;}" ${VAR})

epoupon/fileshelter cmake/modules/FindFilesystem.cmake :188

check_cxx_source_compiles("${code}" CXX_FILESYSTEM_NO_LINK_NEEDED)

infiniflow/infinity third_party/fastpfor/cmake_modules/AppendCompilerFlags.cmake :32

check_cxx_source_compiles("int main() { return 0; }" ${have_flag})

mysql/mysql-connector-cpp cdk/extra/protobuf/protobuf-3.19.6/cmake/CMakeLists.txt :169

check_cxx_source_compiles("
    #include <atomic>
    int main() {
      return std::atomic<int64_t>{};
    }
  " protobuf_HAVE_BUILTIN_ATOMICS)

fligger/FateInjector wxWidgets-3.2.0/build/cmake/setup.cmake :98

check_cxx_source_compiles("${src}" ${res_var})

organicmaps/organicmaps 3party/osrm/osrm-backend/CMakeLists.txt :140

check_cxx_source_compiles("${CHECK_LTO_SRC}" LTO_WORKS)

abdes/asap_app_imgui cmake/GoogleSanitizers.cmake :59

check_cxx_source_compiles("int main() { return 0; }" ${_var}
                            ${_common_patterns})

AshamaneProject/AshamaneCore dep/boost/CMakeLists.txt :54

check_cxx_source_compiles("
  #include <boost/filesystem/path.hpp>
  #include <boost/filesystem/operations.hpp>
  int main() { boost::filesystem::copy_file(boost::filesystem::path(), boost::filesystem::path()); }"
boost_filesystem_copy_links_without_NO_SCOPED_ENUM)