mirror of
https://github.com/facebook/sapling.git
synced 2024-10-26 19:11:50 +03:00
de7f624497
Summary: `target_link_libraries` only allows passing things that are libraries and expressly forbids passing in `-framework Foo`, which is the sort of thing we get back from pkg-config on macos. The result of misusing this is that cmake would add `["-framework", "-lFoo"]` to the argv for the linker, which is totally broken. Instead, we should use `target_link_options`. Unfortunately, cmake seems to fail to do the right thing with the ` -framework CoreFoundation -framework Security` flags returned from libgit2 on my system even using `target_link_options`; it somehow ends up with a bare `Security` and fails to link. meh. Reviewed By: strager Differential Revision: D14680672 fbshipit-source-id: 62f65ddb4d07c8194cfc453cef1349b01be6c8b3
48 lines
1.2 KiB
CMake
48 lines
1.2 KiB
CMake
# Copyright (c) 2016-present, Facebook, Inc.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the BSD-style license found in the
|
|
# LICENSE file in the root directory of this source tree. An additional grant
|
|
# of patent rights can be found in the PATENTS file in the same directory.
|
|
#
|
|
# Find libgit2
|
|
#
|
|
# This package sets:
|
|
# LIBGIT2_FOUND - Whether libgit2 was found
|
|
# LIBGIT2_INCLUDE_DIR - The include directory for libgit2
|
|
# LIBGIT2_LIBRARY - The libgit2 library
|
|
#
|
|
include(FindPackageHandleStandardArgs)
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(LIBGIT2 libgit2 QUIET)
|
|
|
|
if(LIBGIT2_FOUND)
|
|
set(CMAKE_IMPORT_FILE_VERSION 1)
|
|
add_library(libgit2 INTERFACE)
|
|
target_compile_options(libgit2 INTERFACE "${LIBGIT2_CFLAGS_OTHER}")
|
|
target_compile_options(
|
|
libgit2 INTERFACE
|
|
"${LIBGIT2_CFLAGS_OTHER}"
|
|
)
|
|
target_include_directories(
|
|
libgit2 INTERFACE
|
|
"${LIBGIT2_INCLUDE_DIR}"
|
|
)
|
|
target_link_options(
|
|
libgit2 INTERFACE
|
|
"${LIBGIT2_LDFLAGS}"
|
|
)
|
|
set(LIBGIT2_LIBRARY libgit2)
|
|
set(CMAKE_IMPORT_FILE_VERSION)
|
|
endif()
|
|
|
|
find_package_handle_standard_args(
|
|
LIBGIT2
|
|
DEFAULT_MSG
|
|
LIBGIT2_PREFIX
|
|
LIBGIT2_VERSION
|
|
LIBGIT2_LIBRARY
|
|
)
|
|
mark_as_advanced(LIBGIT2_LIBRARY)
|