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
This commit is contained in:
Christian Blichmann 2020-05-13 02:09:12 -07:00 committed by Copybara-Service
parent 144a441d79
commit d6b8e0b3e3
2 changed files with 6 additions and 2 deletions

View File

@ -21,7 +21,7 @@ ExternalProject_Add(zlib
URL_HASH SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 # 2020-04-23 URL_HASH SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 # 2020-04-23
SOURCE_DIR "${CMAKE_BINARY_DIR}/zlib-src" SOURCE_DIR "${CMAKE_BINARY_DIR}/zlib-src"
PATCH_COMMAND patch -p1 PATCH_COMMAND patch -p1
< "${CMAKE_SOURCE_DIR}/sandboxed_api/bazel/external/zlib.patch" < "@SAPI_SOURCE_DIR@/sandboxed_api/bazel/external/zlib.patch"
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""

View File

@ -12,8 +12,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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(stringop)
add_subdirectory(sum) add_subdirectory(sum)
endif()
if(SAPI_ENABLE_EXAMPLES)
add_subdirectory(zlib) add_subdirectory(zlib)
endif() endif()