Skip to content

Commit

Permalink
Add vcpkg features
Browse files Browse the repository at this point in the history
  • Loading branch information
chocolacula authored Jul 6, 2023
1 parent c533f79 commit d4ec444
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 17 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
30 changes: 25 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

# Get version from vcpkg.json manifest
find_program(PYTHON "python3")
if(NOT PYTHON)
find_program(PYTHON "python")
Expand All @@ -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})

Expand All @@ -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()
41 changes: 32 additions & 9 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}

0 comments on commit d4ec444

Please sign in to comment.