# C++ configuration options

# Copyright (c) 2018 B. Leforestier
# SPDX-License-Identifier: Apache-2.0

menu "C++ Language Support"

config CPP
	bool "C++ support for the application"
	help
	  This option enables the use of applications built with C++.

if CPP

config STD_CPP_VERSION
	int
	default 199711 if STD_CPP98
	default 201103 if STD_CPP11
	default 201402 if STD_CPP14
	default 201703 if STD_CPP17
	default 202002 if STD_CPP20 || STD_CPP2A || STD_CPP2B
	help
	  The version number of C++ standard being used (NOTE: this uses the
	  full year and month, and is the same as the __cplusplus macro defined
	  by the compiler). This config can be used to check for a minimum
	  supported version. Example:

	    depends on STD_CPP_VERSION >= 201703

	  Adding this to your library's enablement Kconfig will force a minimum
	  c++17 standard.

	  The full year is used so c++98 can be checked using > and < operators
	  without conflicting with c++11 or higher.

choice STD_CPP
	prompt "C++ Standard"
	default STD_CPP11
	help
	  C++ Standards.

config STD_CPP98
	bool "C++ 98"
	help
	  1998 C++ standard as modified by the 2003 technical corrigendum
	  and some later defect reports.

config STD_CPP11
	bool "C++ 11"
	help
	  2011 C++ standard, previously known as C++0x.

config STD_CPP14
	bool "C++ 14"
	help
	  2014 C++ standard.

config STD_CPP17
	bool "C++ 17"
	help
	  2017 C++ standard, previously known as C++0x.

config STD_CPP2A
	bool "C++ 2a"
	help
	  Next revision of the C++ standard, which is expected to be published in 2020.

config STD_CPP20
	bool "C++ 20"
	help
	  2020 C++ standard, previously known as C++2A.

config STD_CPP2B
	bool "C++ 2b"
	help
	  Next revision of the C++ standard, which is expected to be published in 2023.

endchoice

config REQUIRES_FULL_LIBCPP
	bool "Require complete C++ standard library"
	select REQUIRES_FULL_LIBC
	help
	  Indicates that a full C++ standard library is required, either by
	  a subsystem or an application. This will also include a full C
	  library implementation.

config FULL_LIBCPP_SUPPORTED
	bool
	help
	  Selected when the target has at least one C++ library that offers a
	  complete implementation and which would be selected when
	  REQUIRES_FULL_LIBCPP is set.

choice LIBCPP_IMPLEMENTATION
	prompt "C++ Standard Library Implementation"
	default EXTERNAL_LIBCPP if REQUIRES_FULL_LIBCPP && NATIVE_BUILD
	default LIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP && "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
	default GLIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP
	default MINIMAL_LIBCPP

config MINIMAL_LIBCPP
	bool "Minimal C++ Library"
	depends on !REQUIRES_FULL_LIBCPP
	help
	  Build with the minimal C++ library provided by Zephyr.

	  The Zephyr minimal C++ library only provides a very limited subset
	  of the standard C++ library and is mainly intended for use with the
	  applications that do not require the Standard Template Library (STL).

config GLIBCXX_LIBCPP
	bool "GNU C++ Standard Library"
	depends on !NATIVE_APPLICATION
	depends on NEWLIB_LIBC || PICOLIBC
	select FULL_LIBCPP_SUPPORTED
	help
	  Build with GNU C++ Standard Library (libstdc++) provided by the GNU
	  Compiler Collection (GCC)-based toolchain.

config LIBCXX_LIBCPP
	bool "LLVM C++ Standard Library"
	depends on !NATIVE_APPLICATION
	depends on NEWLIB_LIBC
	depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
	select FULL_LIBCPP_SUPPORTED
	help
	  Build with LLVM C++ Standard Library (libc++) provided by LLVM
	  toolchain. Information about library can be found at
	  https://libcxx.llvm.org

config ARCMWDT_LIBCPP
	bool "ARC MWDT C++ Library"
	depends on !NATIVE_APPLICATION
	depends on ARCMWDT_LIBC
	help
	  Build with ARC MetaWare C++ Standard Library provided by the ARC
	  MetaWare Development Tools (MWDT) toolchain.

config EXTERNAL_LIBCPP
	bool "External C++ standard library"
	help
	  Build and link with an external/user-provided C++ standard library.

config EXTERNAL_MODULE_LIBCPP
	bool "External C++ standard library module"
	help
	  Build an external/user-provided C++ standard library.

endchoice # LIBCPP_IMPLEMENTATION

if !MINIMAL_LIBCPP

config CPP_EXCEPTIONS
	bool "C++ exceptions support"
	depends on !NEWLIB_LIBC_NANO
	help
	  This option enables support of C++ exceptions.

config CPP_RTTI
	bool "C++ RTTI support"
	help
	  This option enables support of C++ RTTI.

endif # !MINIMAL_LIBCPP

endif # CPP

endmenu