diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 089f4177..23c12c47 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -44,7 +44,7 @@ jobs: ./build/tests/json/reflect-cpp-json-tests windows-msvc: - runs-on: windows-latest + runs-on: windows-2019 # not using windows-latest because its MSVC has a bug which prevents it from building reflect-cpp steps: - uses: actions/checkout@v3 with: @@ -53,11 +53,11 @@ jobs: uses: lukka/run-vcpkg@v11 - uses: ilammy/msvc-dev-cmd@v1 with: - vsversion: '2022' + toolset: 14 - name: Run test run: | cl cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_JSON=ON -DREFLECTCPP_FLATBUFFERS=ON - cmake --build build --config Release + cmake --build build -j 4 .\build\tests\flatbuffers\Release\reflect-cpp-flatbuffers-tests.exe .\build\tests\json\Release\reflect-cpp-json-tests.exe \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index ee28bb1e..bd803963 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,21 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/ project(reflectcpp) +option(REFLECTCPP_ENABLE_ALL "Enable all features" OFF) option(REFLECTCPP_JSON "Enable JSON support" OFF) option(REFLECTCPP_FLATBUFFERS "Enable FlatBuffers support" OFF) +option(REFLECTCPP_BUILD_TESTS "Build tests" OFF) + +if (REFLECTCPP_BUILD_TESTS) + set(REFLECTCPP_ENABLE_ALL ON) +endif () + +if (REFLECTCPP_ENABLE_ALL) + set(REFLECTCPP_JSON ON) + set(REFLECTCPP_FLATBUFFERS ON) +endif () + add_library(reflectcpp INTERFACE) target_include_directories(reflectcpp INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -24,9 +36,6 @@ endif () set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2") - -option(REFLECTCPP_BUILD_TESTS "Build tests" OFF) - if (REFLECTCPP_BUILD_TESTS) add_subdirectory(tests) endif () \ No newline at end of file diff --git a/README.md b/README.md index 63d7ad5a..f3ec6897 100644 --- a/README.md +++ b/README.md @@ -373,12 +373,15 @@ git submodule update --init ./vcpkg/bootstrap-vcpkg.bat # Windows ``` -Build: +Use in your project: -```bash -cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DREFLECTCPP_JSON=ON -DREFLECTCPP_FLATBUFFERS=ON -cmake --build build -j 4 # Linux -cmake --build build --config Release # Windows +```cmake +add_subdirectory(reflect-cpp) # Add this project as a subdirectory + +set(REFLECTCPP_JSON ON) # Optional +set(REFLECTCPP_FLATBUFFERS ON) # Optional + +target_link_libraries(your_project PRIVATE reflectcpp) # Link against the library ``` ## Compiling the tests @@ -386,9 +389,8 @@ cmake --build build --config Release # Windows To compile the tests, do the following: ``` -cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_JSON=ON -DREFLECTCPP_FLATBUFFERS=ON -cmake --build build -j 4 # Linux -cmake --build build --config Release # Windows +cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON +cmake --build build -j 4 ``` diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 47715140..035129f2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,10 +7,5 @@ else() endif() -if (REFLECTCPP_JSON) - add_subdirectory(json) -endif () - -if (REFLECTCPP_FLATBUFFERS) - add_subdirectory(flatbuffers) -endif () \ No newline at end of file +add_subdirectory(json) +add_subdirectory(flatbuffers) \ No newline at end of file