Skip to content

Commit bf1c9be

Browse files
Made sure that Github Actions also work for MSVC (#88)
1 parent 8a858d2 commit bf1c9be

File tree

6 files changed

+39
-33
lines changed

6 files changed

+39
-33
lines changed

.github/workflows/test.yaml

+22-18
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,25 @@ jobs:
6666
./build/tests/xml/reflect-cpp-xml-tests
6767
./build/tests/yaml/reflect-cpp-yaml-tests
6868
69-
70-
# The latest MSVC version on GitHub Actions has a bug, and it's difficult to switch to another version.
71-
# Re-enable this when the bug is fixed.
72-
73-
# windows-msvc:
74-
# runs-on: windows-latest
75-
# steps:
76-
# - uses: actions/checkout@v3
77-
# with:
78-
# submodules: true
79-
# - uses: ilammy/msvc-dev-cmd@v1
80-
# - uses: lukka/run-vcpkg@v11
81-
# - name: Run test
82-
# run: |
83-
# cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_FLEXBUFFERS=ON
84-
# cmake --build build -j 4
85-
# .\build\tests\flexbuffers\Release\reflect-cpp-flexbuffers-tests.exe
86-
# .\build\tests\json\Release\reflect-cpp-json-tests.exe
69+
windows-msvc:
70+
runs-on: windows-latest
71+
steps:
72+
- name: Checkout
73+
uses: actions/checkout@v3
74+
with:
75+
submodules: recursive
76+
fetch-depth: 0
77+
- uses: ilammy/msvc-dev-cmd@v1
78+
- uses: lukka/run-vcpkg@v11
79+
- name: Run test
80+
run: |
81+
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
82+
cmake --build build --config Release -j4
83+
.\build\tests\json\Release\reflect-cpp-json-tests.exe
84+
.\build\tests\bson\Release\reflect-cpp-bson-tests.exe
85+
.\build\tests\cbor\Release\reflect-cpp-cbor-tests.exe
86+
.\build\tests\flexbuffers\Release\reflect-cpp-flexbuffers-tests.exe
87+
.\build\tests\msgpack\Release\reflect-cpp-msgpack-tests.exe
88+
.\build\tests\toml\Release\reflect-cpp-toml-tests.exe
89+
.\build\tests\xml\Release\reflect-cpp-xml-tests.exe
90+
.\build\tests\yaml\Release\reflect-cpp-yaml-tests.exe

CMakeLists.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ if (REFLECTCPP_FLEXBUFFERS)
5656
endif ()
5757

5858
if (REFLECTCPP_MSGPACK)
59-
message(${VCPKG_INSTALLED_DIR})
6059
find_package(msgpack-c CONFIG REQUIRED)
6160
if (MSVC)
6261
target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/msgpack-c${CMAKE_STATIC_LIBRARY_SUFFIX}")
@@ -66,9 +65,11 @@ if (REFLECTCPP_MSGPACK)
6665
endif ()
6766

6867
if (REFLECTCPP_TOML)
69-
find_package(PkgConfig REQUIRED)
70-
pkg_check_modules(tomlplusplus REQUIRED IMPORTED_TARGET tomlplusplus)
71-
target_link_libraries(reflectcpp INTERFACE PkgConfig::tomlplusplus)
68+
if (MSVC)
69+
target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/tomlplusplus${CMAKE_STATIC_LIBRARY_SUFFIX}")
70+
else ()
71+
target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libtomlplusplus${CMAKE_STATIC_LIBRARY_SUFFIX}")
72+
endif ()
7273
endif()
7374

7475
if (REFLECTCPP_XML)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ To run the tests, do the following:
570570
./build/tests/flexbuffers/reflect-cpp-flexbuffers-tests
571571
./build/tests/msgpack/reflect-cpp-msgpack-tests
572572
./build/tests/json/reflect-cpp-json-tests
573-
./build/tests/xml/reflect-cpp-toml-tests
573+
./build/tests/toml/reflect-cpp-toml-tests
574574
./build/tests/xml/reflect-cpp-xml-tests
575-
./build/tests/xml/reflect-cpp-yaml-tests
575+
./build/tests/yaml/reflect-cpp-yaml-tests
576576
```
577577

578578
## How to contribute

include/rfl/internal/get_field_names.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ consteval auto get_field_name_str_view() {
5252
#endif
5353
#if defined(__clang__)
5454
const auto split = func_name.substr(0, func_name.size() - 2);
55-
return split.substr(split.find_last_of(":.") + 1);
55+
return split.substr(split.find_last_of(":.") + 1);
5656
#elif defined(__GNUC__)
5757
const auto split = func_name.substr(0, func_name.size() - 2);
5858
return split.substr(split.find_last_of(":") + 1);
5959
#elif defined(_MSC_VER)
6060
const auto split = func_name.substr(0, func_name.size() - 7);
61-
return split.substr(split.find("value->") + 7);
61+
return split.substr(split.rfind("->") + 2);
6262
#else
6363
static_assert(false,
6464
"You are using an unsupported compiler. Please use GCC, Clang "

tests/json/test_inheritance.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <iostream>
33
#include <rfl.hpp>
44
#include <source_location>
5+
#include <tuple>
56

67
namespace test_inheritance {
78

@@ -14,13 +15,12 @@ void test() {
1415

1516
struct T : S {};
1617

17-
const auto name = get<0>(rfl::fields<T>()).name();
18-
if (name == "x") {
19-
std::cout << "OK" << std::endl << std::endl;
20-
} else {
21-
std::cout << "FAIL\n"
22-
<< "Expected member name 'x', got '" << name << "'" << std::endl;
23-
}
18+
constexpr auto name =
19+
std::tuple_element_t<0, typename rfl::named_tuple_t<T>::Fields>::name();
20+
21+
static_assert(name == "x");
22+
23+
std::cout << "OK" << std::endl << std::endl;
2424
}
2525

2626
} // namespace test_inheritance

tests/toml/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ file(GLOB_RECURSE SOURCES "*.cpp")
44

55
add_executable(reflect-cpp-toml-tests ${SOURCES})
66

7+
target_include_directories(reflect-cpp-toml-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
78
target_link_libraries(reflect-cpp-toml-tests PRIVATE reflectcpp)
89

0 commit comments

Comments
 (0)