<commit_before># ~~~
# Copyright 2022 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.
# ~~~

include(GoogleapisConfig)
set(DOXYGEN_PROJECT_NAME "Access Context Manager API C++ Client")
set(DOXYGEN_PROJECT_BRIEF
    "A C++ Client Library for the Access Context Manager API")
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION} (Experimental)")
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "accesscontextmanager_internal"
                            "accesscontextmanager_testing" "examples")
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/quickstart)

# Creates the proto headers needed by doxygen.
set(GOOGLE_CLOUD_CPP_DOXYGEN_DEPS google-cloud-cpp::accesscontextmanager_protos)

include(GoogleCloudCppCommon)

set(EXTERNAL_GOOGLEAPIS_SOURCE
    "${PROJECT_BINARY_DIR}/external/googleapis/src/googleapis_download")
find_path(PROTO_INCLUDE_DIR google/protobuf/descriptor.proto)
if (PROTO_INCLUDE_DIR)
    list(INSERT PROTOBUF_IMPORT_DIRS 0 "${PROTO_INCLUDE_DIR}")
endif ()

include(CompileProtos)
google_cloud_cpp_grpcpp_library(
    google_cloud_cpp_accesscontextmanager_protos
    # cmake-format: sort
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/type/device_resources.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/access_context_manager.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/access_level.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/access_policy.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/gcp_user_access_binding.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/service_perimeter.proto
    PROTO_PATH_DIRECTORIES
    "${EXTERNAL_GOOGLEAPIS_SOURCE}"
    "${PROTO_INCLUDE_DIR}")
external_googleapis_set_version_and_alias(accesscontextmanager_protos)
target_link_libraries(
    google_cloud_cpp_accesscontextmanager_protos
    PUBLIC #
           google-cloud-cpp::api_annotations_protos
           google-cloud-cpp::api_client_protos
           google-cloud-cpp::api_field_behavior_protos
           google-cloud-cpp::api_http_protos
           google-cloud-cpp::api_resource_protos
           google-cloud-cpp::longrunning_operations_protos
           google-cloud-cpp::rpc_status_protos
           google-cloud-cpp::type_expr_protos)

file(
    GLOB source_files
    RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
    "*.h" "*.cc" "internal/*.h" "internal/*.cc")
list(SORT source_files)
add_library(google_cloud_cpp_accesscontextmanager ${source_files})
target_include_directories(
    google_cloud_cpp_accesscontextmanager
    PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
           $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
           $<INSTALL_INTERFACE:include>)
target_link_libraries(
    google_cloud_cpp_accesscontextmanager
    PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common
           google-cloud-cpp::accesscontextmanager_protos)
google_cloud_cpp_add_common_options(google_cloud_cpp_accesscontextmanager)
set_target_properties(
    google_cloud_cpp_accesscontextmanager
    PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-accesscontextmanager
               VERSION "${PROJECT_VERSION}" SOVERSION
                                            "${PROJECT_VERSION_MAJOR}")
target_compile_options(google_cloud_cpp_accesscontextmanager
                       PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})

add_library(google-cloud-cpp::experimental-accesscontextmanager ALIAS
            google_cloud_cpp_accesscontextmanager)

# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
# for these, a regular library would not work on macOS (where the library needs
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
# that they need absolute paths for their sources.
file(
    GLOB relative_mock_files
    RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
    "mocks/*.h")
list(SORT relative_mock_files)
set(mock_files)
foreach (file IN LISTS relative_mock_files)
    list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
endforeach ()
add_library(google_cloud_cpp_accesscontextmanager_mocks INTERFACE)
target_sources(google_cloud_cpp_accesscontextmanager_mocks
               INTERFACE ${mock_files})
target_link_libraries(
    google_cloud_cpp_accesscontextmanager_mocks
    INTERFACE google-cloud-cpp::experimental-accesscontextmanager
              GTest::gmock_main GTest::gmock GTest::gtest)
set_target_properties(
    google_cloud_cpp_accesscontextmanager_mocks
    PROPERTIES EXPORT_NAME
               google-cloud-cpp::experimental-accesscontextmanager_mocks)
target_include_directories(
    google_cloud_cpp_accesscontextmanager_mocks
    INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
              $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
              $<INSTALL_INTERFACE:include>)
target_compile_options(google_cloud_cpp_accesscontextmanager_mocks
                       INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
<commit_msg>test(accesscontextmanager): enable quickstart in CI (#8373)<commit_after># ~~~
# Copyright 2022 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.
# ~~~

include(GoogleapisConfig)
set(DOXYGEN_PROJECT_NAME "Access Context Manager API C++ Client")
set(DOXYGEN_PROJECT_BRIEF
    "A C++ Client Library for the Access Context Manager API")
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION} (Experimental)")
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "accesscontextmanager_internal"
                            "accesscontextmanager_testing" "examples")
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/quickstart)

# Creates the proto headers needed by doxygen.
set(GOOGLE_CLOUD_CPP_DOXYGEN_DEPS google-cloud-cpp::accesscontextmanager_protos)

