sapling/eden/scm/lib/backingstore/CMakeLists.txt
Xavier Deguillard 6f5f2c05f7 win: fix windows build
Summary:
The backingstore crate depends on mio which depends on ntdll. It's not entirely
clear to me why we need to do this manually and why cargo/cmake doesn't pick it
up automatically, but let's fix it this way for now.

Reviewed By: genevievehelsel

Differential Revision: D26376606

fbshipit-source-id: 26714b3f03aabefafdf48c7fb0f442cad501a058
2021-02-10 13:00:24 -08:00

61 lines
1.3 KiB
CMake

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
rust_static_library(rust_backingstore CRATE backingstore)
install_rust_static_library(
rust_backingstore
EXPORT mercurial
INSTALL_DIR lib
)
file(GLOB C_API_SRCS "c_api/*.cpp")
add_library(backingstore "${C_API_SRCS}")
set_target_properties(
backingstore
PROPERTIES
PUBLIC_HEADER
"c_api/HgNativeBackingStore.h;c_api/RustBackingStore.h"
)
target_include_directories(backingstore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(
backingstore
PRIVATE
rust_backingstore
Folly::folly
)
# curl used in the Rust crate has its own copy of curl compiled and it uses
# Crypt32 and Secur32 on Windows. We need to declare the link dependencies here
# to avoid linker errors.
if (WIN32)
target_link_libraries(
backingstore
PRIVATE
ntdll
Crypt32
Secur32
Ncrypt
)
endif()
# Reqwest links against the security framework.
if (APPLE)
target_link_libraries(
backingstore
PRIVATE
"-framework Security"
)
endif()
install(
TARGETS backingstore
EXPORT mercurial
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
PUBLIC_HEADER DESTINATION "include/eden/scm/lib/backingstore/c_api"
)