From d6b8e0b3e31505780994b4f02bb35c3f00b49774 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Wed, 13 May 2020 02:09:12 -0700 Subject: [PATCH] CMake: Fix inclusion and paths for external embedding When using SAPI from an external project via CMake, the small zlib patch cannot be found during the config phase. This change also fixes an oversight in that the tests depend on some of the example code. Regardless embedding code should set `SAPI_ENABLE_EXAMPLES` to `OFF`. Disabling tests by setting `SAPI_ENABLE_TESTS` to `OFF` stays optional. PiperOrigin-RevId: 311290454 Change-Id: Ibe105895859b793b20f47c89b1a9e11cbfef2e2f --- cmake/zlib/CMakeLists.txt.in | 2 +- sandboxed_api/examples/CMakeLists.txt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/zlib/CMakeLists.txt.in b/cmake/zlib/CMakeLists.txt.in index 3b65da0..016e83f 100644 --- a/cmake/zlib/CMakeLists.txt.in +++ b/cmake/zlib/CMakeLists.txt.in @@ -21,7 +21,7 @@ ExternalProject_Add(zlib URL_HASH SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 # 2020-04-23 SOURCE_DIR "${CMAKE_BINARY_DIR}/zlib-src" PATCH_COMMAND patch -p1 - < "${CMAKE_SOURCE_DIR}/sandboxed_api/bazel/external/zlib.patch" + < "@SAPI_SOURCE_DIR@/sandboxed_api/bazel/external/zlib.patch" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/sandboxed_api/examples/CMakeLists.txt b/sandboxed_api/examples/CMakeLists.txt index ef03706..d7dd6cc 100644 --- a/sandboxed_api/examples/CMakeLists.txt +++ b/sandboxed_api/examples/CMakeLists.txt @@ -12,8 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -if(SAPI_ENABLE_EXAMPLES) +if(SAPI_ENABLE_EXAMPLES OR SAPI_ENABLE_TESTS) + # TODO(cblichmann): These are depended on by sapi::sapi_test add_subdirectory(stringop) add_subdirectory(sum) +endif() + +if(SAPI_ENABLE_EXAMPLES) add_subdirectory(zlib) endif()