This document provides a comprehensive guide for installing the vcpkg
package manager, setting up the areg
package, and creating projects with CMake or Visual Studio to effectively use the AREG SDK.
- AREG SDK General Requirements
- Install vcpkg
- Install and Integrate the areg Package
- Setting Up a CMake Project to Use areg
- Creating a Microsoft Visual Studio Project to Use areg
Ensure the following dependencies are installed to integrate the AREG SDK:
- CMake version 3.20 or higher
- Git for repository management
- Supported Compilers: GCC, LLVM, or MSVC (Windows only) with C++17 or newer
- Java version 17+ for code generation tools
The vcpkg
package manager helps manage C++ libraries across multiple platforms. Follow these steps to install vcpkg
:
-
Clone the
vcpkg
repository: Open a terminal (Command Prompt, PowerShell, or Terminal on macOS/Linux) and run:git clone https://github.com/microsoft/vcpkg.git cd vcpkg
-
Bootstrap vcpkg: Build the
vcpkg
executable by running the bootstrap script.- On Windows:
.\bootstrap-vcpkg.bat
- On Linux/macOS:
./bootstrap-vcpkg.sh
- On Windows:
-
Add vcpkg to PATH (Optional): Adding
vcpkg
to your PATH allows you to run it from any terminal session (replace<path-to-vcpkg-root>
with real path).- On Windows:
set PATH=%PATH%;<path-to-vcpkg-root>
- On Linux/macOS:
export PATH=$PATH:<path-to-vcpkg-root>
- On Windows:
-
Integrate
vcpkg
with your system: To enable seamless use with Visual Studio, run:vcpkg integrate install
This command configures Visual Studio to automatically detect and use libraries installed with
vcpkg
. This also displays the full path to the CMake toolchain file to setCMAKE_TOOLCHAIN_FILE
option.
After installing vcpkg
, you can install the areg
package, which provides the AREG SDK libraries, header files, CMake configurations and tools.
-
Install the
areg
Package: Run the following command to download, build, and install the AREG SDK development components.vcpkg install areg
-
Verify Integration: If using Visual Studio, ensure
vcpkg integrate install
was run as described in the previous section. This integration makesareg
available to all Visual Studio projects on the system. For CMake projects, the CMake toolchain file provided byvcpkg
must be set (optionCMAKE_TOOLCHAIN_FILE
) when configuring the project.
Once vcpkg
and the areg
package are installed, you can create a CMake project that links with the AREG SDK libraries.
Steps to Create a CMake Project:
-
Create a Project Directory:
mkdir example cd example
-
Add Source Code: Create a
main.cpp
file that uses components from the areg framework:#include "areg/base/String.hpp" int main() { String str("Hello from AREG SDK!"); std::cout << str.getData() << std::endl; return 0; }
-
Create a
CMakeLists.txt
File: In the project directory, create aCMakeLists.txt
file:cmake_minimum_required(VERSION 3.20) project(example) # Enable vcpkg find_package(areg CONFIG REQUIRED) add_executable(example main.cpp) target_link_libraries(example PRIVATE areg::areg)
-
Build the Project: Run the following commands to configure and build your project. Replace
<path-to-vcpkg-root>
with the path to yourvcpkg
installation.cmake -B ./build -DCMAKE_TOOLCHAIN_FILE="<path-to-vcpkg-root>/scripts/buildsystems/vcpkg.cmake" cmake --build ./build
This will compile the example
project and link it with the areg
library.
vcpkg
also integrates seamlessly with Visual Studio, making it easy to add packages like areg
to C++ projects.
Steps to Set Up a Visual Studio Project:
-
Open Visual Studio: Start a new project and select C++ Console Application.
-
Add Source Code: Create a simple
main.cpp
file in your project with the following content:#include "areg/base/String.hpp" int main() { String str("Hello from AREG SDK!"); std::cout << str.getData() << std::endl; return 0; }
-
Configure and Build:
- If you ran
vcpkg integrate install
, Visual Studio should automatically detect and use packages installed throughvcpkg
, includingareg
. - Build and run your project. Visual Studio will handle linking with
areg
and other configurations throughvcpkg
.
If
vcpkg
is not detected, verify the integration by checking thatvcpkg integrate install
was executed and restart Visual Studio if needed. - If you ran