%undefine __cmake_in_source_build
%global ftest_version 0.3

Name:       utf8cpp
Version:    4.1.1
Release:    1
Summary:    A simple, portable and lightweight library for handling UTF-8 encoded strings
License:    Boost
URL:        https://github.com/nemtrif/utfcpp
Source0:    https://github.com/nemtrif/utfcpp/archive/refs/tags/v%{version}.tar.gz
Source1:    https://github.com/nemtrif/ftest/archive/refs/tags/%{ftest_version}.tar.gz
# put cmake import file in correct directory
Patch0:     %{name}-cmake.patch
BuildRequires: cmake gcc-c++
Buildarch:  noarch

%description
%{summary}.

Features include:
 - iterating through UTF-8 encoded strings
 - converting between UTF-8 and UTF-16/UTF-32
 - detecting invalid UTF-8 sequences

This project currently only contains header files, which can be found in the
%{name}-devel package.

%package    devel
Summary:    Header files for %{name}

%description devel
%{summary}.

Features include:
 - iterating through UTF-8 encoded strings
 - converting between UTF-8 and UTF-16/UTF-32
 - detecting invalid UTF-8 sequences

This project currently only contains header files, which can be found in the
%{name}-devel package.

%prep
%autosetup -n utfcpp-%{version} -a1 -p1

%build
%cmake
%cmake_build

pushd tests
%cmake
%cmake_build
popd

%install
%cmake_install
pushd %{buildroot}%{_includedir}
ln -s utf8cpp/utf8.h ./
mkdir utf8
for f in {{un,}checked,core,cpp{11,17,20}}.h ; do
    ln -s ../utf8cpp/utf8/${f} utf8/
done
popd

%check
pushd tests
%ctest
popd

%files devel
%doc README.md
%license LICENSE
%{_includedir}/utf8.h
%dir %{_includedir}/utf8
%{_includedir}/utf8/checked.h
%{_includedir}/utf8/core.h
%{_includedir}/utf8/cpp11.h
%{_includedir}/utf8/cpp17.h
%{_includedir}/utf8/cpp20.h
%{_includedir}/utf8/unchecked.h
%{_includedir}/utf8cpp
%{_datadir}/cmake/utf8cpp

%changelog
* Sun Jun 07 2026 Funda Wang <fundawang@yeah.net> - 4.1.1-1
- update to 4.1.1

* Fri Apr 03 2026 Funda Wang <fundawang@yeah.net> - 4.0.9-1
- update to 4.0.9

* Sat Oct 11 2025 yaoxin <1024769339@qq.com> - 4.0.8-1
- Update to 4.0.8:
  * Avoid a sign-conversion warning in StaticAssert
  * Fix the name clash with assert macro
  * Compile time checks for size of UTF-16 code units

* Mon Nov 18 2024 Funda Wang <fundawang@yeah.net> - 4.0.6-1
- update to 4.0.6

* Mon Nov 11 2024 Funda Wang <fundawang@yeah.net> - 3.2.5-1
- update to 3.2.5

* Tul Jan 18 2022 liweigang <liweiganga@uniontech.com> - 3.2.1-1
- Init Package