Skip to content

Commit 76b2f17

Browse files
committed
Add tests when char_t is disabled on C++20.
1 parent 8937f18 commit 76b2f17

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.github/workflows/cmake.yml

+5
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,8 @@ jobs:
115115
working-directory: ${{github.workspace}}/build
116116
shell: bash
117117
run: if [ "${{ matrix.os }}" == "windows-latest" ]; then cd ${{ matrix.type }}; fi; ./utf8_test_cpp20
118+
119+
- name: Test c++20 no char_t
120+
working-directory: ${{github.workspace}}/build
121+
shell: bash
122+
run: if [ "${{ matrix.os }}" == "windows-latest" ]; then cd ${{ matrix.type }}; fi; ./utf8_test_cpp20_no_char_t

test/CMakeLists.txt

+19-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#
2424
# For more information, please refer to <http://unlicense.org/>
2525

26-
project(utf8)
2726
cmake_minimum_required(VERSION 2.8.12)
27+
project(utf8)
2828

2929
set(UTF8_USE_SANITIZER "" CACHE STRING "Set which Clang Sanitizer to use")
3030

@@ -95,6 +95,24 @@ add_executable(utf8_test_cpp20 test.cpp)
9595
add_sanitizer(utf8_test_cpp20)
9696
set_target_properties(utf8_test_cpp20 PROPERTIES CXX_STANDARD 20)
9797

98+
add_executable(utf8_test_cpp20_no_char_t test.cpp)
99+
add_sanitizer(utf8_test_cpp20_no_char_t)
100+
set_target_properties(utf8_test_cpp20_no_char_t PROPERTIES CXX_STANDARD 20)
101+
102+
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
103+
target_compile_options(utf8_test_cpp20_no_char_t PUBLIC "-fno-char8_t")
104+
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
105+
if("${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC")
106+
target_compile_options(utf8_test_cpp20_no_char_t PUBLIC "/Zc:char8_t-")
107+
else()
108+
target_compile_options(utf8_test_cpp20_no_char_t PUBLIC "-fno-char8_t")
109+
endif()
110+
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
111+
target_compile_options(utf8_test_cpp20_no_char_t PUBLIC "/Zc:char8_t-")
112+
else()
113+
message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
114+
endif()
115+
98116
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
99117
set_source_files_properties(test.c test.cpp PROPERTIES
100118
COMPILE_FLAGS "-Wall -Wextra -Werror"

0 commit comments

Comments
 (0)