cmake_minimum_required(VERSION 3.2) if (WIN32) # set windows 7 as the minimum version add_definitions(-D_WIN32_WINNT=0x0601) endif() project(leveldb) include(CheckCXXCompilerFlag) list(APPEND SOURCES db/builder.cc) list(APPEND SOURCES db/c.cc) list(APPEND SOURCES db/db_impl.cc) list(APPEND SOURCES db/db_iter.cc) list(APPEND SOURCES db/dbformat.cc) list(APPEND SOURCES db/filename.cc) list(APPEND SOURCES db/log_reader.cc) list(APPEND SOURCES db/log_writer.cc) list(APPEND SOURCES db/memtable.cc) list(APPEND SOURCES db/repair.cc) list(APPEND SOURCES db/table_cache.cc) list(APPEND SOURCES db/version_edit.cc) list(APPEND SOURCES db/version_set.cc) list(APPEND SOURCES db/write_batch.cc) list(APPEND SOURCES table/block.cc) list(APPEND SOURCES table/block_builder.cc) list(APPEND SOURCES table/filter_block.cc) list(APPEND SOURCES table/format.cc) list(APPEND SOURCES table/iterator.cc) list(APPEND SOURCES table/merger.cc) list(APPEND SOURCES table/table.cc) list(APPEND SOURCES table/table_builder.cc) list(APPEND SOURCES table/two_level_iterator.cc) list(APPEND SOURCES util/arena.cc) list(APPEND SOURCES util/bloom.cc) list(APPEND SOURCES util/cache.cc) list(APPEND SOURCES util/coding.cc) list(APPEND SOURCES util/comparator.cc) list(APPEND SOURCES util/crc32c.cc) list(APPEND SOURCES util/env.cc) list(APPEND SOURCES util/filter_policy.cc) list(APPEND SOURCES util/hash.cc) list(APPEND SOURCES util/histogram.cc) list(APPEND SOURCES util/logging.cc) list(APPEND SOURCES util/options.cc) list(APPEND SOURCES util/status.cc) list(APPEND SOURCES db/zlib_compressor.cc) list(APPEND SOURCES db/zstd_compressor.cc) list(APPEND SOURCES port/port_posix_sse.cc) include_directories(. include) if (UNIX) list(APPEND SOURCES port/port_posix.cc) list(APPEND SOURCES util/env_posix.cc) add_definitions(-DLEVELDB_PLATFORM_POSIX "-DDLLX=") if(APPLE) add_definitions(-DOS_MACOSX) endif() CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") else() message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() elseif (WIN32) list(APPEND SOURCES port/port_win.cc) list(APPEND SOURCES util/env_win.cc) list(APPEND SOURCES util/win_logger.cc) add_definitions(-DLEVELDB_PLATFORM_WINDOWS "-DDLLX=__declspec(dllexport)") endif() add_library(leveldb SHARED ${SOURCES}) find_package(ZLIB REQUIRED) if (ZLIB_FOUND) include_directories( ${ZLIB_INCLUDE_DIRS} ) target_link_libraries( leveldb ${ZLIB_LIBRARIES} ) endif(ZLIB_FOUND)