mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
CMake cleanups
- Bump minimum requred version to 3.12 (Ubuntu Cosmic LTS) - Rename `SAPI_USE_?` options to `SAPI_DOWNLOAD_?` - Improve detection of Python 3 - Use platform independent static library suffixes for `find_library()` PiperOrigin-RevId: 281727467 Change-Id: I45596b6ba08e4f8201d8dcde19a03baf825b83ec
This commit is contained in:
parent
d47c066112
commit
948b75efe9
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
project(SandboxedAPI C CXX ASM)
|
||||
|
||||
|
|
|
@ -19,50 +19,46 @@ function(check_target target)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
# Prefer to use static libraries
|
||||
# Use static libraries
|
||||
set(_sapi_saved_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
if(WIN32)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
else()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
endif()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
|
||||
if(SAPI_ENABLE_TESTS)
|
||||
if(SAPI_USE_GOOGLETEST)
|
||||
if(SAPI_DOWNLOAD_GOOGLETEST)
|
||||
include(cmake/googletest/Download.cmake)
|
||||
endif()
|
||||
check_target(gtest)
|
||||
check_target(gtest_main)
|
||||
check_target(gmock)
|
||||
|
||||
if(SAPI_USE_BENCHMARK)
|
||||
if(SAPI_DOWNLOAD_BENCHMARK)
|
||||
include(cmake/benchmark/Download.cmake)
|
||||
endif()
|
||||
check_target(benchmark)
|
||||
endif()
|
||||
|
||||
if(SAPI_USE_ABSL)
|
||||
if(SAPI_DOWNLOAD_ABSL)
|
||||
include(cmake/abseil/Download.cmake)
|
||||
endif()
|
||||
check_target(absl::core_headers)
|
||||
|
||||
if(SAPI_USE_LIBUNWIND)
|
||||
if(SAPI_DOWNLOAD_LIBUNWIND)
|
||||
include(cmake/libunwind/Download.cmake)
|
||||
endif()
|
||||
check_target(unwind_ptrace)
|
||||
check_target(unwind_ptrace_wrapped)
|
||||
|
||||
if(SAPI_USE_GFLAGS)
|
||||
if(SAPI_DOWNLOAD_GFLAGS)
|
||||
include(cmake/gflags/Download.cmake)
|
||||
endif()
|
||||
check_target(gflags)
|
||||
|
||||
if(SAPI_USE_GLOG)
|
||||
if(SAPI_DOWNLOAD_GLOG)
|
||||
include(cmake/glog/Download.cmake)
|
||||
endif()
|
||||
check_target(glog::glog)
|
||||
|
||||
if(SAPI_USE_PROTOBUF)
|
||||
if(SAPI_DOWNLOAD_PROTOBUF)
|
||||
include(cmake/protobuf/Download.cmake)
|
||||
check_target(protobuf::libprotobuf)
|
||||
check_target(protobuf::protoc)
|
||||
|
@ -75,19 +71,7 @@ find_package(Libffi REQUIRED)
|
|||
if(SAPI_ENABLE_EXAMPLES)
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS "3.12")
|
||||
# Work around FindPythonInterp sometimes not preferring Python 3.
|
||||
foreach(v IN ITEMS 3 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
|
||||
list(APPEND _sapi_py_names python${v})
|
||||
endforeach()
|
||||
find_program(Python3_EXECUTABLE NAMES ${_sapi_py_names})
|
||||
if(NOT Python3_EXECUTABLE)
|
||||
message(FATAL_ERROR "No suitable version of Python 3 found")
|
||||
endif()
|
||||
else()
|
||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
||||
endif()
|
||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
||||
|
||||
# Undo global change
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_sapi_saved_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
# below enables embedding projects to selectively override/replace these
|
||||
# dependencies. This is useful for cases where embedding projects already
|
||||
# depend on some of these libraries (e.g. Abseil).
|
||||
option(SAPI_USE_ABSL "Download Abseil at config time" ON)
|
||||
option(SAPI_USE_GOOGLETEST "Download googletest at config time" ON)
|
||||
option(SAPI_USE_BENCHMARK "Download benchmark at config time" ON)
|
||||
option(SAPI_USE_GFLAGS "Download gflags at config time" ON)
|
||||
option(SAPI_USE_GLOG "Download glog at config time" ON)
|
||||
option(SAPI_USE_PROTOBUF "Download protobuf at config time" ON)
|
||||
option(SAPI_USE_LIBUNWIND "Download libunwind at config time" ON)
|
||||
option(SAPI_DOWNLOAD_ABSL "Download Abseil at config time" ON)
|
||||
option(SAPI_DOWNLOAD_GOOGLETEST "Download googletest at config time" ON)
|
||||
option(SAPI_DOWNLOAD_BENCHMARK "Download benchmark at config time" ON)
|
||||
option(SAPI_DOWNLOAD_GFLAGS "Download gflags at config time" ON)
|
||||
option(SAPI_DOWNLOAD_GLOG "Download glog at config time" ON)
|
||||
option(SAPI_DOWNLOAD_PROTOBUF "Download protobuf at config time" ON)
|
||||
option(SAPI_DOWNLOAD_LIBUNWIND "Download libunwind at config time" ON)
|
||||
# TODO(cblichmann): These two are not currently implemented
|
||||
option(SAPI_USE_LIBCAP "Download libcap at config time" ON)
|
||||
option(SAPI_USE_LIBFFI "Download libffi at config time" ON)
|
||||
option(SAPI_DOWNLOAD_LIBCAP "Download libcap at config time" ON)
|
||||
option(SAPI_DOWNLOAD_LIBFFI "Download libffi at config time" ON)
|
||||
|
||||
option(SAPI_ENABLE_EXAMPLES "Build example code" ON)
|
||||
option(SAPI_ENABLE_TESTS "Build unit tests" ON)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(absl-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(benchmark-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(gflags-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(glog-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(googletest-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(libunwind-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(protobuf-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
|
|
Loading…
Reference in New Issue
Block a user