diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ea5f66..ad35ffb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,11 @@ cmake_minimum_required(VERSION 3.16) + +# Must come before project() so it can select vcpkg's "tests" feature (pulls in gtest). +option(HYPERLIQUID_BUILD_TESTS "Build tests" OFF) +if(HYPERLIQUID_BUILD_TESTS) + list(APPEND VCPKG_MANIFEST_FEATURES "tests") +endif() + project(hyperliquid-sdk-cpp VERSION 0.1.0 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 23) @@ -148,7 +155,6 @@ install(FILES ) option(HYPERLIQUID_BUILD_EXAMPLES "Build example programs" OFF) -option(HYPERLIQUID_BUILD_TESTS "Build tests" OFF) if(HYPERLIQUID_BUILD_TESTS) enable_testing() diff --git a/README.md b/README.md index f1c03f5..a421f2f 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ int main() { See the [Quickstart guide](https://TuxedoFish.github.io/hyperliquid-sdk-cpp/quickstart/) for the WebSocket equivalent and the async/typed-listener paths, and the [Examples index](https://TuxedoFish.github.io/hyperliquid-sdk-cpp/examples/) for every runnable example in `examples/` (order placement/modification, transfers, staking, vaults, and every websocket channel, over both REST and WebSocket). -Most examples read credentials from `examples/test.json`, a local, gitignored file you create yourself - it's never committed and the repo doesn't ship one. Create it with: +Most examples read credentials from `examples/test.json`, a local, gitignored file you create yourself - it's never committed and the repo doesn't ship one. Copy the template at [`examples/example.json`](examples/example.json) to `examples/test.json` and fill it in, or create it directly: ```json { diff --git a/docs/examples.md b/docs/examples.md index a4756a7..7f6d5af 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -6,7 +6,7 @@ Examples are paired: most `/exchange` or `/info` call in `rest_*.cpp` has a `ws_ ## Credentials -Most examples read credentials from `examples/test.json`, a local file you create yourself — it's gitignored and never committed, and the repo doesn't ship one. +Most examples read credentials from `examples/test.json`, a local file you create yourself — it's gitignored and never committed, and the repo doesn't ship one. Copy the template at [`examples/example.json`](https://github.com/TuxedoFish/hyperliquid-sdk-cpp/blob/main/examples/example.json) to `examples/test.json` and fill it in, or create it directly: ```json { diff --git a/examples/test_config.h b/examples/test_config.h index 72b9649..cbd6aed 100644 --- a/examples/test_config.h +++ b/examples/test_config.h @@ -17,7 +17,12 @@ inline TestConfig loadTestConfig(const std::string& path = EXAMPLES_DIR "test.js { std::ifstream file(path); if (!file.is_open()) - throw std::runtime_error("Could not open config file: " + path); + throw std::runtime_error( + "Could not open config file: " + path + + "\nThis file is gitignored and not shipped with the repo - copy examples/example.json " + "to examples/test.json and fill in a testnet wallet's address/private key (and " + "optionally a subaccount address) before running examples. See the README's " + "\"Quickstart\" section, or https://TuxedoFish.github.io/hyperliquid-sdk-cpp/examples/#credentials."); auto json = nlohmann::json::parse(file); diff --git a/vcpkg.json b/vcpkg.json index 618ec8c..f6cc194 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -13,7 +13,14 @@ "nlohmann-json", "spdlog", "zlib", - "secp256k1", - "gtest" - ] + "secp256k1" + ], + "features": { + "tests": { + "description": "Build the test suite (HYPERLIQUID_BUILD_TESTS)", + "dependencies": [ + "gtest" + ] + } + } }