Skip to content

Commit

Permalink
406 document to build system with cmake (#409)
Browse files Browse the repository at this point in the history
* Created document with the detailed instructions to compile with CMake.
  • Loading branch information
aregtech authored Oct 28, 2024
1 parent 7bdab94 commit 7c62648
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 1 deletion.
144 changes: 144 additions & 0 deletions docs/wiki/CMAKE-BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Building AREG SDK with CMake

## Introduction
This guide provides step-by-step instructions for building the **AREG SDK** on Linux, Windows, and Cygwin platforms using **CMake**. It also covers IDE setups for **Microsoft Visual Studio** and **Visual Studio Code**. Follow these steps to set up your build environment and efficiently compile AREG SDK projects.

## Table of Contents
- [System Requirements](#system-requirements)
- [General Requirements](#general-requirements)
- [Platform-Specific Requirements](#platform-specific-requirements)
- [Configuration and Build Steps](#configuration-and-build-steps)
- [Step 1: Installing Dependencies](#step-1-installing-dependencies)
- [Step 2: Cloning the AREG SDK Repository](#step-2-cloning-the-areg-sdk-repository)
- [Step 3: Configuring the Build](#step-3-configuring-the-build)
- [Step 4: Building the Project](#step-4-building-the-project)
- [Step 5: Running Tests and Installing](#step-5-running-tests-and-installing)
- [Additional IDE Configurations](#additional-ide-configurations)

---

## System Requirements

### General Requirements
Ensure your system includes the following:
- **CMake** (version 3.20+)
- **Git** for repository cloning
- **Compatible Compilers**: *GNU*, *LLVM*, or *MSVC* (Windows only) supporting **C++17** or newer
- **Java** (version 17+ for code generation tools)

### Platform-Specific Requirements
- **Linux**: Install **ncurses** (required by `aregextend`).
- **Windows**: Requires Microsoft Visual C++ and **MFC** for GUI examples.
- **Optional Libraries**:
- **Google Test (GTest)** for unit tests (or build from sources).
- **SQLite3** (optional, or use the version in AREG SDK’s `thirdparty` directory).

If your system does not meet these requirements, proceed to [Step 1: Installing Dependencies](#step-1-installing-dependencies); otherwise, start from [Step 2: Cloning the AREG SDK Repository](#step-2-cloning-the-areg-sdk-repository).

---

## Configuration and Build Steps

Follow these steps to configure and build the AREG SDK on your system.

---

### Step 1: Installing Dependencies

#### Linux
To install the necessary packages:
```bash
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y git cmake build-essential clang libncurses-dev openjdk-17-jre
```
This command installs essential tools and libraries, including `ncurses` for Linux builds.

#### Windows
1. Download and install [Visual Studio](https://visualstudio.microsoft.com/) with CMake and Clang.
2. Install [Java](https://www.java.com/download/) and [Git](https://git-scm.com/download/win).

After installing these tools, Windows will be ready for AREG SDK builds.

#### Cygwin
Install required packages with the **[Cygwin installer](https://cygwin.com/install.html)** or by running:
```powershell
c:\cygwin\setup.exe -qgnO -s http://mirrors.kernel.org/sourceware/cygwin/ -l C:\cygwin\ -P cmake, dos2unix, flexdll, gcc-g++, make, git, ncurses, libncurses-devel
```

---

### Step 2: Cloning the AREG SDK Repository

Clone the AREG SDK repository to obtain the latest source code:
```bash
git clone https://github.com/aregtech/areg-sdk.git
cd areg-sdk
```
Navigate to the project directory to proceed with build commands.

---

### Step 3: Configuring the Build

Initialize build configurations with default settings:
```bash
cmake -B ./build
```
To customize the build, modify options as needed:
```bash
cmake -B ./build -DAREG_BUILD_TYPE=Debug -DAREG_EXAMPLES=ON -DAREG_TESTS=ON
```
For additional configurations, refer to the [CMake Configuration Guide](./cmake-config.md).

---

### Step 4: Building the Project

Compile the AREG SDK:
```bash
cmake --build ./build -j
```
This command utilizes available cores to speed up the build process.

---

### Step 5: Running Tests and Installing

#### Run Unit Tests:
To execute unit tests (if enabled):
```bash
ctest --test-dir ./build
```
To save test results to a file:
```bash
ctest --test-dir ./build --output-on-failure --output-junit test_results.xml
```

#### Install AREG SDK:

Install AREG SDK binaries and headers to develop multithreaded and multiprocessing applications based on the AREG Framework.

- **Linux**:
```bash
sudo cmake --install ./build
```
- **Windows** (run as Administrator):
```powershell
cmake --install ./build
```

---

## Additional IDE Configurations

For **Microsoft Visual Studio** or **Visual Studio Code**:
1. Open the `<areg-sdk>` directory in your IDE.
2. Right-click `CMakeLists.txt` and select *Configure*.
3. Adjust [AREG SDK settings](./cmake-config.md) in the CMake cache if necessary, then build the project directly in the IDE.

**Further Resources**:
For additional setup information, refer to [Visual Studio CMake Projects](https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio) or [VS Code CMake Quickstart](https://code.visualstudio.com/docs/cpp/cmake-quickstart).

---

This guide provides comprehensive instructions to set up, build, and optionally test the AREG SDK across multiple platforms. For troubleshooting, refer to the [AREG SDK documentation](https://github.com/aregtech/areg-sdk).
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion framework/areg/base/GESwitches.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
#endif // defined(EXP_AREG_LIB) || defined(_EXP_AREG_LIB) || defined(EXPORT_STATIC_SYMBOLS) || defined(_EXPORT_STATIC_SYMBOLS)

#if !defined(EXP_AREG_DLL) && !defined(EXP_AREG_LIB) && !defined(IMP_AREG_DLL) && !defined(IMP_AREG_LIB)
#pragma message ("WARNING: None of preprocessor defines are set. By default sets IMP_AREG_DLL. See GESwitches.h file of AREG API Core")
#pragma message("WARNING: No compiler option set for the AREG library. Using default IMP_AREG_DLL. To use a static library, define IMP_AREG_LIB. Refer to the GESwitches.h file in the AREG base for details.")
#define IMP_AREG_DLL
#endif // !defined(EXP_AREG_DLL) && !defined(EXP_AREG_LIB) && !defined(IMP_AREG_DLL) && !defined(IMP_AREG_LIB)

Expand Down

0 comments on commit 7c62648

Please sign in to comment.