include(GoogleCloudCppCommon)

set(EXTERNAL_GOOGLEAPIS_SOURCE
    "${PROJECT_BINARY_DIR}/external/googleapis/src/googleapis_download")
find_path(PROTO_INCLUDE_DIR google/protobuf/descriptor.proto)
if (PROTO_INCLUDE_DIR)
    list(INSERT PROTOBUF_IMPORT_DIRS 0 "${PROTO_INCLUDE_DIR}")
endif ()

include(CompileProtos)
google_cloud_cpp_grpcpp_library(
    google_cloud_cpp_accesscontextmanager_protos
    # cmake-format: sort
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/type/device_resources.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/access_context_manager.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/access_level.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/access_policy.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/gcp_user_access_binding.proto
    ${EXTERNAL_GOOGLEAPIS_SOURCE}/google/identity/accesscontextmanager/v1/service_perimeter.proto
    PROTO_PATH_DIRECTORIES
    "${EXTERNAL_GOOGLEAPIS_SOURCE}"
    "${PROTO_INCLUDE_DIR}")
external_googleapis_set_version_and_alias(accesscontextmanager_protos)
target_link_libraries(
    google_cloud_cpp_accesscontextmanager_protos
    PUBLIC #
           google-cloud-cpp::api_annotations_protos
           google-cloud-cpp::api_client_protos
           google-cloud-cpp::api_field_behavior_protos
           google-cloud-cpp::api_http_protos
           google-cloud-cpp::api_resource_protos
           google-cloud-cpp::longrunning_operations_protos
           google-cloud-cpp::rpc_status_protos
           google-cloud-cpp::type_expr_protos)

file(
    GLOB source_files
    RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
    "*.h" "*.cc" "internal/*.h" "internal/*.cc")
list(SORT source_files)
add_library(google_cloud_cpp_accesscontextmanager ${source_files})
target_include_directories(
    google_cloud_cpp_accesscontextmanager
    PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
           $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
           $<INSTALL_INTERFACE:include>)
target_link_libraries(
    google_cloud_cpp_accesscontextmanager
    PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common
           google-cloud-cpp::accesscontextmanager_protos)
google_cloud_cpp_add_common_options(google_cloud_cpp_accesscontextmanager)
set_target_properties(
    google_cloud_cpp_accesscontextmanager
    PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-accesscontextmanager
               VERSION "${PROJECT_VERSION}" SOVERSION
                                            "${PROJECT_VERSION_MAJOR}")
target_compile_options(google_cloud_cpp_accesscontextmanager
                       PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})

add_library(google-cloud-cpp::experimental-accesscontextmanager ALIAS
            google_cloud_cpp_accesscontextmanager)

# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
# for these, a regular library would not work on macOS (where the library needs
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
# that they need absolute paths for their sources.
file(
    GLOB relative_mock_files
    RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
    "mocks/*.h")
list(SORT relative_mock_files)
set(mock_files)
foreach (file IN LISTS relative_mock_files)
    list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
endforeach ()
add_library(google_cloud_cpp_accesscontextmanager_mocks INTERFACE)
target_sources(google_cloud_cpp_accesscontextmanager_mocks
               INTERFACE ${mock_files})
target_link_libraries(
    google_cloud_cpp_accesscontextmanager_mocks
    INTERFACE google-cloud-cpp::experimental-accesscontextmanager
              GTest::gmock_main GTest::gmock GTest::gtest)
set_target_properties(
    google_cloud_cpp_accesscontextmanager_mocks
    PROPERTIES EXPORT_NAME
               google-cloud-cpp::experimental-accesscontextmanager_mocks)
target_include_directories(
    google_cloud_cpp_accesscontextmanager_mocks
    INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
              $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
              $<INSTALL_INTERFACE:include>)
target_compile_options(google_cloud_cpp_accesscontextmanager_mocks
                       INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})

include(CTest)
if (BUILD_TESTING)
    add_executable(accesscontextmanager_quickstart "quickstart/quickstart.cc")
    target_link_libraries(
        accesscontextmanager_quickstart
        PRIVATE google-cloud-cpp::experimental-accesscontextmanager)
    google_cloud_cpp_add_common_options(accesscontextmanager_quickstart)
    add_test(
        NAME accesscontextmanager_quickstart
        COMMAND cmake -P "${PROJECT_SOURCE_DIR}/cmake/quickstart-runner.cmake"
                $<TARGET_FILE:accesscontextmanager_quickstart> "")
    set_tests_properties(
        accesscontextmanager_quickstart
        PROPERTIES LABELS "integration-test;quickstart" PASS_REGULAR_EXPRESSION
                   "Permanent error in ListAccessLevels:")
endif ()

{'fraction_non_alphanumeric': 0.07650734673197095, 'fraction_numerical': 0.0027022462421888195, 'mean_word_length': 4.975277497477296, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5318173', 'n_tokens_mistral': 3583, 'n_tokens_neox': 3482, 'n_words': 618}