This section explains how to install the dependencies required for Sparkle and the steps to build and install the Sparkle library on your Windows computer.
To build Sparkle on Windows, the following dependencies are required:
-
vcpkg
Sparkle uses vcpkg for dependency management. vcpkg will handle the installation of all required libraries specified in the
vcpkg.jsonmanifest file included in the Sparkle repository. -
CMake
CMake version 3.16 or higher is required to configure and build Sparkle.
-
Clang-tidy
LLVM version 18.1.5 or higher is required to configure and build Sparkle.
Follow these steps to install vcpkg:
- Clone the vcpkg repository:
git clone https://github.com/microsoft/vcpkg.git- Navigate to the vcpkg directory and bootstrap:
cd vcpkg
.\bootstrap-vcpkg.bat- Set the
VCPKG_ROOTenvironment variable: Set theVCPKG_ROOTenvironment variable to point to your vcpkg installation directory. This allows CMake to automatically detect vcpkg.
$env:VCPKG_ROOT = 'C:\path\to\vcpkg'Alternatively, you can add VCPKG_ROOT to your system environment variables for persistent usage.
Clang-tidy is distributed as part of the LLVM toolchain. Below are two common methods for installing Clang-tidy on Windows. Make sure that your installed version is 18.1.5 or higher.
-
Download Download the LLVM installer for Windows from the LLVM releases page. Choose the version 18.1.5 (or higher).
-
Installation Run the installer and follow the on-screen instructions.
-
Verification Verify that Clang-tidy is installed and on your PATH by opening a new terminal (Command Prompt or PowerShell) and typing:
clang-tidy --versionThis should print the Clang-tidy version number. If you see a "not recognized" error, ensure that the LLVM bin folder (e.g., C:\Program Files\LLVM\bin) is added to your PATH environment variable.
If you have Chocolatey installed on your system, you can install LLVM (including Clang-tidy) by running:
choco install llvmOnce installed, verify your Clang-tidy version by running:
clang-tidy --versionIf Clang-tidy is not accessible after installation, you may need to update your PATH environment variable:
- Open Start and search for "Environment Variables".
- Click "Edit the system environment variables".
- In the System Properties dialog, select "Environment Variables…".
- Under System variables, find or create a variable named PATH and append the path to your LLVM bin directory (for example, C:\Program Files\LLVM\bin).
Once Clang-tidy is installed and your environment is configured, you can confirm it is available by running:
clang-tidy --versionFollow these steps to configure, build, and install Sparkle:
- Clone the Sparkle repository:
git clone https://github.com/YourUsername/Sparkle.git
cd Sparkle- Configure the project with CMake:
cmake --preset [release/debug/test]- Build the project:
cmake --build --preset [release/debug/test]- Install the library:
cmake --install build/[release/debug]By default, this command installs Sparkle to EreliaStudio/Sparkle alongside the repository root. The resulting directory contains a lib folder with separate Debug and Release subdirectories.
Note: If you wish to specify a custom installation directory, you can set the CMAKE_INSTALL_PREFIX variable when configuring (back at instruction 3) like this :
cmake --preset [release/debug] -DCMAKE_INSTALL_PREFIX=<install_directory>This will install Sparkle into the specified <install_directory>.
You are now ready to use Sparkle in your projects!
When configuring an external project, CMake needs to know where Sparkle was installed. Pass either the installation prefix or the directory containing SparkleConfig.cmake:
# using the install prefix
cmake -S <project> -B <build> -DCMAKE_PREFIX_PATH="C:/path/to/EreliaStudio/Sparkle"
# or pointing directly to the config directory
cmake -S <project> -B <build> -DSparkle_DIR="C:/path/to/EreliaStudio/Sparkle/cmake"find_package(Sparkle REQUIRED) can then locate the imported target and expose the headers and libraries.
To use Sparkle in your project, you need to link against the Sparkle library and include its headers. Below are the steps:
Here is a sample CMakeLists.txt that builds an executable and links it against Sparkle:
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(TAAG)
find_package(Sparkle REQUIRED)
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/includes)
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/srcs)
file(GLOB_RECURSE HEADERS
${INCLUDE_DIR}/*.hpp
${INCLUDE_DIR}/*.h
)
file(GLOB_RECURSE SOURCES ${SRC_DIR}/*.cpp)
add_executable(TAAG ${SOURCES} ${HEADERS})
target_link_libraries(TAAG PRIVATE Sparkle::Sparkle)
target_include_directories(TAAG
PRIVATE
${INCLUDE_DIR}
)
set_target_properties(TAAG PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin/$<IF:$<CONFIG:Debug>,Debug,Release>/${ARCH_FOLDER}
)