From 6a58a29039c398e10283c872b024689dbb2153c4 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Wed, 3 Feb 2021 12:18:12 +0100 Subject: [PATCH] Make CMake superbuild behave more similar to `FetchContent` - Move CMake superbuild files - Drop use of `CMakeLists.txt.in` configure files - Allow overriding dependency directories. For now, this should only be used by GitHub workflows. Will be expanded on later, possibly renaming the variables. This change is one in a series to make it easier to consume/customize Sandboxed API in downstream projects. Drive-by: - Update `.gitignore` to ignore clangd's `.cache` directory Signed-off-by: Christian Blichmann --- .gitignore | 3 +- CMakeLists.txt | 3 +- cmake/SapiDeps.cmake | 20 +- .../Download.cmake => abseil-cpp.cmake} | 31 ++- cmake/abseil/CMakeLists.txt.in | 28 -- cmake/benchmark.cmake | 61 +++++ cmake/benchmark/CMakeLists.txt.in | 28 -- cmake/benchmark/Download.cmake | 40 --- cmake/{gflags/Download.cmake => gflags.cmake} | 33 ++- cmake/gflags/CMakeLists.txt.in | 28 -- cmake/{glog/Download.cmake => glog.cmake} | 60 +++-- cmake/glog/CMakeLists.txt.in | 28 -- cmake/googletest.cmake | 59 +++++ cmake/googletest/CMakeLists.txt.in | 28 -- cmake/googletest/Download.cmake | 38 --- cmake/libcap.cmake | 128 ++++++++++ cmake/libcap/CMakeLists.txt.in | 27 -- cmake/libcap/Download.cmake | 103 -------- cmake/libffi.cmake | 121 +++++++++ cmake/libffi/CMakeLists.txt.in | 31 --- cmake/libffi/Download.cmake | 97 ------- cmake/libunwind.cmake | 239 ++++++++++++++++++ cmake/libunwind/CMakeLists.txt.in | 34 --- cmake/libunwind/Download.cmake | 212 ---------------- cmake/{ => modules}/FindLibcap.cmake | 0 cmake/{ => modules}/FindLibffi.cmake | 0 cmake/protobuf.cmake | 64 +++++ cmake/protobuf/CMakeLists.txt.in | 28 -- cmake/protobuf/Download.cmake | 42 --- cmake/zlib.cmake | 98 +++++++ cmake/zlib/CMakeLists.txt.in | 30 --- cmake/zlib/Download.cmake | 78 ------ 32 files changed, 878 insertions(+), 942 deletions(-) rename cmake/{abseil/Download.cmake => abseil-cpp.cmake} (62%) delete mode 100644 cmake/abseil/CMakeLists.txt.in create mode 100644 cmake/benchmark.cmake delete mode 100644 cmake/benchmark/CMakeLists.txt.in delete mode 100644 cmake/benchmark/Download.cmake rename cmake/{gflags/Download.cmake => gflags.cmake} (53%) delete mode 100644 cmake/gflags/CMakeLists.txt.in rename cmake/{glog/Download.cmake => glog.cmake} (51%) delete mode 100644 cmake/glog/CMakeLists.txt.in create mode 100644 cmake/googletest.cmake delete mode 100644 cmake/googletest/CMakeLists.txt.in delete mode 100644 cmake/googletest/Download.cmake create mode 100644 cmake/libcap.cmake delete mode 100644 cmake/libcap/CMakeLists.txt.in delete mode 100644 cmake/libcap/Download.cmake create mode 100644 cmake/libffi.cmake delete mode 100644 cmake/libffi/CMakeLists.txt.in delete mode 100644 cmake/libffi/Download.cmake create mode 100644 cmake/libunwind.cmake delete mode 100644 cmake/libunwind/CMakeLists.txt.in delete mode 100644 cmake/libunwind/Download.cmake rename cmake/{ => modules}/FindLibcap.cmake (100%) rename cmake/{ => modules}/FindLibffi.cmake (100%) create mode 100644 cmake/protobuf.cmake delete mode 100644 cmake/protobuf/CMakeLists.txt.in delete mode 100644 cmake/protobuf/Download.cmake create mode 100644 cmake/zlib.cmake delete mode 100644 cmake/zlib/CMakeLists.txt.in delete mode 100644 cmake/zlib/Download.cmake diff --git a/.gitignore b/.gitignore index b20ccc9..7d4d38f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,8 @@ build/ *.py[co] __py_cache__/ # IDE files +.cache/ .clangd/ +.idea/ .vscode/ -.idea compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index e8c505c..3d87a31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,8 @@ if(SAPI_HARDENED_SOURCE) endif() # Sapi CMake modules, order matters -list(APPEND CMAKE_MODULE_PATH "${SAPI_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${SAPI_SOURCE_DIR}/cmake" + "${SAPI_SOURCE_DIR}/cmake/modules") include(SapiOptions) include(SapiDeps) include(SapiUtil) diff --git a/cmake/SapiDeps.cmake b/cmake/SapiDeps.cmake index 79d9c2a..691dcdf 100644 --- a/cmake/SapiDeps.cmake +++ b/cmake/SapiDeps.cmake @@ -38,56 +38,56 @@ endif() if(SAPI_ENABLE_TESTS) if(SAPI_DOWNLOAD_GOOGLETEST) - include(cmake/googletest/Download.cmake) + include(cmake/googletest.cmake) endif() check_target(gtest) check_target(gtest_main) check_target(gmock) if(SAPI_DOWNLOAD_BENCHMARK) - include(cmake/benchmark/Download.cmake) + include(cmake/benchmark.cmake) endif() check_target(benchmark) endif() if(SAPI_DOWNLOAD_ABSL) - include(cmake/abseil/Download.cmake) + include(cmake/abseil-cpp.cmake) endif() check_target(absl::core_headers) if(SAPI_DOWNLOAD_LIBCAP) - include(cmake/libcap/Download.cmake) + include(cmake/libcap.cmake) check_target(libcap::libcap) else() find_package(Libcap REQUIRED) endif() if(SAPI_DOWNLOAD_LIBFFI) - include(cmake/libffi/Download.cmake) + include(cmake/libffi.cmake) check_target(libffi::libffi) else() find_package(Libffi REQUIRED) endif() if(SAPI_DOWNLOAD_LIBUNWIND) - include(cmake/libunwind/Download.cmake) + include(cmake/libunwind.cmake) endif() check_target(unwind_ptrace_wrapped) if(SAPI_DOWNLOAD_GFLAGS) - include(cmake/gflags/Download.cmake) + include(cmake/gflags.cmake) endif() check_target(gflags) if(SAPI_DOWNLOAD_GLOG) - include(cmake/glog/Download.cmake) + include(cmake/glog.cmake) endif() check_target(glog::glog) add_dependencies(glog gflags::gflags) if(SAPI_DOWNLOAD_PROTOBUF) - include(cmake/protobuf/Download.cmake) + include(cmake/protobuf.cmake) check_target(protobuf::libprotobuf) check_target(protobuf::protoc) else() @@ -96,7 +96,7 @@ endif() if(SAPI_ENABLE_EXAMPLES) if(SAPI_DOWNLOAD_ZLIB) - include(cmake/zlib/Download.cmake) + include(cmake/zlib.cmake) check_target(ZLIB::ZLIB) else() find_package(ZLIB REQUIRED) diff --git a/cmake/abseil/Download.cmake b/cmake/abseil-cpp.cmake similarity index 62% rename from cmake/abseil/Download.cmake rename to cmake/abseil-cpp.cmake index c76afe3..546fb72 100644 --- a/cmake/abseil/Download.cmake +++ b/cmake/abseil-cpp.cmake @@ -12,12 +12,31 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Downloads and unpacks Abseil at configure time +set(workdir "${CMAKE_BINARY_DIR}/_deps/absl-populate") -set(workdir "${CMAKE_BINARY_DIR}/absl-download") +set(SAPI_ABSL_GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git + CACHE STRING "") +set(SAPI_ABSL_GIT_TAG 4fd9a1ec5077daac14eeee05df931d658ec0b7b8 + CACHE STRING "") # 2020-11-19 +set(SAPI_ABSL_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/absl-src" CACHE STRING "") +set(SAPI_ABSL_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/absl-build" CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(absl-populate NONE) +include(ExternalProject) +ExternalProject_Add(absl + GIT_REPOSITORY \"${SAPI_ABSL_GIT_REPOSITORY}\" + GIT_TAG \"${SAPI_ABSL_GIT_TAG}\" + SOURCE_DIR \"${SAPI_ABSL_SOURCE_DIR}\" + BINARY_DIR \"${SAPI_ABSL_BINARY_DIR}\" + CONFIGURE_COMMAND \"\" + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" +) +") -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE error WORKING_DIRECTORY "${workdir}") @@ -42,8 +61,8 @@ set(BUILD_TESTING OFF) # Avoid errors when re-configuring SAPI set(ABSL_CXX_STANDARD ${SAPI_CXX_STANDARD} CACHE STRING "" FORCE) set(ABSL_ENABLE_INSTALL ON CACHE BOOL "" FORCE) -add_subdirectory("${CMAKE_BINARY_DIR}/absl-src" - "${CMAKE_BINARY_DIR}/absl-build" EXCLUDE_FROM_ALL) +add_subdirectory("${SAPI_ABSL_SOURCE_DIR}" + "${SAPI_ABSL_BINARY_DIR}" EXCLUDE_FROM_ALL) if(_sapi_saved_BUILD_TESTING) set(BUILD_TESTING "${_sapi_saved_BUILD_TESTING}") diff --git a/cmake/abseil/CMakeLists.txt.in b/cmake/abseil/CMakeLists.txt.in deleted file mode 100644 index 8222d85..0000000 --- a/cmake/abseil/CMakeLists.txt.in +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(absl-download NONE) - -include(ExternalProject) -ExternalProject_Add(absl - GIT_REPOSITORY https://github.com/abseil/abseil-cpp - GIT_TAG 4fd9a1ec5077daac14eeee05df931d658ec0b7b8 # 2020-11-19 - SOURCE_DIR "${CMAKE_BINARY_DIR}/absl-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/absl-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cmake/benchmark.cmake b/cmake/benchmark.cmake new file mode 100644 index 0000000..cb735a1 --- /dev/null +++ b/cmake/benchmark.cmake @@ -0,0 +1,61 @@ +# Copyright 2019 Google LLC +# +# 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. + +set(workdir "${CMAKE_BINARY_DIR}/_deps/benchmark-populate") + +set(SAPI_BENCHMARK_GIT_REPOSITORY https://github.com/google/benchmark.git + CACHE STRING "") +set(SAPI_BENCHMARK_GIT_TAG 56898e9a92fba537671d5462df9c5ef2ea6a823a + CACHE STRING "") # 2020-04-23 +set(SAPI_BENCHMARK_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/benchmark-src" + CACHE STRING "") +set(SAPI_BENCHMARK_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/benchmark-build" + CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(benchmark-populate NONE) +include(ExternalProject) +ExternalProject_Add(benchmark + GIT_REPOSITORY \"${SAPI_BENCHMARK_GIT_REPOSITORY}\" + GIT_TAG \"${SAPI_BENCHMARK_GIT_TAG}\" + SOURCE_DIR \"${SAPI_BENCHMARK_SOURCE_DIR}\" + BINARY_DIR \"${SAPI_BENCHMARK_BINARY_DIR}\" + CONFIGURE_COMMAND \"\" + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" +) +") + +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") +endif() + +set(BENCHMARK_ENABLE_TESTING OFF) +set(BENCHMARK_ENABLE_EXCEPTIONS OFF) +set(BENCHMARK_ENABLE_GTEST_TESTS OFF) + +add_subdirectory("${SAPI_BENCHMARK_SOURCE_DIR}" + "${SAPI_BENCHMARK_BINARY_DIR}" EXCLUDE_FROM_ALL) diff --git a/cmake/benchmark/CMakeLists.txt.in b/cmake/benchmark/CMakeLists.txt.in deleted file mode 100644 index e2dc7f7..0000000 --- a/cmake/benchmark/CMakeLists.txt.in +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(benchmark-download NONE) - -include(ExternalProject) -ExternalProject_Add(benchmark - GIT_REPOSITORY https://github.com/google/benchmark.git - GIT_TAG 56898e9a92fba537671d5462df9c5ef2ea6a823a # 2020-04-23 - SOURCE_DIR "${CMAKE_BINARY_DIR}/benchmark-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/benchmark-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cmake/benchmark/Download.cmake b/cmake/benchmark/Download.cmake deleted file mode 100644 index 8bc622b..0000000 --- a/cmake/benchmark/Download.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -# Downloads and unpacks Benchmark at configure time - -set(workdir "${CMAKE_BINARY_DIR}/benchmark-download") - -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") -endif() - -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") -endif() - -set(BENCHMARK_ENABLE_TESTING OFF) -set(BENCHMARK_ENABLE_EXCEPTIONS OFF) -set(BENCHMARK_ENABLE_GTEST_TESTS OFF) - -add_subdirectory("${CMAKE_BINARY_DIR}/benchmark-src" - "${CMAKE_BINARY_DIR}/benchmark-build" EXCLUDE_FROM_ALL) diff --git a/cmake/gflags/Download.cmake b/cmake/gflags.cmake similarity index 53% rename from cmake/gflags/Download.cmake rename to cmake/gflags.cmake index 00a006d..df73ebd 100644 --- a/cmake/gflags/Download.cmake +++ b/cmake/gflags.cmake @@ -12,12 +12,33 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Downloads and unpacks gflags at configure time +set(workdir "${CMAKE_BINARY_DIR}/_deps/gflags-populate") -set(workdir "${CMAKE_BINARY_DIR}/gflags-download") +set(SAPI_GFLAGS_GIT_REPOSITORY https://github.com/gflags/gflags.git + CACHE STRING "") +set(SAPI_GFLAGS_GIT_TAG addd749114fab4f24b7ea1e0f2f837584389e52c + CACHE STRING "") # 2020-03-18 +set(SAPI_GFLAGS_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/gflags-src" + CACHE STRING "") +set(SAPI_GFLAGS_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/gflags-build" + CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(gflags-populate NONE) +include(ExternalProject) +ExternalProject_Add(gflags + GIT_REPOSITORY \"${SAPI_GFLAGS_GIT_REPOSITORY}\" + GIT_TAG \"${SAPI_GFLAGS_GIT_TAG}\" + SOURCE_DIR \"${SAPI_GFLAGS_SOURCE_DIR}\" + BINARY_DIR \"${SAPI_GFLAGS_BINARY_DIR}\" + CONFIGURE_COMMAND \"\" + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" +) +") -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE error WORKING_DIRECTORY "${workdir}") @@ -38,5 +59,5 @@ set(GFLAGS_INSTALL_SHARED_LIBS ${SAPI_ENABLE_SHARED_LIBS}) set(GFLAGS_INSTALL_HEADERS OFF) # TODO: Temporary off set(GFLAGS_BUILD_TESTING FALSE) -add_subdirectory("${CMAKE_BINARY_DIR}/gflags-src" - "${CMAKE_BINARY_DIR}/gflags-build" EXCLUDE_FROM_ALL) +add_subdirectory("${SAPI_GFLAGS_SOURCE_DIR}" + "${SAPI_GFLAGS_BINARY_DIR}" EXCLUDE_FROM_ALL) diff --git a/cmake/gflags/CMakeLists.txt.in b/cmake/gflags/CMakeLists.txt.in deleted file mode 100644 index 6428456..0000000 --- a/cmake/gflags/CMakeLists.txt.in +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(gflags-download NONE) - -include(ExternalProject) -ExternalProject_Add(gflags - GIT_REPOSITORY https://github.com/gflags/gflags.git - GIT_TAG addd749114fab4f24b7ea1e0f2f837584389e52c # 2020-03-18 - SOURCE_DIR "${CMAKE_BINARY_DIR}/gflags-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/gflags-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cmake/glog/Download.cmake b/cmake/glog.cmake similarity index 51% rename from cmake/glog/Download.cmake rename to cmake/glog.cmake index 91755f4..2af1185 100644 --- a/cmake/glog/Download.cmake +++ b/cmake/glog.cmake @@ -12,17 +12,35 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Downloads and unpacks glog at configure time - # Allows use target_link_libraries() with targets in other directories. if(POLICY CMP0079) cmake_policy(SET CMP0079 NEW) endif() -set(workdir "${CMAKE_BINARY_DIR}/glog-download") +set(workdir "${CMAKE_BINARY_DIR}/_deps/glog-populate") + +set(SAPI_GLOG_GIT_REPOSITORY https://github.com/google/glog.git CACHE STRING "") +set(SAPI_GLOG_GIT_TAG 3ba8976592274bc1f907c402ce22558011d6fc5e + CACHE STRING "") # 2020-02-16 +set(SAPI_GLOG_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/glog-src" CACHE STRING "") +set(SAPI_GLOG_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/glog-build" CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(glog-populate NONE) +include(ExternalProject) +ExternalProject_Add(glog + GIT_REPOSITORY \"${SAPI_GLOG_GIT_REPOSITORY}\" + GIT_TAG \"${SAPI_GLOG_GIT_TAG}\" + SOURCE_DIR \"${SAPI_GLOG_SOURCE_DIR}\" + BINARY_DIR \"${SAPI_GLOG_BINARY_DIR}\" + CONFIGURE_COMMAND \"\" + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" +) +") -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE error WORKING_DIRECTORY "${workdir}") @@ -37,32 +55,38 @@ if(error) message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") endif() -# Force gflags from subdirectory -set(WITH_GFLAGS OFF CACHE BOOL "" FORCE) -set(HAVE_LIB_GFLAGS 1 CACHE STRING "" FORCE) +set(_sapi_saved_BUILD_TESTING ${BUILD_TESTING}) -set(WITH_UNWIND OFF CACHE BOOL "" FORCE) +# Force gflags from subdirectory +set(WITH_GFLAGS FALSE CACHE BOOL "" FORCE) +set(HAVE_LIB_GFLAGS TRUE CACHE STRING "" FORCE) + +set(WITH_UNWIND FALSE CACHE BOOL "" FORCE) set(UNWIND_LIBRARY FALSE) set(HAVE_PWD_H FALSE) -set(WITH_PKGCONFIG ON CACHE BOOL "" FORCE) +set(WITH_PKGCONFIG TRUE CACHE BOOL "" FORCE) -set(_glog_BUILD_TESTING ${BUILD_TESTING}) set(BUILD_TESTING FALSE) set(BUILD_SHARED_LIBS ${SAPI_ENABLE_SHARED_LIBS}) -add_subdirectory("${CMAKE_BINARY_DIR}/glog-src" - "${CMAKE_BINARY_DIR}/glog-build" EXCLUDE_FROM_ALL) -set(BUILD_TESTING ${_glog_BUILD_TESTING}) -set(_glog_BUILD_TESTING) + +add_subdirectory("${SAPI_GLOG_SOURCE_DIR}" + "${SAPI_GLOG_BINARY_DIR}" EXCLUDE_FROM_ALL) + target_include_directories(glog PUBLIC - $ - $ + $ + $ ) add_library(gflags_nothreads STATIC IMPORTED) set_target_properties(gflags_nothreads PROPERTIES - IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/gflags-build/libgflags_nothreads.a") + IMPORTED_LOCATION + "${CMAKE_BINARY_DIR}/_deps/gflags-build/libgflags_nothreads.a") target_link_libraries(glog PRIVATE -Wl,--whole-archive gflags_nothreads -Wl,--no-whole-archive ) + +if(_sapi_saved_BUILD_TESTING) + set(BUILD_TESTING "${_sapi_saved_BUILD_TESTING}") +endif() diff --git a/cmake/glog/CMakeLists.txt.in b/cmake/glog/CMakeLists.txt.in deleted file mode 100644 index 2fad67d..0000000 --- a/cmake/glog/CMakeLists.txt.in +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(glog-download NONE) - -include(ExternalProject) -ExternalProject_Add(glog - GIT_REPOSITORY https://github.com/google/glog.git - GIT_TAG 3ba8976592274bc1f907c402ce22558011d6fc5e # 2020-02-16 - SOURCE_DIR "${CMAKE_BINARY_DIR}/glog-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/glog-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cmake/googletest.cmake b/cmake/googletest.cmake new file mode 100644 index 0000000..73ab62b --- /dev/null +++ b/cmake/googletest.cmake @@ -0,0 +1,59 @@ +# Copyright 2019 Google LLC +# +# 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. + +set(workdir "${CMAKE_BINARY_DIR}/_deps/googletest-populate") + +set(SAPI_GOOGLETEST_GIT_REPOSITORY https://github.com/google/googletest.git + CACHE STRING "") +set(SAPI_GOOGLETEST_GIT_TAG dcc92d0ab6c4ce022162a23566d44f673251eee4 + CACHE STRING "") # 2020-04-16 +set(SAPI_GOOGLETEST_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/googletest-src" + CACHE STRING "") +set(SAPI_GOOGLETEST_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/googletest-build" + CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(googletest-populate NONE) +include(ExternalProject) +ExternalProject_Add(googletest + GIT_REPOSITORY \"${SAPI_GOOGLETEST_GIT_REPOSITORY}\" + GIT_TAG \"${SAPI_GOOGLETEST_GIT_TAG}\" + SOURCE_DIR \"${SAPI_GOOGLETEST_SOURCE_DIR}\" + BINARY_DIR \"${SAPI_GOOGLETEST_BINARY_DIR}\" + CONFIGURE_COMMAND \"\" + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" +) +") + +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") +endif() + +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +add_subdirectory("${SAPI_GOOGLETEST_SOURCE_DIR}" + "${SAPI_GOOGLETEST_BINARY_DIR}" EXCLUDE_FROM_ALL) diff --git a/cmake/googletest/CMakeLists.txt.in b/cmake/googletest/CMakeLists.txt.in deleted file mode 100644 index 09a7f36..0000000 --- a/cmake/googletest/CMakeLists.txt.in +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(googletest-download NONE) - -include(ExternalProject) -ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG dcc92d0ab6c4ce022162a23566d44f673251eee4 # 2020-04-16 - SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cmake/googletest/Download.cmake b/cmake/googletest/Download.cmake deleted file mode 100644 index cbb28e4..0000000 --- a/cmake/googletest/Download.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -# Downloads and unpacks Googletest at configure time - -set(workdir "${CMAKE_BINARY_DIR}/googletest-download") - -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") -endif() - -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") -endif() - -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - -add_subdirectory("${CMAKE_BINARY_DIR}/googletest-src" - "${CMAKE_BINARY_DIR}/googletest-build" EXCLUDE_FROM_ALL) diff --git a/cmake/libcap.cmake b/cmake/libcap.cmake new file mode 100644 index 0000000..55e9192 --- /dev/null +++ b/cmake/libcap.cmake @@ -0,0 +1,128 @@ +# Copyright 2019 Google LLC +# +# 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. + +set(workdir "${CMAKE_BINARY_DIR}/_deps/libcap-populate") + +set(SAPI_LIBCAP_URL + https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.27.tar.gz + CACHE STRING "") +set(SAPI_LIBCAP_URL_HASH + SHA256=260b549c154b07c3cdc16b9ccc93c04633c39f4fb6a4a3b8d1fa5b8a9c3f5fe8 + CACHE STRING "") # 2019-04-16 +set(SAPI_LIBCAP_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/libcap-src" + CACHE STRING "") +set(SAPI_LIBCAP_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/libcap-build" + CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(libcap-populate NONE) +include(ExternalProject) +ExternalProject_Add(libcap + URL \"${SAPI_LIBCAP_URL}\" + URL_HASH \"${SAPI_LIBCAP_URL_HASH}\" + SOURCE_DIR \"${SAPI_LIBCAP_SOURCE_DIR}\" + BINARY_DIR \"${SAPI_LIBCAP_BINARY_DIR}\" + CONFIGURE_COMMAND \"\" + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" +) +") + +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") +endif() + +set(libcap_INCLUDE_DIR "${SAPI_LIBCAP_SOURCE_DIR}/libcap/include") + +add_custom_command(OUTPUT ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_names.list.h + VERBATIM + COMMAND # Use the same logic as libcap/Makefile + sed -ne [=[/^#define[ \\t]CAP[_A-Z]\+[ \\t]\+[0-9]\+/{s/^#define \([^ \\t]*\)[ \\t]*\([^ \\t]*\)/\{\"\1\",\2\},/p;}]=] + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/include/uapi/linux/capability.h | + tr [:upper:] [:lower:] > ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_names.list.h +) + +if (CMAKE_CROSSCOMPILING AND BUILD_C_COMPILER) + add_custom_command(OUTPUT ${SAPI_LIBCAP_SOURCE_DIR}/libcap/libcap_makenames + VERBATIM + # Use the same logic as libcap/Makefile + COMMAND ${BUILD_C_COMPILER} ${BUILD_C_FLAGS} + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/_makenames.c + -o ${SAPI_LIBCAP_SOURCE_DIR}/libcap/libcap_makenames + DEPENDS ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_names.list.h + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/_makenames.c + ) + + add_custom_command(OUTPUT ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_names.h + COMMAND ${SAPI_LIBCAP_SOURCE_DIR}/libcap/libcap_makenames > + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_names.h + DEPENDS ${SAPI_LIBCAP_SOURCE_DIR}/libcap/libcap_makenames + ) +else() + add_executable(libcap_makenames + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_names.list.h + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/_makenames.c + ) + + target_include_directories(libcap_makenames PUBLIC + ${SAPI_LIBCAP_SOURCE_DIR}/libcap + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/include + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/include/uapi + ) + + add_custom_command(OUTPUT ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_names.h + COMMAND libcap_makenames > ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_names.h + ) +endif() + +add_library(cap STATIC + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_alloc.c + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_extint.c + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_file.c + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_flag.c + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_names.h + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_proc.c + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/cap_text.c + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/include/uapi/linux/capability.h + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/libcap.h +) +add_library(libcap::libcap ALIAS cap) +target_include_directories(cap PUBLIC + ${SAPI_LIBCAP_SOURCE_DIR}/libcap + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/include + ${SAPI_LIBCAP_SOURCE_DIR}/libcap/include/uapi +) +target_compile_options(cap PRIVATE + -Wno-tautological-compare + -Wno-unused-result +) +target_compile_definitions(cap PRIVATE + # Work around sys/xattr.h not declaring this + -DXATTR_NAME_CAPS="\"security.capability\"" +) +target_link_libraries(cap PRIVATE + sapi::base +) diff --git a/cmake/libcap/CMakeLists.txt.in b/cmake/libcap/CMakeLists.txt.in deleted file mode 100644 index 40ac904..0000000 --- a/cmake/libcap/CMakeLists.txt.in +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(libcap-download NONE) - -include(ExternalProject) -ExternalProject_Add(libcap - URL https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.27.tar.gz - URL_HASH SHA256=260b549c154b07c3cdc16b9ccc93c04633c39f4fb6a4a3b8d1fa5b8a9c3f5fe8 # 2019-04-16 - SOURCE_DIR "${CMAKE_BINARY_DIR}/libcap-src" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cmake/libcap/Download.cmake b/cmake/libcap/Download.cmake deleted file mode 100644 index 1ef10b3..0000000 --- a/cmake/libcap/Download.cmake +++ /dev/null @@ -1,103 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -# Downloads and unpacks libunwind at configure time - -set(workdir "${CMAKE_BINARY_DIR}/libcap-download") - -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") -endif() - -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") -endif() - -set(_cap_src "${CMAKE_BINARY_DIR}/libcap-src") - -set(libcap_INCLUDE_DIR ${_cap_src}/libcap/include) - -add_custom_command(OUTPUT ${_cap_src}/libcap/cap_names.list.h - VERBATIM - # Use the same logic as libcap/Makefile - COMMAND sed -ne [=[/^#define[ \\t]CAP[_A-Z]\+[ \\t]\+[0-9]\+/{s/^#define \([^ \\t]*\)[ \\t]*\([^ \\t]*\)/\{\"\1\",\2\},/p;}]=] - ${_cap_src}/libcap/include/uapi/linux/capability.h | - tr [:upper:] [:lower:] > ${_cap_src}/libcap/cap_names.list.h -) - -if (CMAKE_CROSSCOMPILING AND BUILD_C_COMPILER) - add_custom_command(OUTPUT ${_cap_src}/libcap/libcap_makenames - VERBATIM - # Use the same logic as libcap/Makefile - COMMAND ${BUILD_C_COMPILER} ${BUILD_C_FLAGS} ${_cap_src}/libcap/_makenames.c -o ${_cap_src}/libcap/libcap_makenames - DEPENDS ${_cap_src}/libcap/cap_names.list.h ${_cap_src}/libcap/_makenames.c - ) - - add_custom_command(OUTPUT ${_cap_src}/libcap/cap_names.h - COMMAND ${_cap_src}/libcap/libcap_makenames > ${_cap_src}/libcap/cap_names.h - DEPENDS ${_cap_src}/libcap/libcap_makenames - ) -else() - add_executable(libcap_makenames - ${_cap_src}/libcap/cap_names.list.h - ${_cap_src}/libcap/_makenames.c - ) - - target_include_directories(libcap_makenames PUBLIC - ${_cap_src}/libcap - ${_cap_src}/libcap/include - ${_cap_src}/libcap/include/uapi - ) - - add_custom_command(OUTPUT ${_cap_src}/libcap/cap_names.h - COMMAND libcap_makenames > ${_cap_src}/libcap/cap_names.h - ) -endif() - -add_library(cap STATIC - ${_cap_src}/libcap/cap_alloc.c - ${_cap_src}/libcap/cap_extint.c - ${_cap_src}/libcap/cap_file.c - ${_cap_src}/libcap/cap_flag.c - ${_cap_src}/libcap/cap_names.h - ${_cap_src}/libcap/cap_proc.c - ${_cap_src}/libcap/cap_text.c - ${_cap_src}/libcap/include/uapi/linux/capability.h - ${_cap_src}/libcap/libcap.h -) -add_library(libcap::libcap ALIAS cap) -target_include_directories(cap PUBLIC - ${_cap_src}/libcap - ${_cap_src}/libcap/include - ${_cap_src}/libcap/include/uapi -) -target_compile_options(cap PRIVATE - -Wno-tautological-compare - -Wno-unused-result -) -target_compile_definitions(cap PRIVATE - # Work around sys/xattr.h not declaring this - -DXATTR_NAME_CAPS="\"security.capability\"" -) -target_link_libraries(cap PRIVATE - sapi::base -) diff --git a/cmake/libffi.cmake b/cmake/libffi.cmake new file mode 100644 index 0000000..f3abb56 --- /dev/null +++ b/cmake/libffi.cmake @@ -0,0 +1,121 @@ +# Copyright 2020 Google LLC +# +# 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. + +set(workdir "${CMAKE_BINARY_DIR}/_deps/libffi-populate") + +set(SAPI_LIBFFI_URL + https://github.com/libffi/libffi/releases/download/v3.3-rc2/libffi-3.3-rc2.tar.gz + CACHE STRING "") +set(SAPI_LIBFFI_URL_HASH + SHA256=653ffdfc67fbb865f39c7e5df2a071c0beb17206ebfb0a9ecb18a18f63f6b263 + CACHE STRING "") # 2019-11-02 +set(SAPI_LIBFFI_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/libffi-src" + CACHE STRING "") +set(SAPI_LIBFFI_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/libffi-build" + CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(libffi-populate NONE) +include(ExternalProject) +ExternalProject_Add(libffi + URL \"${SAPI_LIBFFI_URL}\" + URL_HASH \"${SAPI_LIBFFI_URL_HASH}\" + SOURCE_DIR \"${SAPI_LIBFFI_SOURCE_DIR}\" + CONFIGURE_COMMAND ./configure + --disable-dependency-tracking + --disable-builddir + ${SAPI_THIRD_PARTY_CONFIGUREOPTS} + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" + BUILD_IN_SOURCE TRUE +) +") + +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") +endif() + +set(libffi_INCLUDE_DIR ${SAPI_LIBFFI_SOURCE_DIR}/libffi/include) + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + list(APPEND _ffi_platform_srcs + ${SAPI_LIBFFI_SOURCE_DIR}/src/x86/asmnames.h + ${SAPI_LIBFFI_SOURCE_DIR}/src/x86/ffi.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/x86/ffi64.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/x86/ffiw64.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/x86/internal.h + ${SAPI_LIBFFI_SOURCE_DIR}/src/x86/internal64.h + ${SAPI_LIBFFI_SOURCE_DIR}/src/x86/sysv.S + ${SAPI_LIBFFI_SOURCE_DIR}/src/x86/unix64.S + ${SAPI_LIBFFI_SOURCE_DIR}/src/x86/win64.S + ) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64") + list(APPEND _ffi_platform_srcs + ${SAPI_LIBFFI_SOURCE_DIR}/src/powerpc/ffi.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/powerpc/ffi_linux64.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/powerpc/ffi_sysv.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/powerpc/linux64.S + ${SAPI_LIBFFI_SOURCE_DIR}/src/powerpc/linux64_closure.S + ${SAPI_LIBFFI_SOURCE_DIR}/src/powerpc/ppc_closure.S + ${SAPI_LIBFFI_SOURCE_DIR}/src/powerpc/sysv.S + # Textual headers + ${SAPI_LIBFFI_SOURCE_DIR}/src/powerpc/ffi_powerpc.h + ${SAPI_LIBFFI_SOURCE_DIR}/src/powerpc/asm.h + ) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + list(APPEND _ffi_platform_srcs + ${SAPI_LIBFFI_SOURCE_DIR}/src/aarch64/ffi.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/aarch64/internal.h + ${SAPI_LIBFFI_SOURCE_DIR}/src/aarch64/sysv.S + ) +endif() + +add_library(ffi STATIC + ${SAPI_LIBFFI_SOURCE_DIR}/fficonfig.h + ${SAPI_LIBFFI_SOURCE_DIR}/include/ffi.h + ${SAPI_LIBFFI_SOURCE_DIR}/include/ffi_cfi.h + ${SAPI_LIBFFI_SOURCE_DIR}/include/ffi_common.h + ${SAPI_LIBFFI_SOURCE_DIR}/include/ffitarget.h + ${SAPI_LIBFFI_SOURCE_DIR}/src/closures.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/debug.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/java_raw_api.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/prep_cif.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/raw_api.c + ${SAPI_LIBFFI_SOURCE_DIR}/src/types.c + ${_ffi_platform_srcs} +) +add_library(libffi::libffi ALIAS ffi) +target_include_directories(ffi PUBLIC + ${SAPI_LIBFFI_SOURCE_DIR} + ${SAPI_LIBFFI_SOURCE_DIR}/include +) +target_compile_options(ffi PRIVATE + -Wno-vla + -Wno-unused-result +) +target_link_libraries(ffi PRIVATE + sapi::base +) diff --git a/cmake/libffi/CMakeLists.txt.in b/cmake/libffi/CMakeLists.txt.in deleted file mode 100644 index 8712d2e..0000000 --- a/cmake/libffi/CMakeLists.txt.in +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(libffi-download NONE) - -include(ExternalProject) -ExternalProject_Add(libffi - URL https://github.com/libffi/libffi/releases/download/v3.3-rc2/libffi-3.3-rc2.tar.gz - URL_HASH SHA256=653ffdfc67fbb865f39c7e5df2a071c0beb17206ebfb0a9ecb18a18f63f6b263 # 2019-11-02 - SOURCE_DIR "${CMAKE_BINARY_DIR}/libffi-src" - CONFIGURE_COMMAND ./configure - --disable-dependency-tracking - --disable-builddir - ${SAPI_THIRD_PARTY_CONFIGUREOPTS} - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - BUILD_IN_SOURCE TRUE -) diff --git a/cmake/libffi/Download.cmake b/cmake/libffi/Download.cmake deleted file mode 100644 index 168f8d8..0000000 --- a/cmake/libffi/Download.cmake +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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. - -# Downloads and unpacks libunwind at configure time - -set(workdir "${CMAKE_BINARY_DIR}/libffi-download") - -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") -endif() - -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") -endif() - -set(_ffi_src "${CMAKE_BINARY_DIR}/libffi-src") - -set(libffi_INCLUDE_DIR ${_ffi_src}/libffi/include) - -if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - list(APPEND _ffi_platform_srcs - ${_ffi_src}/src/x86/asmnames.h - ${_ffi_src}/src/x86/ffi.c - ${_ffi_src}/src/x86/ffi64.c - ${_ffi_src}/src/x86/ffiw64.c - ${_ffi_src}/src/x86/internal.h - ${_ffi_src}/src/x86/internal64.h - ${_ffi_src}/src/x86/sysv.S - ${_ffi_src}/src/x86/unix64.S - ${_ffi_src}/src/x86/win64.S - ) -elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64") - list(APPEND _ffi_platform_srcs - ${_ffi_src}/src/powerpc/ffi.c - ${_ffi_src}/src/powerpc/ffi_linux64.c - ${_ffi_src}/src/powerpc/ffi_sysv.c - ${_ffi_src}/src/powerpc/linux64.S - ${_ffi_src}/src/powerpc/linux64_closure.S - ${_ffi_src}/src/powerpc/ppc_closure.S - ${_ffi_src}/src/powerpc/sysv.S - # Textual headers - ${_ffi_src}/src/powerpc/ffi_powerpc.h - ${_ffi_src}/src/powerpc/asm.h - ) -elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") - list(APPEND _ffi_platform_srcs - ${_ffi_src}/src/aarch64/ffi.c - ${_ffi_src}/src/aarch64/internal.h - ${_ffi_src}/src/aarch64/sysv.S - ) -endif() - -add_library(ffi STATIC - ${_ffi_src}/fficonfig.h - ${_ffi_src}/include/ffi.h - ${_ffi_src}/include/ffi_cfi.h - ${_ffi_src}/include/ffi_common.h - ${_ffi_src}/include/ffitarget.h - ${_ffi_src}/src/closures.c - ${_ffi_src}/src/debug.c - ${_ffi_src}/src/java_raw_api.c - ${_ffi_src}/src/prep_cif.c - ${_ffi_src}/src/raw_api.c - ${_ffi_src}/src/types.c - ${_ffi_platform_srcs} -) -add_library(libffi::libffi ALIAS ffi) -target_include_directories(ffi PUBLIC - ${_ffi_src} - ${_ffi_src}/include -) -target_compile_options(ffi PRIVATE - -Wno-vla - -Wno-unused-result -) -target_link_libraries(ffi PRIVATE - sapi::base -) diff --git a/cmake/libunwind.cmake b/cmake/libunwind.cmake new file mode 100644 index 0000000..bd05672 --- /dev/null +++ b/cmake/libunwind.cmake @@ -0,0 +1,239 @@ +# Copyright 2019 Google LLC +# +# 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. + +set(workdir "${CMAKE_BINARY_DIR}/_deps/libunwind-populate") + +set(SAPI_LIBUNWIND_URL + https://github.com/libunwind/libunwind/releases/download/v1.2.1/libunwind-1.2.1.tar.gz + CACHE STRING "") +set(SAPI_LIBUNWIND_URL_HASH + SHA256=3f3ecb90e28cbe53fba7a4a27ccce7aad188d3210bb1964a923a731a27a75acb + CACHE STRING "") +set(SAPI_LIBUNWIND_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/libunwind-src" + CACHE STRING "") +set(SAPI_LIBUNWIND_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/libunwind-build" + CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(libunwind-populate NONE) +include(ExternalProject) +ExternalProject_Add(libunwind + URL \"${SAPI_LIBUNWIND_URL}\" + URL_HASH \"${SAPI_LIBUNWIND_URL_HASH}\" + SOURCE_DIR \"${SAPI_LIBUNWIND_SOURCE_DIR}\" + CONFIGURE_COMMAND ./configure + --disable-dependency-tracking + --disable-documentation + --disable-minidebuginfo + --disable-shared + --enable-ptrace + ${SAPI_THIRD_PARTY_CONFIGUREOPTS} + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" + BUILD_IN_SOURCE TRUE +) +") + +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") +endif() + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(_unwind_cpu "x86_64") + list(APPEND _unwind_platform_srcs + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/Gcreate_addr_space.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/Gglobal.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/Ginit.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/Gos-linux.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/Gregs.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/Gresume.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/Gstash_frame.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/Gstep.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/is_fpreg.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/setcontext.S + ) + list(APPEND _unwind_ptrace_srcs + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/Ginit_remote.c + ) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64") + set(_unwind_cpu "ppc64") + list(APPEND _unwind_platform_srcs + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc/Gis_signal_frame.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc64/Gcreate_addr_space.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc64/Gglobal.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc64/Ginit.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc64/Gregs.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc64/Gresume.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc64/Gstep.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc64/get_func_addr.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc64/is_fpreg.c + ) + list(APPEND _unwind_ptrace_srcs + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ppc/Ginit_remote.c + ) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + set(_unwind_cpu "aarch64") + list(APPEND _unwind_platform_srcs + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/Gcreate_addr_space.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/Gglobal.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/Ginit.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/Gis_signal_frame.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/Gregs.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/Gresume.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/Gstash_frame.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/Gstep.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/is_fpreg.c + ) + list(APPEND _unwind_ptrace_srcs + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/aarch64/Ginit_remote.c + ) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm") + set(_unwind_cpu "arm") + list(APPEND _unwind_platform_srcs + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Gcreate_addr_space.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Gex_tables.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Gglobal.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Ginit.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Gis_signal_frame.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Gregs.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Gresume.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Gstash_frame.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Gstep.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/is_fpreg.c + ) + list(APPEND _unwind_ptrace_srcs + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/arm/Ginit_remote.c + ) +endif() + +add_library(unwind_ptrace_wrapped STATIC + # internal_headers + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/compiler.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/config.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/dwarf.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/dwarf-eh.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/dwarf_i.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/libunwind.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/libunwind-common.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/libunwind-coredump.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/libunwind-dynamic.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/libunwind-ptrace.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/libunwind-x86_64.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/libunwind_i.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/mempool.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/remote.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/tdep-x86_64/dwarf-config.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/tdep-x86_64/libunwind_i.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/tdep/dwarf-config.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/tdep/libunwind_i.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/unwind.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/elf32.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/elf64.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/elfxx.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/os-linux.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/init.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/offsets.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/ucontext_i.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/x86_64/unwind_i.h + # included_sources + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/elf64.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/elfxx.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/elfxx.c + # sources_common + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/dwarf/Gexpr.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/dwarf/Gfde.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/dwarf/Gfind_proc_info-lsb.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/dwarf/Gfind_unwind_table.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/dwarf/Gparser.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/dwarf/Gpe.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/dwarf/Gstep.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/dwarf/global.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/Gdestroy_addr_space.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/Gdyn-extract.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/Gfind_dynamic_proc_info.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/Gget_accessors.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/Gget_proc_name.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/Gget_reg.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/Gput_dynamic_unwind_info.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/flush_cache.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/init.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/mempool.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/os-linux.c + ${_unwind_platform_srcs} + # srcs + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/mi/Gdyn-remote.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_access_fpreg.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_access_mem.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_access_reg.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_accessors.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_create.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_destroy.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_elf.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_find_proc_info.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_get_dyn_info_list_addr.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_get_proc_name.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_internal.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_put_unwind_info.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_reg_offset.c + ${SAPI_LIBUNWIND_SOURCE_DIR}/src/ptrace/_UPT_resume.c + # hdrs + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/config.h + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/libunwind.h + # source_ptrace + ${_unwind_ptrace_srcs} +) +add_library(unwind::unwind_ptrace_wrapped ALIAS unwind_ptrace_wrapped) +target_include_directories(unwind_ptrace_wrapped PUBLIC + ${SAPI_LIBUNWIND_SOURCE_DIR}/include + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/tdep + ${SAPI_LIBUNWIND_SOURCE_DIR}/include/tdep-${_unwind_cpu} + ${SAPI_LIBUNWIND_SOURCE_DIR}/src +) +target_compile_options(unwind_ptrace_wrapped PRIVATE + -fno-common + -Wno-cpp +) +target_compile_definitions(unwind_ptrace_wrapped + PRIVATE -DHAVE_CONFIG_H + -D_GNU_SOURCE + -DNO_FRAME_POINTER + PUBLIC -D_UPT_accessors=_UPT_accessors_wrapped + -D_UPT_create=_UPT_create_wrapped + -D_UPT_destroy=_UPT_destroy_wrapped + + -D_U${_unwind_cpu}_create_addr_space=_U${_unwind_cpu}_create_addr_space_wrapped + -D_U${_unwind_cpu}_destroy_addr_space=_U${_unwind_cpu}_destroy_addr_space_wrapped + -D_U${_unwind_cpu}_get_proc_name=_U${_unwind_cpu}_get_proc_name_wrapped + -D_U${_unwind_cpu}_get_reg=_U${_unwind_cpu}_get_reg_wrapped + -D_U${_unwind_cpu}_init_remote=_U${_unwind_cpu}_init_remote_wrapped + -D_U${_unwind_cpu}_step=_U${_unwind_cpu}_step_wrapped + + -Dptrace=ptrace_wrapped +) +target_link_libraries(unwind_ptrace_wrapped PRIVATE + sapi::base + sandbox2::ptrace_hook +) diff --git a/cmake/libunwind/CMakeLists.txt.in b/cmake/libunwind/CMakeLists.txt.in deleted file mode 100644 index 1216958..0000000 --- a/cmake/libunwind/CMakeLists.txt.in +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(libunwind-download NONE) - -include(ExternalProject) -ExternalProject_Add(libunwind - URL https://github.com/libunwind/libunwind/releases/download/v1.2.1/libunwind-1.2.1.tar.gz - URL_HASH SHA256=3f3ecb90e28cbe53fba7a4a27ccce7aad188d3210bb1964a923a731a27a75acb - SOURCE_DIR "${CMAKE_BINARY_DIR}/libunwind-src" - CONFIGURE_COMMAND ./configure - --disable-dependency-tracking - --disable-documentation - --disable-minidebuginfo - --disable-shared - --enable-ptrace - ${SAPI_THIRD_PARTY_CONFIGUREOPTS} - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - BUILD_IN_SOURCE TRUE -) diff --git a/cmake/libunwind/Download.cmake b/cmake/libunwind/Download.cmake deleted file mode 100644 index 88221a8..0000000 --- a/cmake/libunwind/Download.cmake +++ /dev/null @@ -1,212 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -# Downloads and unpacks libunwind at configure time - -set(workdir "${CMAKE_BINARY_DIR}/libunwind-download") - -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") -endif() - -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") -endif() - -set(_unwind_src "${CMAKE_BINARY_DIR}/libunwind-src") - -if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - set(_unwind_cpu "x86_64") - list(APPEND _unwind_platform_srcs - ${_unwind_src}/src/x86_64/Gcreate_addr_space.c - ${_unwind_src}/src/x86_64/Gglobal.c - ${_unwind_src}/src/x86_64/Ginit.c - ${_unwind_src}/src/x86_64/Gos-linux.c - ${_unwind_src}/src/x86_64/Gregs.c - ${_unwind_src}/src/x86_64/Gresume.c - ${_unwind_src}/src/x86_64/Gstash_frame.c - ${_unwind_src}/src/x86_64/Gstep.c - ${_unwind_src}/src/x86_64/is_fpreg.c - ${_unwind_src}/src/x86_64/setcontext.S - ) - list(APPEND _unwind_ptrace_srcs - ${_unwind_src}/src/x86_64/Ginit_remote.c - ) -elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64") - set(_unwind_cpu "ppc64") - list(APPEND _unwind_platform_srcs - ${_unwind_src}/src/ppc/Gis_signal_frame.c - ${_unwind_src}/src/ppc64/Gcreate_addr_space.c - ${_unwind_src}/src/ppc64/Gglobal.c - ${_unwind_src}/src/ppc64/Ginit.c - ${_unwind_src}/src/ppc64/Gregs.c - ${_unwind_src}/src/ppc64/Gresume.c - ${_unwind_src}/src/ppc64/Gstep.c - ${_unwind_src}/src/ppc64/get_func_addr.c - ${_unwind_src}/src/ppc64/is_fpreg.c - ) - list(APPEND _unwind_ptrace_srcs - ${_unwind_src}/src/ppc/Ginit_remote.c - ) -elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") - set(_unwind_cpu "aarch64") - list(APPEND _unwind_platform_srcs - ${_unwind_src}/src/aarch64/Gcreate_addr_space.c - ${_unwind_src}/src/aarch64/Gglobal.c - ${_unwind_src}/src/aarch64/Ginit.c - ${_unwind_src}/src/aarch64/Gis_signal_frame.c - ${_unwind_src}/src/aarch64/Gregs.c - ${_unwind_src}/src/aarch64/Gresume.c - ${_unwind_src}/src/aarch64/Gstash_frame.c - ${_unwind_src}/src/aarch64/Gstep.c - ${_unwind_src}/src/aarch64/is_fpreg.c - ) - list(APPEND _unwind_ptrace_srcs - ${_unwind_src}/src/aarch64/Ginit_remote.c - ) -elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm") - set(_unwind_cpu "arm") - list(APPEND _unwind_platform_srcs - ${_unwind_src}/src/arm/Gcreate_addr_space.c - ${_unwind_src}/src/arm/Gex_tables.c - ${_unwind_src}/src/arm/Gglobal.c - ${_unwind_src}/src/arm/Ginit.c - ${_unwind_src}/src/arm/Gis_signal_frame.c - ${_unwind_src}/src/arm/Gregs.c - ${_unwind_src}/src/arm/Gresume.c - ${_unwind_src}/src/arm/Gstash_frame.c - ${_unwind_src}/src/arm/Gstep.c - ${_unwind_src}/src/arm/is_fpreg.c - ) - list(APPEND _unwind_ptrace_srcs - ${_unwind_src}/src/arm/Ginit_remote.c - ) -endif() - -add_library(unwind_ptrace_wrapped STATIC - # internal_headers - ${_unwind_src}/include/compiler.h - ${_unwind_src}/include/config.h - ${_unwind_src}/include/dwarf.h - ${_unwind_src}/include/dwarf-eh.h - ${_unwind_src}/include/dwarf_i.h - ${_unwind_src}/include/libunwind.h - ${_unwind_src}/include/libunwind-common.h - ${_unwind_src}/include/libunwind-coredump.h - ${_unwind_src}/include/libunwind-dynamic.h - ${_unwind_src}/include/libunwind-ptrace.h - ${_unwind_src}/include/libunwind-x86_64.h - ${_unwind_src}/include/libunwind_i.h - ${_unwind_src}/include/mempool.h - ${_unwind_src}/include/remote.h - ${_unwind_src}/include/tdep-x86_64/dwarf-config.h - ${_unwind_src}/include/tdep-x86_64/libunwind_i.h - ${_unwind_src}/include/tdep/dwarf-config.h - ${_unwind_src}/include/tdep/libunwind_i.h - ${_unwind_src}/include/unwind.h - ${_unwind_src}/src/elf32.h - ${_unwind_src}/src/elf64.h - ${_unwind_src}/src/elfxx.h - ${_unwind_src}/src/os-linux.h - ${_unwind_src}/src/x86_64/init.h - ${_unwind_src}/src/x86_64/offsets.h - ${_unwind_src}/src/x86_64/ucontext_i.h - ${_unwind_src}/src/x86_64/unwind_i.h - # included_sources - ${_unwind_src}/src/elf64.h - ${_unwind_src}/src/elfxx.h - ${_unwind_src}/src/elfxx.c - # sources_common - ${_unwind_src}/src/dwarf/Gexpr.c - ${_unwind_src}/src/dwarf/Gfde.c - ${_unwind_src}/src/dwarf/Gfind_proc_info-lsb.c - ${_unwind_src}/src/dwarf/Gfind_unwind_table.c - ${_unwind_src}/src/dwarf/Gparser.c - ${_unwind_src}/src/dwarf/Gpe.c - ${_unwind_src}/src/dwarf/Gstep.c - ${_unwind_src}/src/dwarf/global.c - ${_unwind_src}/src/mi/Gdestroy_addr_space.c - ${_unwind_src}/src/mi/Gdyn-extract.c - ${_unwind_src}/src/mi/Gfind_dynamic_proc_info.c - ${_unwind_src}/src/mi/Gget_accessors.c - ${_unwind_src}/src/mi/Gget_proc_name.c - ${_unwind_src}/src/mi/Gget_reg.c - ${_unwind_src}/src/mi/Gput_dynamic_unwind_info.c - ${_unwind_src}/src/mi/flush_cache.c - ${_unwind_src}/src/mi/init.c - ${_unwind_src}/src/mi/mempool.c - ${_unwind_src}/src/os-linux.c - ${_unwind_platform_srcs} - # srcs - ${_unwind_src}/src/mi/Gdyn-remote.c - ${_unwind_src}/src/ptrace/_UPT_access_fpreg.c - ${_unwind_src}/src/ptrace/_UPT_access_mem.c - ${_unwind_src}/src/ptrace/_UPT_access_reg.c - ${_unwind_src}/src/ptrace/_UPT_accessors.c - ${_unwind_src}/src/ptrace/_UPT_create.c - ${_unwind_src}/src/ptrace/_UPT_destroy.c - ${_unwind_src}/src/ptrace/_UPT_elf.c - ${_unwind_src}/src/ptrace/_UPT_find_proc_info.c - ${_unwind_src}/src/ptrace/_UPT_get_dyn_info_list_addr.c - ${_unwind_src}/src/ptrace/_UPT_get_proc_name.c - ${_unwind_src}/src/ptrace/_UPT_internal.h - ${_unwind_src}/src/ptrace/_UPT_put_unwind_info.c - ${_unwind_src}/src/ptrace/_UPT_reg_offset.c - ${_unwind_src}/src/ptrace/_UPT_resume.c - # hdrs - ${_unwind_src}/include/config.h - ${_unwind_src}/include/libunwind.h - # source_ptrace - ${_unwind_ptrace_srcs} -) -add_library(unwind::unwind_ptrace_wrapped ALIAS unwind_ptrace_wrapped) -target_include_directories(unwind_ptrace_wrapped PUBLIC - ${_unwind_src}/include - ${_unwind_src}/include/tdep - ${_unwind_src}/include/tdep-${_unwind_cpu} - ${_unwind_src}/src -) -target_compile_options(unwind_ptrace_wrapped PRIVATE - -fno-common - -Wno-cpp -) -target_compile_definitions(unwind_ptrace_wrapped - PRIVATE -DHAVE_CONFIG_H - -D_GNU_SOURCE - -DNO_FRAME_POINTER - PUBLIC -D_UPT_accessors=_UPT_accessors_wrapped - -D_UPT_create=_UPT_create_wrapped - -D_UPT_destroy=_UPT_destroy_wrapped - - -D_U${_unwind_cpu}_create_addr_space=_U${_unwind_cpu}_create_addr_space_wrapped - -D_U${_unwind_cpu}_destroy_addr_space=_U${_unwind_cpu}_destroy_addr_space_wrapped - -D_U${_unwind_cpu}_get_proc_name=_U${_unwind_cpu}_get_proc_name_wrapped - -D_U${_unwind_cpu}_get_reg=_U${_unwind_cpu}_get_reg_wrapped - -D_U${_unwind_cpu}_init_remote=_U${_unwind_cpu}_init_remote_wrapped - -D_U${_unwind_cpu}_step=_U${_unwind_cpu}_step_wrapped - - -Dptrace=ptrace_wrapped -) -target_link_libraries(unwind_ptrace_wrapped PRIVATE - sapi::base - sandbox2::ptrace_hook -) diff --git a/cmake/FindLibcap.cmake b/cmake/modules/FindLibcap.cmake similarity index 100% rename from cmake/FindLibcap.cmake rename to cmake/modules/FindLibcap.cmake diff --git a/cmake/FindLibffi.cmake b/cmake/modules/FindLibffi.cmake similarity index 100% rename from cmake/FindLibffi.cmake rename to cmake/modules/FindLibffi.cmake diff --git a/cmake/protobuf.cmake b/cmake/protobuf.cmake new file mode 100644 index 0000000..56202cd --- /dev/null +++ b/cmake/protobuf.cmake @@ -0,0 +1,64 @@ +# Copyright 2019 Google LLC +# +# 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. + +set(workdir "${CMAKE_BINARY_DIR}/_deps/protobuf-populate") + +set(SAPI_PROTOBUF_GIT_REPOSITORY + https://github.com/protocolbuffers/protobuf.git + CACHE STRING "") +set(SAPI_PROTOBUF_GIT_TAG v3.11.4 CACHE STRING "") # 2020-02-14 +set(SAPI_PROTOBUF_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/protobuf-src" + CACHE STRING "") +set(SAPI_PROTOBUF_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/protobuf-build" + CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(protobuf-populate NONE) +include(ExternalProject) +ExternalProject_Add(protobuf + GIT_REPOSITORY \"${SAPI_PROTOBUF_GIT_REPOSITORY}\" + GIT_TAG \"${SAPI_PROTOBUF_GIT_TAG}\" + GIT_SUBMODULES \"cmake\" # Workaround for CMake #20579 + SOURCE_DIR \"${SAPI_PROTOBUF_SOURCE_DIR}\" + BINARY_DIR \"${SAPI_PROTOBUF_BINARY_DIR}\" + CONFIGURE_COMMAND \"\" + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" +) +") + +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") +endif() + +set(protobuf_BUILD_TESTS FALSE CACHE BOOL "") +set(protobuf_BUILD_SHARED_LIBS FALSE CACHE BOOL "") +set(protobuf_WITH_ZLIB FALSE CACHE BOOL "") + +add_subdirectory("${SAPI_PROTOBUF_SOURCE_DIR}/cmake" + "${SAPI_PROTOBUF_BINARY_DIR}" EXCLUDE_FROM_ALL) +get_property(Protobuf_INCLUDE_DIRS TARGET protobuf::libprotobuf + PROPERTY INCLUDE_DIRECTORIES) diff --git a/cmake/protobuf/CMakeLists.txt.in b/cmake/protobuf/CMakeLists.txt.in deleted file mode 100644 index 7640f2d..0000000 --- a/cmake/protobuf/CMakeLists.txt.in +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(protobuf-download NONE) - -include(ExternalProject) -ExternalProject_Add(protobuf - GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git - GIT_TAG v3.11.4 # 2020-02-14 - SOURCE_DIR "${CMAKE_BINARY_DIR}/protobuf-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/protobuf-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/cmake/protobuf/Download.cmake b/cmake/protobuf/Download.cmake deleted file mode 100644 index 8dc3432..0000000 --- a/cmake/protobuf/Download.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2019 Google LLC -# -# 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. - -# Downloads and unpacks Protobuf at configure time - -set(workdir "${CMAKE_BINARY_DIR}/protobuf-download") - -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") -endif() - -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") -endif() - -set(protobuf_BUILD_TESTS OFF CACHE BOOL "") -set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "") -set(protobuf_WITH_ZLIB OFF CACHE BOOL "") - -add_subdirectory("${CMAKE_BINARY_DIR}/protobuf-src/cmake" - "${CMAKE_BINARY_DIR}/protobuf-build" EXCLUDE_FROM_ALL) -get_property(Protobuf_INCLUDE_DIRS TARGET protobuf::libprotobuf - PROPERTY INCLUDE_DIRECTORIES) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake new file mode 100644 index 0000000..848a85f --- /dev/null +++ b/cmake/zlib.cmake @@ -0,0 +1,98 @@ +# Copyright 2020 Google LLC +# +# 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. + +set(workdir "${CMAKE_BINARY_DIR}/_deps/zlib-populate") + +set(SAPI_ZLIB_URL https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz + CACHE STRING "") +set(SAPI_ZLIB_URL_HASH + SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 + CACHE STRING "") # 2020-04-23 +set(SAPI_ZLIB_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/zlib-src" CACHE STRING "") +set(SAPI_ZLIB_BINARY_DIR "${CMAKE_BINARY_DIR}/_deps/zlib-build" CACHE STRING "") + +file(WRITE "${workdir}/CMakeLists.txt" "\ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project(zlib-populate NONE) +include(ExternalProject) +ExternalProject_Add(zlib + URL \"${SAPI_ZLIB_URL}\" + URL_HASH \"${SAPI_ZLIB_URL_HASH}\" + SOURCE_DIR \"${SAPI_ZLIB_SOURCE_DIR}\" + BINARY_DIR \"${SAPI_ZLIB_BINARY_DIR}\" + PATCH_COMMAND patch -p1 + < \"${SAPI_SOURCE_DIR}/sandboxed_api/bazel/external/zlib.patch\" + CONFIGURE_COMMAND \"\" + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TEST_COMMAND \"\" +) +") + +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE error + WORKING_DIRECTORY "${workdir}") +if(error) + message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") +endif() + +set(ZLIB_FOUND TRUE) +set(ZLIB_INCLUDE_DIRS ${SAPI_ZLIB_SOURCE_DIR}) + +add_library(z STATIC + ${SAPI_ZLIB_SOURCE_DIR}/adler32.c + ${SAPI_ZLIB_SOURCE_DIR}/compress.c + ${SAPI_ZLIB_SOURCE_DIR}/crc32.c + ${SAPI_ZLIB_SOURCE_DIR}/crc32.h + ${SAPI_ZLIB_SOURCE_DIR}/deflate.c + ${SAPI_ZLIB_SOURCE_DIR}/deflate.h + ${SAPI_ZLIB_SOURCE_DIR}/gzclose.c + ${SAPI_ZLIB_SOURCE_DIR}/gzguts.h + ${SAPI_ZLIB_SOURCE_DIR}/gzlib.c + ${SAPI_ZLIB_SOURCE_DIR}/gzread.c + ${SAPI_ZLIB_SOURCE_DIR}/gzwrite.c + ${SAPI_ZLIB_SOURCE_DIR}/infback.c + ${SAPI_ZLIB_SOURCE_DIR}/inffast.c + ${SAPI_ZLIB_SOURCE_DIR}/inffast.h + ${SAPI_ZLIB_SOURCE_DIR}/inffixed.h + ${SAPI_ZLIB_SOURCE_DIR}/inflate.c + ${SAPI_ZLIB_SOURCE_DIR}/inflate.h + ${SAPI_ZLIB_SOURCE_DIR}/inftrees.c + ${SAPI_ZLIB_SOURCE_DIR}/inftrees.h + ${SAPI_ZLIB_SOURCE_DIR}/trees.c + ${SAPI_ZLIB_SOURCE_DIR}/trees.h + ${SAPI_ZLIB_SOURCE_DIR}/uncompr.c + ${SAPI_ZLIB_SOURCE_DIR}/zconf.h + ${SAPI_ZLIB_SOURCE_DIR}/zlib.h + ${SAPI_ZLIB_SOURCE_DIR}/zutil.c + ${SAPI_ZLIB_SOURCE_DIR}/zutil.h +) +add_library(ZLIB::ZLIB ALIAS z) +target_include_directories(z PUBLIC + ${SAPI_ZLIB_SOURCE_DIR} +) +target_compile_options(z PRIVATE + -w + -Dverbose=-1 +) +target_link_libraries(z PRIVATE + sapi::base +) diff --git a/cmake/zlib/CMakeLists.txt.in b/cmake/zlib/CMakeLists.txt.in deleted file mode 100644 index 016e83f..0000000 --- a/cmake/zlib/CMakeLists.txt.in +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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. - -cmake_minimum_required(VERSION 3.12) -project(zlib-download NONE) - -include(ExternalProject) -ExternalProject_Add(zlib - URL https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz - URL_HASH SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 # 2020-04-23 - SOURCE_DIR "${CMAKE_BINARY_DIR}/zlib-src" - PATCH_COMMAND patch -p1 - < "@SAPI_SOURCE_DIR@/sandboxed_api/bazel/external/zlib.patch" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - BUILD_IN_SOURCE TRUE -) diff --git a/cmake/zlib/Download.cmake b/cmake/zlib/Download.cmake deleted file mode 100644 index 24aad46..0000000 --- a/cmake/zlib/Download.cmake +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright 2020 Google LLC -# -# 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. - -# Downloads and unpacks Abseil at configure time - -set(workdir "${CMAKE_BINARY_DIR}/zlib-download") - -configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in" - "${workdir}/CMakeLists.txt") -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "CMake step for ${PROJECT_NAME} failed: ${error}") -endif() - -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE error - WORKING_DIRECTORY "${workdir}") -if(error) - message(FATAL_ERROR "Build step for ${PROJECT_NAME} failed: ${error}") -endif() - -set(_zlib_src "${CMAKE_BINARY_DIR}/zlib-src") - -set(ZLIB_FOUND TRUE) -set(ZLIB_INCLUDE_DIRS ${_zlib_src}) - -add_library(z STATIC - ${_zlib_src}/adler32.c - ${_zlib_src}/compress.c - ${_zlib_src}/crc32.c - ${_zlib_src}/crc32.h - ${_zlib_src}/deflate.c - ${_zlib_src}/deflate.h - ${_zlib_src}/gzclose.c - ${_zlib_src}/gzguts.h - ${_zlib_src}/gzlib.c - ${_zlib_src}/gzread.c - ${_zlib_src}/gzwrite.c - ${_zlib_src}/infback.c - ${_zlib_src}/inffast.c - ${_zlib_src}/inffast.h - ${_zlib_src}/inffixed.h - ${_zlib_src}/inflate.c - ${_zlib_src}/inflate.h - ${_zlib_src}/inftrees.c - ${_zlib_src}/inftrees.h - ${_zlib_src}/trees.c - ${_zlib_src}/trees.h - ${_zlib_src}/uncompr.c - ${_zlib_src}/zconf.h - ${_zlib_src}/zlib.h - ${_zlib_src}/zutil.c - ${_zlib_src}/zutil.h -) -add_library(ZLIB::ZLIB ALIAS z) -target_include_directories(z PUBLIC - ${_zlib_src} -) -target_compile_options(z PRIVATE - -w - -Dverbose=-1 -) -target_link_libraries(z PRIVATE - sapi::base -)