-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+# We only do the subset of the snappy autoconf that actually affect the library
+# (as most of them are for the tests which we don't build.)
+
+include (CheckIncludeFileCXX)
+include (CheckCXXSourceCompiles)
+include (TestBigEndian)
+
+check_include_file_cxx (sys/mman.h HAVE_SYS_MMAN_H)
+
+check_cxx_source_compiles (
+ "main() { return __builtin_expect(1, 1) ? 1 : 0; }"
+ HAVE_BUILTIN_EXPECT
+)
+
+check_cxx_source_compiles (
+ "main() { return (__builtin_ctzll(0x100000000LL) == 32) ? 1 : 0; }"
+ HAVE_BUILTIN_CTZ
+)
+
+test_big_endian (WORDS_BIGENDIAN)
+
+configure_file (config.h.in config.h)
+
+add_definitions (-DHAVE_CONFIG_H)
+
+
+include_directories (${CMAKE_CURRENT_BINARY_DIR})
add_library (snappy_bundled STATIC
snappy.cc
#undef AC_APPLE_UNIVERSAL_BUILD
/* Define to 1 if the compiler supports __builtin_ctz and friends. */
-#undef HAVE_BUILTIN_CTZ
+#cmakedefine HAVE_BUILTIN_CTZ
/* Define to 1 if the compiler supports __builtin_expect. */
-#undef HAVE_BUILTIN_EXPECT
+#cmakedefine HAVE_BUILTIN_EXPECT
/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
+#cmakedefine HAVE_DLFCN_H
/* Use the gflags package for command-line parsing. */
-#undef HAVE_GFLAGS
+#cmakedefine HAVE_GFLAGS
/* Defined when Google Test is available. */
-#undef HAVE_GTEST
+#cmakedefine HAVE_GTEST
/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
+#cmakedefine HAVE_INTTYPES_H
/* Define to 1 if you have the `fastlz' library (-lfastlz). */
-#undef HAVE_LIBFASTLZ
+#cmakedefine HAVE_LIBFASTLZ
/* Define to 1 if you have the `lzf' library (-llzf). */
-#undef HAVE_LIBLZF
+#cmakedefine HAVE_LIBLZF
/* Define to 1 if you have the `lzo2' library (-llzo2). */
-#undef HAVE_LIBLZO2
+#cmakedefine HAVE_LIBLZO2
/* Define to 1 if you have the `quicklz' library (-lquicklz). */
-#undef HAVE_LIBQUICKLZ
+#cmakedefine HAVE_LIBQUICKLZ
/* Define to 1 if you have the `z' library (-lz). */
-#undef HAVE_LIBZ
+#cmakedefine HAVE_LIBZ
/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
+#cmakedefine HAVE_MEMORY_H
/* Define to 1 if you have the <stddef.h> header file. */
-#undef HAVE_STDDEF_H
+#cmakedefine HAVE_STDDEF_H
/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
+#cmakedefine HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
+#cmakedefine HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
+#cmakedefine HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
+#cmakedefine HAVE_STRING_H
/* Define to 1 if you have the <sys/mman.h> header file. */
-#undef HAVE_SYS_MMAN_H
+#cmakedefine HAVE_SYS_MMAN_H
/* Define to 1 if you have the <sys/resource.h> header file. */
-#undef HAVE_SYS_RESOURCE_H
+#cmakedefine HAVE_SYS_RESOURCE_H
/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
+#cmakedefine HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
+#cmakedefine HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
+#cmakedefine HAVE_UNISTD_H
/* Define to 1 if you have the <windows.h> header file. */
-#undef HAVE_WINDOWS_H
+#cmakedefine HAVE_WINDOWS_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-# undef WORDS_BIGENDIAN
-# endif
-#endif
+#cmakedefine WORDS_BIGENDIAN