-
Notifications
You must be signed in to change notification settings - Fork 0
Getting started
Welcome to sparq!
We intended sparq to be a vcpkg package and this guide will help you integrate the sparq embedded framework into your application using vcpkg Manifest Mode and CMake paired with CMake Presets
This setup allows IDEs (like VS Code, CLion or Visual Studio) to automatically configure, fetch and compile all dependencies in the background
- CMake (v3.21 or higher for full workflow preset support)
-
vcpkg(Installed and accessible on your system) - created an environment variable
VCPKG_ROOTset to your vcpkg installation path -
git(To access thebase42-vcpkg-registry)
Follow these four steps to connect to our private registry(base42-vcpkg-registry) and add sparq to your project
- Configure the registry
Create a file named vcpkg-configuration.json in your aplication's root directory. This tells vcpkg to fetch the sparq package from base42-vcpkg-registry instead of the public index
{
"registries": [
{
"kind": "git",
"repository": "https://github.com/42dotmk/base42-vcpkg-registry",
"baseline": "get-hash-from-last-commit-of-main-branch",
"packages": [
"sparq"
]
}
]
}- Declare the dependency
Create a vcpkg.json file in your application's root directory to declare your dependency on the framework
{
"name": "your-application-name",
"version": "1.0.0",
"dependencies": [
"sparq"
]
}- Create the CMake Presets
Instead of typing out long toolchain paths manually, create a
CMakePresets.jsonfile in your root directory. This file points directly to the vcpkg toolchain using yourVCPKG_ROOTenvironment variable
{
"version": 3,
"configurePresets": [
{
"name": "default-vcpkg",
"displayName": "Default with vcpkg",
"description": "Standard configuration using vcpkg toolchain",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
}
]
}- Wire up your
CMakeLists.txt
Add the standard CMake commands to find and link the sparq library to your executable
cmake_minimum_required(VERSION 3.23)
project(YourEmbeddedApp VERSION 0.0.1 LANGUAGES CXX)
# Find the sparq package provided by vcpkg
find_package(sparq REQUIRED)
add_executable(YourEmbeddedApp src/main.cpp)
# Link sparq to your application target
target_link_libraries(YourEmbeddedApp PRIVATE sparq::sparq)You do not need to use the command line or run manual installations. IDEs read your CMakePresets.json automatically
- Open the CMake GUI application
- In "Where is the source code", browse to your project's root directory
- CMake GUI will instantly detect your presets. Look for the Preset: dropdown menu at the top
- Select your preset(
default-vcpkgfor us) from the dropdown menu - Click the Generate button, this will automatically call Configure first, vcpkg will run in the background to fetch and prepare sparq and then create the Visual Studio solution files
- Click the Open Project button right next to it. This launches Visual Studio with your newly generated solution ready to go
- Install the CMake Tools and C/C++ extensions
- Open your project folder
- Select your named preset("Default with vcpkg" in our case) from the CMake Presets list in the status bar(or via the command palette)
- Click Configure or Build. VS Code will trigger vcpkg to pull sparq down and compile it seamlessly
- Open your project folder. CLion will detect
CMakePresets.jsonimmediately - Go to Settings > Build, Execution, Deployment > CMake
- Enable your preset("Default with vcpkg" in our case) profile
- Click the Build hammer icon
Whenever there will be vcpkg features for specific hardware support, this template will serve as a blueprint on how to update the current obscure version of vcpkg.json:
{
"name": "sparq",
"version": "0.0.1",
"description": "base42's embedded framework",
"dependencies": [
{
"name": "",
"features": [
""
],
"version>=": ""
}
],
"features": {
"test": {
"description": "test utilities",
"dependencies": [
"gtest"
]
},
"": {
"description": "support for ... devices",
"dependencies": [
{
"name": "",
"features": [
""
]
}
]
}
}
}