diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f6a7c0a..1eaf48e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,14 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +if (WIN32) + set(LEVELDB_PLATFORM_NAME LEVELDB_PLATFORM_WINDOWS) + # TODO(cmumford): Make UNICODE configurable for Windows. + add_definitions(-D_UNICODE -DUNICODE) +else (WIN32) + set(LEVELDB_PLATFORM_NAME LEVELDB_PLATFORM_POSIX) +endif (WIN32) + option(LEVELDB_BUILD_TESTS "Build LevelDB's unit tests" ON) option(LEVELDB_BUILD_BENCHMARKS "Build LevelDB's benchmarks" ON) option(LEVELDB_INSTALL "Install LevelDB's header and library" ON) @@ -179,12 +187,19 @@ target_sources(leveldb "${LEVELDB_PUBLIC_INCLUDE_DIR}/write_batch.h" ) -# POSIX code is specified separately so we can leave it out in the future. +if (WIN32) +target_sources(leveldb + PRIVATE + "${PROJECT_SOURCE_DIR}/util/env_windows.cc" + "${PROJECT_SOURCE_DIR}/util/windows_logger.h" +) +else (WIN32) target_sources(leveldb PRIVATE "${PROJECT_SOURCE_DIR}/util/env_posix.cc" "${PROJECT_SOURCE_DIR}/util/posix_logger.h" ) +endif (WIN32) # MemEnv is not part of the interface and could be pulled to a separate library. target_sources(leveldb @@ -203,7 +218,7 @@ target_compile_definitions(leveldb # Used by include/export.h when building shared libraries. LEVELDB_COMPILE_LIBRARY # Used by port/port.h. - LEVELDB_PLATFORM_POSIX=1 + ${LEVELDB_PLATFORM_NAME}=1 ) if (NOT HAVE_CXX17_HAS_INCLUDE) target_compile_definitions(leveldb @@ -265,7 +280,7 @@ if(LEVELDB_BUILD_TESTS) target_link_libraries("${test_target_name}" leveldb) target_compile_definitions("${test_target_name}" PRIVATE - LEVELDB_PLATFORM_POSIX=1 + ${LEVELDB_PLATFORM_NAME}=1 ) if (NOT HAVE_CXX17_HAS_INCLUDE) target_compile_definitions("${test_target_name}" @@ -314,8 +329,12 @@ if(LEVELDB_BUILD_TESTS) leveldb_test("${PROJECT_SOURCE_DIR}/util/logging_test.cc") # TODO(costan): This test also uses - # "${PROJECT_SOURCE_DIR}/util/env_posix_test_helper.h" - leveldb_test("${PROJECT_SOURCE_DIR}/util/env_posix_test.cc") + # "${PROJECT_SOURCE_DIR}/util/env_{posix|windows}_test_helper.h" + if (WIN32) + leveldb_test("${PROJECT_SOURCE_DIR}/util/env_windows_test.cc") + else (WIN32) + leveldb_test("${PROJECT_SOURCE_DIR}/util/env_posix_test.cc") + endif (WIN32) endif(NOT BUILD_SHARED_LIBS) endif(LEVELDB_BUILD_TESTS) @@ -339,7 +358,7 @@ if(LEVELDB_BUILD_BENCHMARKS) target_link_libraries("${bench_target_name}" leveldb) target_compile_definitions("${bench_target_name}" PRIVATE - LEVELDB_PLATFORM_POSIX=1 + ${LEVELDB_PLATFORM_NAME}=1 ) if (NOT HAVE_CXX17_HAS_INCLUDE) target_compile_definitions("${bench_target_name}" |