mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
e8b54f7088
PiperOrigin-RevId: 424813033 Change-Id: I617ac515e471ea220f34a9ca636aa0669799b968
91 lines
2.7 KiB
CMake
91 lines
2.7 KiB
CMake
# 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
|
|
#
|
|
# https://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.13..3.22)
|
|
project(jsonnet-sapi C CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
|
|
|
|
add_subdirectory("${SAPI_ROOT}"
|
|
"${CMAKE_BINARY_DIR}/sandboxed-api-build"
|
|
EXCLUDE_FROM_ALL)
|
|
|
|
FetchContent_Declare(jsonnet
|
|
GIT_REPOSITORY https://github.com/google/jsonnet.git
|
|
GIT_TAG v0.18.0 # 2021-12-21
|
|
)
|
|
set(BUILD_TESTS OFF CACHE BOOL "") # Do not build jsonnet tests
|
|
FetchContent_MakeAvailable(jsonnet)
|
|
create_directory_symlink("${jsonnet_SOURCE_DIR}"
|
|
"${PROJECT_BINARY_DIR}/jsonnet")
|
|
|
|
add_subdirectory(examples)
|
|
|
|
add_sapi_library(jsonnet_sapi
|
|
FUNCTIONS c_free_input
|
|
c_jsonnet_destroy
|
|
c_jsonnet_evaluate_snippet
|
|
c_jsonnet_evaluate_snippet_multi
|
|
c_jsonnet_evaluate_snippet_stream
|
|
c_jsonnet_fmt_snippet
|
|
c_jsonnet_make
|
|
c_jsonnet_realloc
|
|
c_read_input
|
|
c_write_multi_output_files
|
|
c_write_output_file
|
|
c_write_output_stream
|
|
INPUTS jsonnet_helper.h
|
|
LIBRARY jsonnet_helper
|
|
LIBRARY_NAME Jsonnet
|
|
NAMESPACE ""
|
|
)
|
|
|
|
target_include_directories(jsonnet_sapi INTERFACE
|
|
"${PROJECT_BINARY_DIR}"
|
|
)
|
|
|
|
target_link_libraries(jsonnet_sapi PUBLIC jsonnet_helper)
|
|
|
|
if(SAPI_ENABLE_TESTS)
|
|
include(GoogleTest)
|
|
enable_testing()
|
|
|
|
# Create directories so the tests will be able to access them
|
|
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/tests_input"
|
|
"${PROJECT_BINARY_DIR}/tests_output"
|
|
"${PROJECT_BINARY_DIR}/tests_expected_output")
|
|
|
|
add_custom_target(test_preparation ALL
|
|
COMMAND cp ${PROJECT_SOURCE_DIR}/examples/jsonnet_codes/*
|
|
${PROJECT_BINARY_DIR}/tests_input
|
|
COMMAND cp ${PROJECT_SOURCE_DIR}/examples/jsonnet_codes_expected_output/*
|
|
${PROJECT_BINARY_DIR}/tests_expected_output
|
|
)
|
|
|
|
add_executable(jsonnet_tests
|
|
jsonnet_tests.cc
|
|
)
|
|
target_include_directories(jsonnet_tests PUBLIC
|
|
${PROJECT_SOURCE_DIR}
|
|
)
|
|
target_link_libraries(jsonnet_tests
|
|
jsonnet_sapi
|
|
sapi::test_main
|
|
)
|
|
gtest_discover_tests(jsonnet_tests)
|
|
endif()
|