# SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
# SPDX-License-Identifier: BSD-2-Clause

set(CPPFLAGS_STD -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 CACHE STRING "C preprocessor flags defining standards compliance")
set(CFLAGS_STD -std=c99 CACHE STRING "C compiler flags specifying the C dialect to use")

set(CFLAGS_WARN_GCC -Wall -W)
set(CFLAGS_WARN_BDE -Wall -W -pedantic -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings)

option(USE_BDE_CFLAGS "Add some use GCC compiler warning flags for stricter checks" OFF)
if(USE_BDE_CFLAGS)
	set(CFLAGS_WARN_DEFAULT ${CFLAGS_WARN_BDE})
else()
	set(CFLAGS_WARN_DEFAULT ${CFLAGS_WARN_GCC})
endif()

option(USE_WERROR "Stop the build if any compiler warnings are emitted" OFF)
if(USE_WERROR)
	set(CFLAGS_WARN_WERROR -Werror)
else()
	set(CFLAGS_WARN_WERROR)
endif()

set(CFLAGS_WARN ${CFLAGS_WARN_DEFAULT} ${CFLAGS_WARN_WERROR} CACHE STRING "C compiler warning flags")

set(CPPFLAGS CACHE STRING "Base C preprocessor flags")
set(CPPFLAGS_FULL $CACHE{CPPFLAGS} $CACHE{CPPFLAGS_STD})

set(CFLAGS -g -pipe CACHE STRING "Base C compiler flags")
set(CFLAGS_FULL $CACHE{CFLAGS} $CACHE{CFLAGS_STD} $CACHE{CFLAGS_WARN})

set(U8_INCLUDEDIR "${CMAKE_CURRENT_SOURCE_DIR}/include")

add_subdirectory(u8loc)
add_subdirectory(utf8_locale)
