From 5c01ca3a36a1e41918f87d8b52e3a138c3ed9644 Mon Sep 17 00:00:00 2001 From: injae <8687lee@gmail.com> Date: Sun, 7 Jan 2024 19:05:50 +0900 Subject: [PATCH] fix CMakeLists.txt (unit test, benchmark) --- CMakeLists.txt | 59 ++++++++++++++++++++++++++++-- cppm.toml | 2 +- thirdparty/Catch2/3.5.0/cppkg.toml | 2 +- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a536623..5ff9d1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ cppm_compiler_option( CLANG "-fprofile-instr-generate -fcoverage-mapping --coverage" ) -find_cppkg(Catch2 3.5.0 MODULE Catch2::Catch2 TYPE lib OPTIONAL OFF) +find_cppkg(Catch2 3.5.0 MODULE Catch2::Catch2WithMain TYPE lib OPTIONAL OFF) find_cppkg(RapidJSON 1.1.1 MODULE rapidjson TYPE lib OPTIONAL OFF) find_cppkg(benchmark 1.5.2 MODULE benchmark::benchmark TYPE lib OPTIONAL OFF) find_cppkg(fmt 10.2.0 MODULE fmt::fmt-header-only TYPE lib OPTIONAL OFF) @@ -88,8 +88,46 @@ SOURCES endif() +cppm_unit_test_area() +if(SERDEPP_BUILD_TESTING) + +cppm_target_define(unittest BINARY +SOURCES + tests/serializer.cpp + tests/rapid_json.cpp + tests/yaml_cpp.cpp + tests/toml11.cpp + tests/reflection.cpp + tests/nlohmann_json.cpp + tests/test_struct.hpp +) + +endif() +end_cppm_unit_test_area() + +if(SERDEPP_BUILD_BENCHMARKS) + +cppm_target_define(benchmark BINARY +SOURCES + benchmark/benchmark.cpp +) + +cppm_target_define(data_type_benchmark BINARY +SOURCES + benchmark/data_type_benchmark.cpp +) + +cppm_target_define(syntax_sugar_benchmark BINARY +SOURCES + benchmark/syntax_benchmark.cpp +) + +endif() + +set(serdepp_global_deps + PRIVATE benchmark Catch2 + PUBLIC RapidJSON nlohmann_json toml11 yaml-cpp fmt magic_enum nameof) -set(serdepp_global_deps PUBLIC Catch2 RapidJSON benchmark fmt magic_enum nameof nlohmann_json toml11 yaml-cpp) cppm_target_dependencies(serdepp ${serdepp_global_deps}) @@ -108,7 +146,6 @@ cppm_target_dependencies(simple_example cppm_target_dependencies(flatten_example ${serdepp_global_deps} serdepp) - cppm_target_dependencies(variant_example ${serdepp_global_deps} serdepp) @@ -137,6 +174,20 @@ cppm_target_dependencies(pointer ${serdepp_global_deps} serdepp) +cppm_target_dependencies(unittest + ${serdepp_global_deps} + serdepp) -cppm_target_install(serdepp) +cppm_target_dependencies(benchmark + ${serdepp_global_deps} + serdepp) +cppm_target_dependencies(data_type_benchmark + ${serdepp_global_deps} + serdepp) + +cppm_target_dependencies(syntax_sugar_benchmark + ${serdepp_global_deps} + serdepp) + +cppm_target_install(serdepp) diff --git a/cppm.toml b/cppm.toml index 736dfcf..745e6a1 100644 --- a/cppm.toml +++ b/cppm.toml @@ -85,7 +85,7 @@ name = "syntax_sugar_benchmark" source = ["benchmark/syntax_benchmark.cpp"] -[[tests]] +[[test]] name = "unittest" source = ["tests/.*"] diff --git a/thirdparty/Catch2/3.5.0/cppkg.toml b/thirdparty/Catch2/3.5.0/cppkg.toml index 31530f9..e59d5aa 100644 --- a/thirdparty/Catch2/3.5.0/cppkg.toml +++ b/thirdparty/Catch2/3.5.0/cppkg.toml @@ -1,6 +1,6 @@ [Catch2] version = "3.5.0" description = "modern, C++-native, header-only, test framework for unit-tests" -module = "Catch2::Catch2" +module = "Catch2::Catch2WithMain" url="https://github.com/catchorg/Catch2/archive/refs/tags/v3.5.0.tar.gz" flags="-DCATCH_BUILD_TESTING=OFF" \ No newline at end of file