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

include(ExternalProjectHelper)
find_package(Threads REQUIRED)

if (NOT TARGET grpc_project)
    add_custom_target(grpc_project)
endif ()

if (NOT TARGET googleapis_project)
    # Give application developers a hook to configure the version and hash
    # downloaded from GitHub.
    set(
        GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL
        "https://github.com/googleapis/googleapis/archive/6a3277c0656219174ff7c345f31fb20a90b30b97.tar.gz"
        )
    set(GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256
        "793f1fe9d3adf28900792b4151b7cb2fa4ef14ae1e14ea4e7faa2be14be7a301")

    if ("${CMAKE_GENERATOR}" STREQUAL "Unix Makefiles"
        OR "${CMAKE_GENERATOR}" STREQUAL "Ninja")
        include(ProcessorCount)
        processorcount(NCPU)
        set(PARALLEL "--" "-j" "${NCPU}")
    else()
        set(PARALLEL "")
    endif ()

    # When passing a semi-colon delimited list to ExternalProject_Add, we need
    # to escape the semi-colon. Quoting does not work and escaping the semi-
    # colon does not seem to work (see https://reviews.llvm.org/D40257). A
    # workaround is to use LIST_SEPARATOR to change the delimiter, which will
    # then be replaced by an escaped semi-colon by CMake. This allows us to use
    # multiple directories for our RPATH. Normally, it'd make sense to use : as
    # a delimiter since it is a typical path-list separator, but it is a special
    # character in CMake.
    set(GOOGLE_CLOUD_CPP_INSTALL_RPATH "<INSTALL_DIR>/lib;<INSTALL_DIR>/lib64")
    string(REPLACE ";"
                   "|"
                   GOOGLE_CLOUD_CPP_INSTALL_RPATH
                   "${GOOGLE_CLOUD_CPP_INSTALL_RPATH}")

    create_external_project_library_byproduct_list(
        googleapis_byproducts "googleapis_cpp_bigtable_protos")

    set(_googleapis_toolchain_flag "")
    if (NOT "${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
        set(_googleapis_toolchain_flag
            "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
    endif ()
    set(_googleapis_triplet_flag "")
    if (NOT "${VCPKG_TARGET_TRIPLET}" STREQUAL "")
        set(_googleapis_triplet_flag
            "-DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}")
    endif ()

    include(ExternalProject)
    externalproject_add(
        googleapis_project
        DEPENDS grpc_project
        EXCLUDE_FROM_ALL ON
        PREFIX "${CMAKE_BINARY_DIR}/external/googleapis"
        INSTALL_DIR "${CMAKE_BINARY_DIR}/external"
        URL ${GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL}
        URL_HASH SHA256=${GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256}
        LIST_SEPARATOR
        |
        PATCH_COMMAND
        ${CMAKE_COMMAND}
        -E
        copy
        ${PROJECT_SOURCE_DIR}/cmake/external/googleapis/CMakeLists.txt
        <SOURCE_DIR>/CMakeLists.txt
        COMMAND
            ${CMAKE_COMMAND} -E copy
            ${PROJECT_SOURCE_DIR}/cmake/CompileProtos.cmake
            ${PROJECT_SOURCE_DIR}/cmake/PkgConfigHelper.cmake
            ${PROJECT_SOURCE_DIR}/cmake/FindgRPC.cmake
            ${PROJECT_SOURCE_DIR}/cmake/FindProtobufTargets.cmake
            ${PROJECT_SOURCE_DIR}/cmake/SelectMSVCRuntime.cmake
            ${PROJECT_SOURCE_DIR}/google/cloud/config.pc.in
            ${PROJECT_SOURCE_DIR}/cmake/external/googleapis/config.cmake.in
            ${PROJECT_SOURCE_DIR}/cmake/external/googleapis/config-version.cmake.in
            <SOURCE_DIR>
        CMAKE_ARGS ${GOOGLE_CLOUD_CPP_EXTERNAL_PROJECT_CCACHE}
                   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
                   -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
                   -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
                   -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
                   -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
                   -DCMAKE_INSTALL_RPATH=${GOOGLE_CLOUD_CPP_INSTALL_RPATH}
                   -DgRPC_DEBUG=ON
                   -Dprotobuf_DEBUG=ON
                   -DGOOGLE_CLOUD_CPP_USE_LIBCXX=${GOOGLE_CLOUD_CPP_USE_LIBCXX}
                   ${_googleapis_toolchain_flag}
                   ${_googleapis_triplet_flag}
        BUILD_COMMAND ${CMAKE_COMMAND}
                      --build
                      <BINARY_DIR>
                      ${PARALLEL}
        BUILD_BYPRODUCTS ${googleapis_byproducts}
        LOG_DOWNLOAD ON
        LOG_CONFIGURE OFF
        LOG_BUILD OFF
        LOG_INSTALL OFF)
<commit_msg>Set CMAKE_SKIP_INSTALL_RPATH for bigtable_protos (#2289)<commit_after># ~~~
# 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.
# ~~~

include(ExternalProjectHelper)
find_package(Threads REQUIRED)

if (NOT TARGET grpc_project)
    add_custom_target(grpc_project)
endif ()

if (NOT TARGET googleapis_project)
    # Give application developers a hook to configure the version and hash
    # downloaded from GitHub.
    set(
        GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL
        "https://github.com/googleapis/googleapis/archive/6a3277c0656219174ff7c345f31fb20a90b30b97.tar.gz"
        )
    set(GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256
        "793f1fe9d3adf28900792b4151b7cb2fa4ef14ae1e14ea4e7faa2be14be7a301")

    if ("${CMAKE_GENERATOR}" STREQUAL "Unix Makefiles"
        OR "${CMAKE_GENERATOR}" STREQUAL "Ninja")
        include(ProcessorCount)
        processorcount(NCPU)
        set(PARALLEL "--" "-j" "${NCPU}")
    else()
        set(PARALLEL "")
    endif ()

    # When passing a semi-colon delimited list to ExternalProject_Add, we need
    # to escape the semi-colon. Quoting does not work and escaping the semi-
    # colon does not seem to work (see https://reviews.llvm.org/D40257). A
    # workaround is to use LIST_SEPARATOR to change the delimiter, which will
    # then be replaced by an escaped semi-colon by CMake. This allows us to use
    # multiple directories for our RPATH. Normally, it'd make sense to use : as
    # a delimiter since it is a typical path-list separator, but it is a special
    # character in CMake.
    set(GOOGLE_CLOUD_CPP_INSTALL_RPATH "<INSTALL_DIR>/lib;<INSTALL_DIR>/lib64")
    string(REPLACE ";"
                   "|"
                   GOOGLE_CLOUD_CPP_INSTALL_RPATH
                   "${GOOGLE_CLOUD_CPP_INSTALL_RPATH}")

    create_external_project_library_byproduct_list(
        googleapis_byproducts "googleapis_cpp_bigtable_protos")

    set(_googleapis_toolchain_flag "")
    if (NOT "${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
        set(_googleapis_toolchain_flag
            "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
    endif ()
    set(_googleapis_triplet_flag "")
    if (NOT "${VCPKG_TARGET_TRIPLET}" STREQUAL "")
        set(_googleapis_triplet_flag
            "-DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}")
    endif ()

    include(ExternalProject)
    externalproject_add(
        googleapis_project
        DEPENDS grpc_project
        EXCLUDE_FROM_ALL ON
        PREFIX "${CMAKE_BINARY_DIR}/external/googleapis"
        INSTALL_DIR "${CMAKE_BINARY_DIR}/external"
        URL ${GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL}
        URL_HASH SHA256=${GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256}
        LIST_SEPARATOR
        |
        PATCH_COMMAND
        ${CMAKE_COMMAND}
        -E
        copy
        ${PROJECT_SOURCE_DIR}/cmake/external/googleapis/CMakeLists.txt
        <SOURCE_DIR>/CMakeLists.txt
        COMMAND
            ${CMAKE_COMMAND} -E copy
            ${PROJECT_SOURCE_DIR}/cmake/CompileProtos.cmake
            ${PROJECT_SOURCE_DIR}/cmake/PkgConfigHelper.cmake
            ${PROJECT_SOURCE_DIR}/cmake/FindgRPC.cmake
            ${PROJECT_SOURCE_DIR}/cmake/FindProtobufTargets.cmake
            ${PROJECT_SOURCE_DIR}/cmake/SelectMSVCRuntime.cmake
            ${PROJECT_SOURCE_DIR}/google/cloud/config.pc.in
            ${PROJECT_SOURCE_DIR}/cmake/external/googleapis/config.cmake.in
            ${PROJECT_SOURCE_DIR}/cmake/external/googleapis/config-version.cmake.in
            <SOURCE_DIR>
        CMAKE_ARGS ${GOOGLE_CLOUD_CPP_EXTERNAL_PROJECT_CCACHE}
                   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
                   -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
                   -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
                   -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
                   -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
                   -DCMAKE_INSTALL_RPATH=${GOOGLE_CLOUD_CPP_INSTALL_RPATH}
                   -DCMAKE_SKIP_INSTALL_RPATH=ON
                   -DgRPC_DEBUG=ON
                   -Dprotobuf_DEBUG=ON
                   -DGOOGLE_CLOUD_CPP_USE_LIBCXX=${GOOGLE_CLOUD_CPP_USE_LIBCXX}
                   ${_googleapis_toolchain_flag}
                   ${_googleapis_triplet_flag}
        BUILD_COMMAND ${CMAKE_COMMAND}
                      --build
                      <BINARY_DIR>
                      ${PARALLEL}
        BUILD_BYPRODUCTS ${googleapis_byproducts}
        LOG_DOWNLOAD ON
        LOG_CONFIGURE OFF
        LOG_BUILD OFF
        LOG_INSTALL OFF)

{'fraction_non_alphanumeric': 0.08028681074530399, 'fraction_numerical': 0.018178145829125428, 'mean_word_length': 2.7117691154422787, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4715450', 'n_tokens_mistral': 3372, 'n_tokens_neox': 3074, 'n_words': 613}