2020-01-17 21:05:03 +08:00
|
|
|
# Copyright 2019 Google LLC
|
2019-07-15 19:12:55 +08:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2019-07-26 20:50:45 +08:00
|
|
|
function(check_target target)
|
|
|
|
if(NOT TARGET ${target})
|
|
|
|
message(FATAL_ERROR " SAPI: compiling Sandboxed API requires a ${target}
|
|
|
|
CMake target in your project")
|
|
|
|
endif()
|
|
|
|
endfunction()
|
2019-07-15 19:12:55 +08:00
|
|
|
|
2019-11-21 21:16:59 +08:00
|
|
|
# Use static libraries
|
2019-07-15 19:12:55 +08:00
|
|
|
set(_sapi_saved_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
2019-11-21 21:16:59 +08:00
|
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
|
2019-07-15 19:12:55 +08:00
|
|
|
|
2019-07-26 20:50:45 +08:00
|
|
|
if(SAPI_ENABLE_TESTS)
|
2019-11-21 21:16:59 +08:00
|
|
|
if(SAPI_DOWNLOAD_GOOGLETEST)
|
2019-07-26 20:50:45 +08:00
|
|
|
include(cmake/googletest/Download.cmake)
|
|
|
|
endif()
|
|
|
|
check_target(gtest)
|
|
|
|
check_target(gtest_main)
|
|
|
|
check_target(gmock)
|
2019-11-21 20:03:47 +08:00
|
|
|
|
2019-11-21 21:16:59 +08:00
|
|
|
if(SAPI_DOWNLOAD_BENCHMARK)
|
2019-11-21 20:03:47 +08:00
|
|
|
include(cmake/benchmark/Download.cmake)
|
|
|
|
endif()
|
|
|
|
check_target(benchmark)
|
2019-07-26 20:50:45 +08:00
|
|
|
endif()
|
|
|
|
|
2019-11-21 21:16:59 +08:00
|
|
|
if(SAPI_DOWNLOAD_ABSL)
|
2019-07-26 20:50:45 +08:00
|
|
|
include(cmake/abseil/Download.cmake)
|
|
|
|
endif()
|
|
|
|
check_target(absl::core_headers)
|
|
|
|
|
2019-11-25 23:30:16 +08:00
|
|
|
if(SAPI_DOWNLOAD_LIBCAP)
|
|
|
|
include(cmake/libcap/Download.cmake)
|
|
|
|
check_target(libcap::libcap)
|
|
|
|
else()
|
|
|
|
find_package(Libcap REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2020-03-22 23:44:39 +08:00
|
|
|
if(SAPI_DOWNLOAD_LIBFFI)
|
|
|
|
include(cmake/libffi/Download.cmake)
|
|
|
|
check_target(libffi::libffi)
|
|
|
|
else()
|
|
|
|
find_package(Libffi REQUIRED)
|
|
|
|
endif()
|
|
|
|
|
2019-11-21 21:16:59 +08:00
|
|
|
if(SAPI_DOWNLOAD_LIBUNWIND)
|
2019-07-26 20:50:45 +08:00
|
|
|
include(cmake/libunwind/Download.cmake)
|
|
|
|
endif()
|
|
|
|
check_target(unwind_ptrace_wrapped)
|
|
|
|
|
2019-11-21 21:16:59 +08:00
|
|
|
if(SAPI_DOWNLOAD_GFLAGS)
|
2019-07-26 20:50:45 +08:00
|
|
|
include(cmake/gflags/Download.cmake)
|
|
|
|
endif()
|
|
|
|
check_target(gflags)
|
|
|
|
|
2019-11-21 21:16:59 +08:00
|
|
|
if(SAPI_DOWNLOAD_GLOG)
|
2019-07-26 20:50:45 +08:00
|
|
|
include(cmake/glog/Download.cmake)
|
|
|
|
endif()
|
|
|
|
check_target(glog::glog)
|
|
|
|
|
2019-11-21 21:16:59 +08:00
|
|
|
if(SAPI_DOWNLOAD_PROTOBUF)
|
2019-07-26 20:50:45 +08:00
|
|
|
include(cmake/protobuf/Download.cmake)
|
2019-08-22 01:00:27 +08:00
|
|
|
check_target(protobuf::libprotobuf)
|
|
|
|
check_target(protobuf::protoc)
|
|
|
|
else()
|
|
|
|
find_package(Protobuf REQUIRED)
|
2019-07-26 20:50:45 +08:00
|
|
|
endif()
|
|
|
|
|
2019-07-15 19:42:39 +08:00
|
|
|
if(SAPI_ENABLE_EXAMPLES)
|
2020-04-30 19:57:09 +08:00
|
|
|
if(SAPI_DOWNLOAD_ZLIB)
|
|
|
|
include(cmake/zlib/Download.cmake)
|
|
|
|
check_target(ZLIB::ZLIB)
|
|
|
|
else()
|
|
|
|
find_package(ZLIB REQUIRED)
|
|
|
|
endif()
|
2019-07-15 19:42:39 +08:00
|
|
|
endif()
|
2020-03-18 04:26:14 +08:00
|
|
|
|
2019-06-25 20:48:56 +08:00
|
|
|
if(NOT SAPI_ENABLE_GENERATOR)
|
|
|
|
# Find Python 3 and add its location to the cache so that its available in
|
|
|
|
# the add_sapi_library() macro in embedding projects.
|
|
|
|
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
|
|
|
set(SAPI_PYTHON3_EXECUTABLE "${Python3_EXECUTABLE}" CACHE INTERNAL "" FORCE)
|
|
|
|
endif()
|
2019-07-15 19:12:55 +08:00
|
|
|
|
|
|
|
# Undo global change
|
|
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_sapi_saved_CMAKE_FIND_LIBRARY_SUFFIXES})
|