#
# Copyright 2017 The Abseil Authors.
#
# 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.
#
absl_cc_library(
  NAME
    any
  HDRS
    "any.h"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::bad_any_cast
    absl::config
    absl::core_headers
    absl::type_traits
    absl::utility
  PUBLIC
)

absl_cc_library(
  NAME
    bad_any_cast
  HDRS
   "bad_any_cast.h"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::bad_any_cast_impl
    absl::config
  PUBLIC
)

absl_cc_library(
  NAME
    bad_any_cast_impl
  SRCS
   "bad_any_cast.h"
   "bad_any_cast.cc"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::config
    absl::raw_logging_internal
)

absl_cc_test(
  NAME
    any_test
  SRCS
    "any_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::any
    absl::config
    absl::exception_testing
    absl::raw_logging_internal
    absl::test_instance_tracker
    gmock_main
)

absl_cc_test(
  NAME
    any_test_noexceptions
  SRCS
    "any_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::any
    absl::config
    absl::exception_testing
    absl::raw_logging_internal
    absl::test_instance_tracker
    gmock_main
)

absl_cc_test(
  NAME
    any_exception_safety_test
  SRCS
    "any_exception_safety_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::any
    absl::config
    absl::exception_safety_testing
    gmock_main
)

absl_cc_library(
  NAME
    span
  HDRS
    "span.h"
  SRCS
    "internal/span.h"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::algorithm
    absl::core_headers
    absl::throw_delegate
    absl::type_traits
  PUBLIC
)

absl_cc_test(
  NAME
    span_test
  SRCS
    "span_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::span
    absl::base
    absl::config
    absl::core_headers
    absl::exception_testing
    absl::fixed_array
    absl::inlined_vector
    absl::hash_testing
    absl::strings
    gmock_main
)

absl_cc_test(
  NAME
    span_test_noexceptions
  SRCS
    "span_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::span
    absl::base
    absl::config
    absl::core_headers
    absl::exception_testing
    absl::fixed_array
    absl::inlined_vector
    absl::hash_testing
    absl::strings
    gmock_main
)

absl_cc_library(
  NAME
    optional
  HDRS
    "optional.h"
  SRCS
    "internal/optional.h"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::bad_optional_access
    absl::base_internal
    absl::config
    absl::core_headers
    absl::memory
    absl::type_traits
    absl::utility
  PUBLIC
)

absl_cc_library(
  NAME
    bad_optional_access
  HDRS
    "bad_optional_access.h"
  SRCS
    "bad_optional_access.cc"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::config
    absl::raw_logging_internal
  PUBLIC
)

absl_cc_library(
  NAME
    bad_variant_access
  HDRS
    "bad_variant_access.h"
  SRCS
    "bad_variant_access.cc"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::config
    absl::raw_logging_internal
  PUBLIC
)

absl_cc_test(
  NAME
    optional_test
  SRCS
    "optional_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::optional
    absl::config
    absl::raw_logging_internal
    absl::strings
    absl::type_traits
    gmock_main
)

absl_cc_test(
  NAME
    optional_exception_safety_test
  SRCS
    "optional_exception_safety_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::optional
    absl::config
    absl::exception_safety_testing
    gmock_main
)

absl_cc_library(
  NAME
    conformance_testing
  HDRS
    "internal/conformance_aliases.h"
    "internal/conformance_archetype.h"
    "internal/conformance_profile.h"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::debugging
    absl::type_traits
    absl::strings
    absl::utility
    gmock_main
  PUBLIC
)

absl_cc_test(
  NAME
    conformance_testing_test
  SRCS
    "internal/conformance_testing_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
    ${ABSL_EXCEPTIONS_FLAG}
  LINKOPTS
    ${ABSL_EXCEPTIONS_FLAG_LINKOPTS}
  DEPS
    absl::conformance_testing
    absl::type_traits
    gmock_main
)

absl_cc_test(
  NAME
    conformance_testing_test_no_exceptions
  SRCS
    "internal/conformance_testing_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::conformance_testing
    gmock_main
)

absl_cc_library(
  NAME
    variant
  HDRS
    "variant.h"
  SRCS
    "internal/variant.h"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::bad_variant_access
    absl::base_internal
    absl::config
    absl::core_headers
    absl::type_traits
    absl::utility
  PUBLIC
)

absl_cc_test(
  NAME
    variant_test
  SRCS
    "variant_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::variant
    absl::config
    absl::core_headers
    absl::memory
    absl::type_traits
    absl::strings
    gmock_main
)

absl_cc_library(
  NAME
    compare
  HDRS
    "compare.h"
  COPTS
    ${ABSL_DEFAULT_COPTS}
  DEPS
    absl::core_headers
    absl::type_traits
  PUBLIC
)

absl_cc_test(
  NAME
    compare_test
  SRCS
    "compare_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::base
    absl::compare
    gmock_main
)

# TODO(cohenjon,zhangxy) Figure out why this test is failing on gcc 4.8
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
else()
absl_cc_test(
  NAME
    variant_exception_safety_test
  SRCS
    "variant_exception_safety_test.cc"
  COPTS
    ${ABSL_TEST_COPTS}
  DEPS
    absl::variant
    absl::config
    absl::exception_safety_testing
    absl::memory
    gmock_main
)
endif()
