-
Notifications
You must be signed in to change notification settings - Fork 1k
Allow building with cmake (to ease building on windows) #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| ### Autotools template | ||
| # http://www.gnu.org/software/automake | ||
|
|
||
| Makefile.in | ||
|
|
||
| # http://www.gnu.org/software/autoconf | ||
|
|
||
| /autom4te.cache | ||
| /aclocal.m4 | ||
| /compile | ||
| /configure | ||
| /depcomp | ||
| /install-sh | ||
| /missing | ||
| /stamp-h1 | ||
| ### C++ template | ||
| # Compiled Object files | ||
| *.slo | ||
| *.lo | ||
| *.o | ||
| *.obj | ||
|
|
||
| # Precompiled Headers | ||
| *.gch | ||
| *.pch | ||
|
|
||
| # Compiled Dynamic libraries | ||
| *.so | ||
| *.dylib | ||
| *.dll | ||
|
|
||
| # Fortran module files | ||
| *.mod | ||
|
|
||
| # Compiled Static libraries | ||
| *.lai | ||
| *.la | ||
| *.a | ||
| *.lib | ||
|
|
||
| # Executables | ||
| *.exe | ||
| *.out | ||
| *.app | ||
| ### CMake template | ||
| CMakeCache.txt | ||
| CMakeFiles | ||
| CMakeScripts | ||
| Makefile | ||
| cmake_install.cmake | ||
| install_manifest.txt | ||
| ### C template | ||
| # Object files | ||
| *.o | ||
| *.ko | ||
| *.obj | ||
| *.elf | ||
|
|
||
| # Precompiled Headers | ||
| *.gch | ||
| *.pch | ||
|
|
||
| # Libraries | ||
| *.lib | ||
| *.a | ||
| *.la | ||
| *.lo | ||
|
|
||
| # Shared objects (inc. Windows DLLs) | ||
| *.dll | ||
| *.so | ||
| *.so.* | ||
| *.dylib | ||
|
|
||
| # Executables | ||
| *.exe | ||
| *.out | ||
| *.app | ||
| *.i*86 | ||
| *.x86_64 | ||
| *.hex | ||
|
|
||
| # Debug files | ||
| *.dSYM/ | ||
|
|
||
| # Created by .ignore support plugin (hsz.mobi) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| PROJECT(Snappy C CXX) | ||
| CMAKE_MINIMUM_REQUIRED(VERSION 3.0) | ||
|
|
||
| SET(SNAPPY_MAJOR 1) | ||
| SET(SNAPPY_MINOR 1) | ||
| SET(SNAPPY_PATCHLEVEL 3) | ||
|
|
||
| # I haven't looked at what the soname for the previous | ||
| # versions of snappy... let's just start with 1.1.3 | ||
| SET(SNAPPY_SONAME "1.1.3") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That variable is useless now that you use SNAPPY_MAJOR in SET_TARGET_PROPERTIES. |
||
|
|
||
| INCLUDE(CheckIncludeFiles) | ||
| INCLUDE(CheckLibraryExists) | ||
| INCLUDE(CheckCXXSourceCompiles) | ||
| INCLUDE(TestBigEndian) | ||
| INCLUDE(GenerateExportHeader) | ||
| INCLUDE(CMakePackageConfigHelpers) | ||
|
|
||
| TEST_BIG_ENDIAN(WORDS_BIG_ENDIAN) | ||
| IF (WORDS_BIG_ENDIAN) | ||
| MESSAGE(STATUS "Builing on big endian system") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: Building |
||
| ADD_DEFINITIONS(-DWORDS_BIGENDIAN=1) | ||
| ENDIF (WORDS_BIG_ENDIAN) | ||
|
|
||
| CHECK_INCLUDE_FILES("windows.h" HAVE_WINDOWS_H) | ||
| CHECK_INCLUDE_FILES("byteswap.h" HAVE_BYTESWAP_H) | ||
| CHECK_INCLUDE_FILES("dlfcn.h" HAVE_DLFCN_H) | ||
| CHECK_INCLUDE_FILES("inttypes.h" HAVE_INTTYPES_H) | ||
| CHECK_INCLUDE_FILES("memory.h" HAVE_MEMORY_H) | ||
| CHECK_INCLUDE_FILES("stddef.h" HAVE_STDDEF_H) | ||
| CHECK_INCLUDE_FILES("stdint.h" HAVE_STDINT_H) | ||
| CHECK_INCLUDE_FILES("stdlib.h" HAVE_STDLIB_H) | ||
| CHECK_INCLUDE_FILES("strings.h" HAVE_STRINGS_H) | ||
| CHECK_INCLUDE_FILES("string.h" HAVE_STRING_H) | ||
| CHECK_INCLUDE_FILES("sys/byteswap.h" HAVE_SYS_BYTESWAP_H) | ||
| CHECK_INCLUDE_FILES("sys/endian.h" HAVE_SYS_ENDIAN_H) | ||
| CHECK_INCLUDE_FILES("stdint.h" HAVE_STDINT_H) | ||
| CHECK_INCLUDE_FILES("sys/mman.h" HAVE_SYS_MMAN_H) | ||
| CHECK_INCLUDE_FILES("sys/resource.h" HAVE_SYS_RESOURCE_H) | ||
| CHECK_INCLUDE_FILES("sys/stat.h" HAVE_SYS_STAT_H) | ||
| CHECK_INCLUDE_FILES("sys/time.h" HAVE_SYS_TIME_H) | ||
| CHECK_INCLUDE_FILES("sys/types.h" HAVE_SYS_TYPES_H) | ||
| CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H) | ||
| CHECK_INCLUDE_FILES("sys/uio.h" HAVE_SYS_UIO_H) | ||
|
|
||
| IF (NOT HAVE_SYS_UIO_H) | ||
| SET(HAVE_SYS_UIO_H 0) | ||
| ENDIF (NOT HAVE_SYS_UIO_H) | ||
|
|
||
| IF (NOT HAVE_STDINT_H) | ||
| SET(HAVE_STDINT_H 0) | ||
| ENDIF (NOT HAVE_STDINT_H) | ||
|
|
||
| IF (NOT HAVE_STDDEF_H) | ||
| SET(HAVE_STDDEF_H 0) | ||
| ENDIF (NOT HAVE_STDDEF_H) | ||
|
|
||
| CHECK_LIBRARY_EXISTS(z zlibVersion "" HAVE_LIBZ) | ||
| CHECK_LIBRARY_EXISTS(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2) | ||
| CHECK_LIBRARY_EXISTS(lzf lzf_compress "" HAVE_LIBLZF) | ||
| CHECK_LIBRARY_EXISTS(fastlz fastlz_compress "" HAVE_LIBFASTLZ) | ||
| CHECK_LIBRARY_EXISTS(quicklz qlz_compress "" HAVE_LIBQUICKLZ) | ||
|
|
||
| CHECK_CXX_SOURCE_COMPILES("int main(void) { return __builtin_expect(0, 1) ? 1 : 0; }" | ||
| HAVE_BUILTIN_EXPECT) | ||
|
|
||
| CHECK_CXX_SOURCE_COMPILES("int main(void) { return __builtin_ctzll(0) ? 1 : 0; }" | ||
| HAVE_BUILTIN_CTZ) | ||
|
|
||
|
|
||
| CONFIGURE_FILE(${Snappy_SOURCE_DIR}/cmake/config.h.in config.h) | ||
| CONFIGURE_FILE(${Snappy_SOURCE_DIR}/cmake/snappy-stubs-public.h.in snappy-stubs-public.h) | ||
|
|
||
| IF (WIN32) | ||
| ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) | ||
| ENDIF (WIN32) | ||
|
|
||
| ADD_DEFINITIONS(-DHAVE_CONFIG_H) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. target_add_definitions instead? |
||
|
|
||
| INCLUDE_DIRECTORIES(BEFORE ${Snappy_SOURCE_DIR}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgive my Cmake noobishness, but Cmake best practices says do not use include_directories but target_include_directories instead. |
||
| INCLUDE_DIRECTORIES(AFTER ${Snappy_BINARY_DIR}) | ||
|
|
||
| ADD_LIBRARY(snappy SHARED | ||
| snappy-c.cc | ||
| snappy-c.h | ||
| snappy-sinksource.cc | ||
| snappy-sinksource.h | ||
| snappy-stubs-internal.cc | ||
| snappy-stubs-public.h | ||
| snappy.cc | ||
| snappy.h) | ||
|
|
||
| GENERATE_EXPORT_HEADER(snappy | ||
| EXPORT_MACRO_NAME SNAPPY_PUBLIC_API | ||
| EXPORT_FILE_NAME snappy-visibility.h) | ||
|
|
||
| INSTALL(FILES snappy.h | ||
| snappy-c.h | ||
| snappy-sinksource.h | ||
| ${Snappy_BINARY_DIR}/snappy-stubs-public.h | ||
| ${Snappy_BINARY_DIR}/snappy-visibility.h | ||
| DESTINATION include) | ||
|
|
||
| INSTALL(TARGETS snappy | ||
| RUNTIME DESTINATION bin | ||
| LIBRARY DESTINATION lib | ||
| ARCHIVE DESTINATION lib) | ||
|
|
||
| SET_TARGET_PROPERTIES(snappy PROPERTIES SOVERSION | ||
| ${SNAPPY_MAJOR}.${SNAPPY_MINOR}.${SNAPPY_PATCHLEVEL}) | ||
|
|
||
| SET(INCLUDE_INSTALL_DIR include) | ||
| SET(LIBRARY_INSTALL_DIR lib) | ||
| SET(BINARY_INSTALL_DIR bin) | ||
|
|
||
| CONFIGURE_PACKAGE_CONFIG_FILE(cmake/SnappyConfig.cmake.in | ||
| ${Snappy_BINARY_DIR}/SnappyConfig.cmake | ||
| INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/Snappy/cmake | ||
| PATH_VARS INCLUDE_INSTALL_DIR LIBRARY_INSTALL_DIR BINARY_INSTALL_DIR | ||
| ) | ||
|
|
||
| WRITE_BASIC_PACKAGE_VERSION_FILE(${Snappy_BINARY_DIR}/SnappyConfigVersion.cmake | ||
| VERSION ${SNAPPY_MAJOR}.${SNAPPY_MINOR}.${SNAPPY_PATCHLEVEL} | ||
| COMPATIBILITY SameMajorVersion) | ||
| INSTALL(FILES ${Snappy_BINARY_DIR}/SnappyConfig.cmake | ||
| ${Snappy_BINARY_DIR}/SnappyConfigVersion.cmake | ||
| DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake) | ||
|
|
||
| ENABLE_TESTING() | ||
|
|
||
| IF (HAVE_LIBZ) | ||
| LIST(APPEND COMPRESSION_LIBS z) | ||
| ENDIF (HAVE_LIBZ) | ||
|
|
||
| IF (HAVE_LIBLZO2) | ||
| LIST(APPEND COMPRESSION_LIBS lzo2) | ||
| ENDIF (HAVE_LIBLZO2) | ||
|
|
||
| IF (HAVE_LIBLZF) | ||
| LIST(APPEND COMPRESSION_LIBS lzf) | ||
| ENDIF (HAVE_LIBLZF) | ||
|
|
||
| IF (HAVE_LIBFASTLZ) | ||
| LIST(APPEND COMPRESSION_LIBS fastlz) | ||
| ENDIF (HAVE_LIBFASTLZ) | ||
|
|
||
| IF (HAVE_LIBQUICKLZ) | ||
| LIST(APPEND COMPRESSION_LIBS quicklz) | ||
| ENDIF (HAVE_LIBQUICKLZ) | ||
|
|
||
| ADD_EXECUTABLE(snappy-unittest snappy_unittest.cc snappy-test.cc) | ||
| TARGET_LINK_LIBRARIES(snappy-unittest snappy ${COMPRESSION_LIBS}) | ||
| ADD_TEST(NAME snappy-unittest | ||
| WORKING_DIRECTORY ${Snappy_SOURCE_DIR} | ||
| COMMAND ${Snappy_BINARY_DIR}/snappy-unittest) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| set(SNAPPY_VERSION @SNAPPY_MAJOR@.@SNAPPY_MINOR@.@SNAPPY_PATCHLEVEL@) | ||
|
|
||
| @PACKAGE_INIT@ | ||
|
|
||
| set_and_check(SNAPPY_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") | ||
| set_and_check(SNAPPY_LIBRARY_DIR "@PACKAGE_LIBRARY_INSTALL_DIR@") | ||
| set_and_check(SNAPPY_BINARY_DIR "@PACKAGE_BINARY_INSTALL_DIR@") | ||
|
|
||
| check_required_components(SNAPPY) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| #ifndef SNAPPY_CONFIG_H | ||
| #define SNAPPY_CONFIG_H 1 | ||
|
|
||
| /* Define to 1 if the compiler supports __builtin_ctz and friends. */ | ||
| #cmakedefine HAVE_BUILTIN_CTZ ${HAVE_BUILTIN_CTZ} | ||
|
|
||
| /* Define to 1 if the compiler supports __builtin_expect. */ | ||
| #cmakedefine HAVE_BUILTIN_EXPECT ${HAVE_BUILTIN_EXPECT} | ||
|
|
||
| /* Define to 1 if you have the <byteswap.h> header file. */ | ||
| #cmakedefine HAVE_BYTESWAP_H ${HAVE_BYTESWAP_H} | ||
|
|
||
| /* Define to 1 if you have the <dlfcn.h> header file. */ | ||
| #cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H} | ||
|
|
||
| /* Use the gflags package for command-line parsing. */ | ||
| /* #undef HAVE_GFLAGS */ | ||
|
|
||
| /* Defined when Google Test is available. */ | ||
| /* #undef HAVE_GTEST */ | ||
|
|
||
| /* Define to 1 if you have the <inttypes.h> header file. */ | ||
| #cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H} | ||
|
|
||
| /* Define to 1 if you have the `fastlz' library (-lfastlz). */ | ||
| #cmakedefine HAVE_LIBFASTLZ ${HAVE_LIBFASTLZ} | ||
|
|
||
| /* Define to 1 if you have the `lzf' library (-llzf). */ | ||
| #cmakedefine HAVE_LIBLZF ${HAVE_LIBLZF} | ||
|
|
||
| /* Define to 1 if you have the `lzo2' library (-llzo2). */ | ||
| #cmakedefine HAVE_LIBLZO2 ${HAVE_LIBLZO2} | ||
|
|
||
| /* Define to 1 if you have the `quicklz' library (-lquicklz). */ | ||
| #cmakedefine HAVE_LIBQUICKLZ ${HAVE_LIBQUICKLZ} | ||
|
|
||
| /* Define to 1 if you have the `z' library (-lz). */ | ||
| #cmakedefine HAVE_LIBZ ${HAVE_LIBZ} | ||
|
|
||
| /* Define to 1 if you have the <sys/uio.h> header file. */ | ||
| #cmakedefine HAVE_SYS_UIO_H ${HAVE_SYS_UIO_H} | ||
|
|
||
| /* Define to 1 if you have the <memory.h> header file. */ | ||
| #cmakedefine HAVE_MEMORY_H ${HAVE_MEMORY_H} | ||
|
|
||
| /* Define to 1 if you have the <stddef.h> header file. */ | ||
| #cmakedefine HAVE_STDDEF_H ${HAVE_STDDEF_H} | ||
|
|
||
| /* Define to 1 if you have the <stdint.h> header file. */ | ||
| #cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H} | ||
|
|
||
| /* Define to 1 if you have the <stdlib.h> header file. */ | ||
| #cmakedefine HAVE_STDLIB_H ${HAVE_STDLIB_H} | ||
|
|
||
| /* Define to 1 if you have the <strings.h> header file. */ | ||
| #cmakedefine HAVE_STRINGS_H ${HAVE_STRINGS_H} | ||
|
|
||
| /* Define to 1 if you have the <string.h> header file. */ | ||
| #cmakedefine HAVE_STRING_H ${HAVE_STRING_H} | ||
|
|
||
| /* Define to 1 if you have the <sys/byteswap.h> header file. */ | ||
| #cmakedefine HAVE_SYS_BYTESWAP_H ${HAVE_SYS_BYTESWAP_H} | ||
|
|
||
| /* Define to 1 if you have the <sys/endian.h> header file. */ | ||
| #cmakedefine HAVE_SYS_ENDIAN_H ${HAVE_SYS_ENDIAN_H} | ||
|
|
||
| /* Define to 1 if you have the <sys/mman.h> header file. */ | ||
| #cmakedefine HAVE_SYS_MMAN_H ${HAVE_SYS_MMAN_H} | ||
|
|
||
| /* Define to 1 if you have the <sys/resource.h> header file. */ | ||
| #cmakedefine HAVE_SYS_RESOURCE_H ${HAVE_SYS_RESOURCE_H} | ||
|
|
||
| /* Define to 1 if you have the <sys/stat.h> header file. */ | ||
| #cmakedefine HAVE_SYS_STAT_H ${HAVE_SYS_STAT_H} | ||
|
|
||
| /* Define to 1 if you have the <sys/time.h> header file. */ | ||
| #cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H} | ||
|
|
||
| /* Define to 1 if you have the <sys/types.h> header file. */ | ||
| #cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES} | ||
|
|
||
| /* Define to 1 if you have the <unistd.h> header file. */ | ||
| #cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} | ||
|
|
||
| /* Define to 1 if you have the <windows.h> header file. */ | ||
| #cmakedefine HAVE_WINDOWS_H ${HAVE_WINDOWS_H} | ||
|
|
||
| /* Define to 1 if you have the ANSI C header files. */ | ||
| #define STDC_HEADERS 1 | ||
|
|
||
| /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most | ||
| significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ | ||
| #cmakedefine WORDS_BIGENDIAN | ||
|
|
||
| #if defined(_MSC_VER) && (_MSC_VER <= 1900) | ||
| typedef __int64 ssize_t; | ||
| #endif | ||
|
|
||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The project is CXX only no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We export a C only API by wrapping the C++ code. See snappy-c.h.