From 2323b6c76362e605c94cf2331f683c80db9e3a60 Mon Sep 17 00:00:00 2001 From: topazus Date: Mon, 23 Oct 2023 20:52:30 +0800 Subject: [PATCH 1/2] Upgrade Catch2 to v3 --- CMakeLists.txt | 3 ++- cmake/ThirdParties.cmake | 2 +- scripts/install-deps.ps1 | 6 +++--- scripts/install-deps.sh | 6 +++--- src/libunicode/CMakeLists.txt | 2 +- src/libunicode/capi_test.cpp | 2 +- src/libunicode/convert_test.cpp | 2 +- src/libunicode/emoji_segmenter_test.cpp | 2 +- src/libunicode/grapheme_segmenter_test.cpp | 2 +- src/libunicode/run_segmenter_test.cpp | 2 +- src/libunicode/scan_test.cpp | 2 +- src/libunicode/script_segmenter_test.cpp | 2 +- src/libunicode/test_main.cpp | 2 +- src/libunicode/utf8_grapheme_segmenter_test.cpp | 2 +- src/libunicode/utf8_test.cpp | 2 +- src/libunicode/width_test.cpp | 2 +- src/libunicode/word_segmenter_test.cpp | 2 +- 17 files changed, 22 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6355d82..0859571 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,6 @@ endif() include(EnableCcache) include(ClangTidy) include(PedanticCompiler) -include(ThirdParties) set(CMAKE_EXPORT_COMPILE_COMMANDS ${MASTER_PROJECT}) option(LIBUNICODE_COVERAGE "libunicode: Builds with codecov [default: OFF]" OFF) @@ -45,6 +44,8 @@ option(LIBUNICODE_TESTING "libunicode: Enables building of unittests for libunic option(LIBUNICODE_TOOLS "libunicode: Builds CLI tools [default: ${MASTER_PROJECT}]" ${MASTER_PROJECT}) option(LIBUNICODE_BUILD_STATIC "libunicode: provide static library instead of dynamic [default: ${LIBUNICODE_BUILD_STATIC_DEFAULT}]" ${LIBUNICODE_BUILD_STATIC_DEFAULT}) +include(ThirdParties) + if(LIBUNICODE_TESTING) enable_testing() endif() diff --git a/cmake/ThirdParties.cmake b/cmake/ThirdParties.cmake index 2988052..96cb921 100644 --- a/cmake/ThirdParties.cmake +++ b/cmake/ThirdParties.cmake @@ -36,7 +36,7 @@ endmacro() # via find_package, usually system installed packages. if(LIBUNICODE_TESTING) - if (TARGET Catch2::Catch2) + if(TARGET Catch2::Catch2WithMain) set(THIRDPARTY_BUILTIN_Catch2 "embedded") else() find_package(Catch2 REQUIRED) diff --git a/scripts/install-deps.ps1 b/scripts/install-deps.ps1 index 9f9bfc7..9a37944 100755 --- a/scripts/install-deps.ps1 +++ b/scripts/install-deps.ps1 @@ -14,9 +14,9 @@ class ThirdParty $ThirdParties = @( [ThirdParty]@{ - Folder="Catch2-2.13.7"; - Archive="Catch2-2.13.7.zip"; - URI="https://github.com/catchorg/Catch2/archive/refs/tags/v2.13.7.zip" + Folder="Catch2-3.4.0"; + Archive="Catch2-3.4.0.zip"; + URI="https://github.com/catchorg/Catch2/archive/refs/tags/v3.4.0.zip" }; ) diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index 1103f3c..3432296 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -65,9 +65,9 @@ fetch_and_unpack() fetch_and_unpack_Catch2() { fetch_and_unpack \ - Catch2-2.13.7 \ - Catch2-2.13.7.tar.gz \ - https://github.com/catchorg/Catch2/archive/refs/tags/v2.13.7.tar.gz + Catch2-3.4.0 \ + Catch2-3.4.0.tar.gz \ + https://github.com/catchorg/Catch2/archive/refs/tags/v3.4.0.tar.gz } fetch_and_unpack_fmtlib() diff --git a/src/libunicode/CMakeLists.txt b/src/libunicode/CMakeLists.txt index 9ad4f88..c22b97d 100644 --- a/src/libunicode/CMakeLists.txt +++ b/src/libunicode/CMakeLists.txt @@ -197,7 +197,7 @@ if(LIBUNICODE_TESTING) width_test.cpp word_segmenter_test.cpp ) - target_link_libraries(unicode_test unicode Catch2::Catch2 fmt::fmt-header-only) + target_link_libraries(unicode_test PRIVATE unicode Catch2::Catch2WithMain fmt::fmt-header-only) add_test(unicode_test unicode_test) endif() # }}} diff --git a/src/libunicode/capi_test.cpp b/src/libunicode/capi_test.cpp index 742e2cf..5722fb5 100644 --- a/src/libunicode/capi_test.cpp +++ b/src/libunicode/capi_test.cpp @@ -15,7 +15,7 @@ #include -#include +#include #include #include diff --git a/src/libunicode/convert_test.cpp b/src/libunicode/convert_test.cpp index 64c2984..616681c 100644 --- a/src/libunicode/convert_test.cpp +++ b/src/libunicode/convert_test.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include diff --git a/src/libunicode/emoji_segmenter_test.cpp b/src/libunicode/emoji_segmenter_test.cpp index aacae28..a1391a8 100644 --- a/src/libunicode/emoji_segmenter_test.cpp +++ b/src/libunicode/emoji_segmenter_test.cpp @@ -18,7 +18,7 @@ #include -#include +#include using namespace unicode; using namespace std::string_literals; diff --git a/src/libunicode/grapheme_segmenter_test.cpp b/src/libunicode/grapheme_segmenter_test.cpp index 85a8bfb..2b0efe9 100644 --- a/src/libunicode/grapheme_segmenter_test.cpp +++ b/src/libunicode/grapheme_segmenter_test.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include using namespace unicode; using namespace std::string_literals; diff --git a/src/libunicode/run_segmenter_test.cpp b/src/libunicode/run_segmenter_test.cpp index 91caa54..9e8b6aa 100644 --- a/src/libunicode/run_segmenter_test.cpp +++ b/src/libunicode/run_segmenter_test.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include diff --git a/src/libunicode/scan_test.cpp b/src/libunicode/scan_test.cpp index a62dceb..df40ff6 100644 --- a/src/libunicode/scan_test.cpp +++ b/src/libunicode/scan_test.cpp @@ -17,7 +17,7 @@ #include -#include +#include #include diff --git a/src/libunicode/script_segmenter_test.cpp b/src/libunicode/script_segmenter_test.cpp index ddd3705..b331055 100644 --- a/src/libunicode/script_segmenter_test.cpp +++ b/src/libunicode/script_segmenter_test.cpp @@ -13,7 +13,7 @@ */ #include -#include +#include #include #include diff --git a/src/libunicode/test_main.cpp b/src/libunicode/test_main.cpp index 1e50483..7876576 100644 --- a/src/libunicode/test_main.cpp +++ b/src/libunicode/test_main.cpp @@ -12,7 +12,7 @@ * limitations under the License. */ #define CATCH_CONFIG_RUNNER -#include +#include int main(int argc, char const* argv[]) { diff --git a/src/libunicode/utf8_grapheme_segmenter_test.cpp b/src/libunicode/utf8_grapheme_segmenter_test.cpp index 65344cf..f4b220f 100644 --- a/src/libunicode/utf8_grapheme_segmenter_test.cpp +++ b/src/libunicode/utf8_grapheme_segmenter_test.cpp @@ -15,7 +15,7 @@ #include -#include +#include #include diff --git a/src/libunicode/utf8_test.cpp b/src/libunicode/utf8_test.cpp index ec3ff0b..9c04977 100644 --- a/src/libunicode/utf8_test.cpp +++ b/src/libunicode/utf8_test.cpp @@ -16,7 +16,7 @@ #include -#include +#include #include #include diff --git a/src/libunicode/width_test.cpp b/src/libunicode/width_test.cpp index 03aa603..7642ad9 100644 --- a/src/libunicode/width_test.cpp +++ b/src/libunicode/width_test.cpp @@ -13,7 +13,7 @@ */ #include -#include +#include TEST_CASE("random test", "[width]") { diff --git a/src/libunicode/word_segmenter_test.cpp b/src/libunicode/word_segmenter_test.cpp index 91d9ca6..6a03c6a 100644 --- a/src/libunicode/word_segmenter_test.cpp +++ b/src/libunicode/word_segmenter_test.cpp @@ -13,7 +13,7 @@ */ #include -#include +#include using namespace unicode; using namespace std::string_literals; From 6854a01a7f59c7d56ebb5eb7c430f2913c6c8f91 Mon Sep 17 00:00:00 2001 From: topazus Date: Tue, 24 Oct 2023 10:18:25 +0800 Subject: [PATCH 2/2] fix conversion error for Catch2 --- CMakeLists.txt | 2 ++ src/libunicode/CMakeLists.txt | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0859571..c1c39ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,3 +101,5 @@ message(STATUS "Using ccache: ${USING_CCACHE_STRING}") message(STATUS "Using UCD directory: ${LIBUNICODE_UCD_DIR}") message(STATUS "Enable clang-tidy: ${ENABLE_TIDY} (${CMAKE_CXX_CLANG_TIDY})") message(STATUS "------------------------------------------------------------------------------") + +ThirdPartiesSummary2() \ No newline at end of file diff --git a/src/libunicode/CMakeLists.txt b/src/libunicode/CMakeLists.txt index c22b97d..98d598c 100644 --- a/src/libunicode/CMakeLists.txt +++ b/src/libunicode/CMakeLists.txt @@ -197,7 +197,16 @@ if(LIBUNICODE_TESTING) width_test.cpp word_segmenter_test.cpp ) - target_link_libraries(unicode_test PRIVATE unicode Catch2::Catch2WithMain fmt::fmt-header-only) + + # supress conversion warnings for Catch2 + # https://github.com/catchorg/Catch2/issues/2583 + # https://github.com/SFML/SFML/blob/e45628e2ebc5843baa3739781276fa85a54d4653/test/CMakeLists.txt#L18-L22 + set_target_properties(Catch2 PROPERTIES COMPILE_OPTIONS "" EXPORT_COMPILE_COMMANDS OFF) + set_target_properties(Catch2WithMain PROPERTIES EXPORT_COMPILE_COMMANDS OFF) + get_target_property(CATCH2_INCLUDE_DIRS Catch2 INTERFACE_INCLUDE_DIRECTORIES) + target_include_directories(Catch2 SYSTEM INTERFACE ${CATCH2_INCLUDE_DIRS}) + + target_link_libraries(unicode_test unicode Catch2::Catch2WithMain fmt::fmt-header-only) add_test(unicode_test unicode_test) endif() # }}}