diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 299dece..a3a28be 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -23,8 +23,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 # other submodules are: - # - vcpkg which is already installed at the virtual environment - # - llvm-project which is too heavy, use binary release for generator instead + # vcpkg - already installed at the virtual environment + # generator/llvm-project - too heavy, download and use generator binary - run: git submodule update --init library/RE-flex # - name: Get version @@ -36,7 +36,6 @@ jobs: run: > cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} - -DDISABLE_GENERATOR=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake - name: Install generator diff --git a/CMakeLists.txt b/CMakeLists.txt index 8459e06..76bca53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.10) cmake_policy(SET CMP0091 NEW) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +# Get version from vcpkg.json manifest find_program(PYTHON "python3") if(NOT PYTHON) find_program(PYTHON "python") @@ -21,6 +22,22 @@ if(VCPKG_VERSION_ERROR) message(WARNING ${VCPKG_VERSION_ERROR}) endif() +# Enable vcpkg features +option(ENABLE_TESTS "Enable tests" ON) +option(ENABLE_GENERATOR "Enable generator" OFF) +option(ENABLE_BENCHMARKS "Enable benchmarks" OFF) + +if(ENABLE_TESTS) + list(APPEND VCPKG_MANIFEST_FEATURES "tests") +endif() +if(ENABLE_GENERATOR) + list(APPEND VCPKG_MANIFEST_FEATURES "generator") +endif() +if(ENABLE_BENCHMARKS) + list(APPEND VCPKG_MANIFEST_FEATURES "benchmarks") +endif() + +# Setup project cmake_policy(SET CMP0048 NEW) project(easy_reflection VERSION ${VCPKG_MANIFEST_PROJECT_VERSION}) @@ -31,11 +48,14 @@ include(Dart) enable_testing() add_subdirectory(library) +add_subdirectory(example) -if(NOT DISABLE_GENERATOR) +if(ENABLE_TESTS) + add_subdirectory(tests) +endif() +if(ENABLE_GENERATOR) add_subdirectory(generator) endif() - -add_subdirectory(example) -add_subdirectory(tests) -add_subdirectory(benchmarks) +if(ENABLE_BENCHMARKS) + add_subdirectory(benchmarks) +endif() diff --git a/vcpkg.json b/vcpkg.json index 400addd..be14a29 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,13 +1,36 @@ { "name": "reflection-cpp", "version": "2.9.0", - "dependencies": [ - "simdjson", - "gtest", - "inja", - "tclap", - "benchmark", - "rapidjson", - "yaml-cpp" - ] + "default-features": [ + "library" + ], + "features": { + "library": { + "description": "Reflection library", + "dependencies": [ + "simdjson" + ] + }, + "generator": { + "description": "Code generation tool", + "dependencies": [ + "inja", + "tclap" + ] + }, + "tests": { + "description": "Generate reflection code and test it", + "dependencies": [ + "gtest" + ] + }, + "benchmarks": { + "description": "Set of benchmarks", + "dependencies": [ + "benchmark", + "rapidjson", + "yaml-cpp" + ] + } + } }