#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you 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.
#

# NOTE: The examples and their build files are self-contained, and installed
# stand-alone independent of the library build tree. They must build and work in
# this mode.
#
# For self-test purposes, the library and binding CMake files can provide extra
# settings in <LANGUAGE>_EXAMPLE_* variables - for example to enable extra error
# checking or ensure compiler consistency with the library build. However, the
# examples must also build correctly stand-alone, with none of those variables set.

set (Proton_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set (ProtonCpp_DIR ${CMAKE_CURRENT_SOURCE_DIR})

# Add the tools directory for the 'proctest' module
set_search_path(EXAMPLE_PYTHONPATH "${CMAKE_SOURCE_DIR}/tools/py" "$ENV{PYTHON_PATH}")
set(EXAMPLE_ENV "PYTHONPATH=${EXAMPLE_PYTHONPATH}")

add_subdirectory(c)
add_subdirectory(go)
if (BUILD_CPP)
  add_subdirectory(cpp)
endif()

install(DIRECTORY c cpp go
        DESTINATION ${PROTON_SHARE}/examples)

install(DIRECTORY python
        DESTINATION ${PROTON_SHARE}/examples
        PATTERN "*.py"
        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
                    GROUP_EXECUTE GROUP_READ
                    WORLD_EXECUTE WORLD_READ)

install(DIRECTORY ruby
        DESTINATION ${PROTON_SHARE}/examples
        PATTERN "*.rb"
        PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
                    GROUP_EXECUTE GROUP_READ
                    WORLD_EXECUTE WORLD_READ)
