Changeset View
Changeset View
Standalone View
Standalone View
src/leveldb/CMakeLists.txt
# Copyright 2017 The LEVELDB Authors. All rights reserved. | # Copyright 2017 The LEVELDB Authors. All rights reserved. | ||||
# Use of this source code is governed by a BSD-style license that can be | # Use of this source code is governed by a BSD-style license that can be | ||||
# found in the LICENSE file. See the AUTHORS file for names of contributors. | # found in the LICENSE file. See the AUTHORS file for names of contributors. | ||||
cmake_minimum_required(VERSION 3.13) | cmake_minimum_required(VERSION 3.16) | ||||
project(Leveldb VERSION 0.1.0 LANGUAGES C CXX) | project(Leveldb VERSION 0.1.0 LANGUAGES C CXX) | ||||
# This project can take advantage of C++11. | # This project can take advantage of C++11. | ||||
set(CMAKE_CXX_STANDARD 11) | set(CMAKE_CXX_STANDARD 11) | ||||
# Remove some warnings for leveldb as they can get noisy. | # Remove some warnings for leveldb as they can get noisy. | ||||
add_compiler_flags( | add_compiler_flags( | ||||
-Wno-implicit-fallthrough | -Wno-implicit-fallthrough | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
) | ) | ||||
target_compile_definitions(leveldb | target_compile_definitions(leveldb | ||||
PRIVATE | PRIVATE | ||||
WINVER=0x0500 | WINVER=0x0500 | ||||
__USE_MINGW_ANSI_STDIO=1 | __USE_MINGW_ANSI_STDIO=1 | ||||
) | ) | ||||
find_package(SHLWAPI REQUIRED) | find_package(SHLWAPI REQUIRED) | ||||
# We cannot use the imported target here, because cmake will introduce an | target_link_libraries(leveldb SHLWAPI::shlwapi) | ||||
# -isystem compilation directive and cause the build to fail with MinGw. | |||||
# This comes from a couple cmake bugs: | |||||
# - https://gitlab.kitware.com/cmake/cmake/issues/16291 | |||||
# - https://gitlab.kitware.com/cmake/cmake/issues/19095 | |||||
# These issues are solved from cmake 3.14.1. Once this version is enforced, | |||||
# the following can be used: | |||||
# target_link_libraries(leveldb SHLWAPI::shlwapi) | |||||
target_link_libraries(leveldb ${SHLWAPI_LIBRARIES}) | |||||
target_include_directories(leveldb PUBLIC ${SHLWAPI_INCLUDE_DIRS}) | |||||
else() | else() | ||||
set(LEVELDB_PLATFORM POSIX) | set(LEVELDB_PLATFORM POSIX) | ||||
target_sources(leveldb PRIVATE port/port_posix.cc) | target_sources(leveldb PRIVATE port/port_posix.cc) | ||||
set(THREADS_PREFER_PTHREAD_FLAG ON) | set(THREADS_PREFER_PTHREAD_FLAG ON) | ||||
find_package(Threads REQUIRED) | find_package(Threads REQUIRED) | ||||
target_link_libraries(leveldb Threads::Threads) | target_link_libraries(leveldb Threads::Threads) | ||||
▲ Show 20 Lines • Show All 128 Lines • Show Last 20 Lines |