-
Notifications
You must be signed in to change notification settings - Fork 122
08. Setup a project
When working on a project, it is common to utilize third-party frameworks or libraries. Integration methods typically involve using compiled binaries along with include files or integrating complete source codes into the build process. In some cases, the flexibility of the third-party component may limit integration options, necessitating the use of compiled binaries and header files instead of the source codes.
The AREG Framework has been developed with the utmost flexibility, allowing it to be seamlessly integrated into any project. Follow the instructions below to create a project based on the AREG SDK, referring to the areg-sdk-demo
repository as a practical implementation example.
This integration guide provides an instructions on seamlessly integrating the AREG (Automated Real-time Event Grid) Framework into your project. The AREG Framework is designed to be flexible and can be integrated into various project structures. To assist you in the process, we have created the areg-sdk-demo
repository as a practical example.
Start by cloning the AREG SDK repository, following the detailed instructions provided in the Wiki page. Ensure that the submodules are properly cloned. Set the source codes of the AREG SDK in a separate folder, or alternatively, include the AREG SDK as a submodule in your project.
You have two options for incorporating the AREG Framework into your project:
Option 1: Using Pre-built Binaries
- Build the AREG SDK as a separate project to generate the required binaries.
- Specify the
<areg-sdk>/framework
folder in your project's include path. - Link against the AREG Framework's libraries during the linking stage of your project.
Option 2: Integrating Source Codes
- Integrate the AREG Framework's source codes directly into your project's build process.
- Additional configuration steps are required before building your software.
Before building your software with any build tool, configure the AREG SDK builds to set the output folder and other flags.
To build the AREG SDK Demo project source codes and AREG Framework with CMake
:
-
Before including the
areg-sdk/CMakeLists.txt
in your build, ensure you set the values of the following parameters:-
AREG_BUILD_ROOT
: Specify the desired output folder for the AREG SDK build. -
AREG_BUILD_EXAMPLES
: Optionally set this parameter to exclude building examples, if desired.
-
-
For more details on available configuration parameters, refer to the cmake details section in the Software build Wiki page of AREG SDK.
To build the AREG SDK Demo project source codes and AREG Framework with Microsoft Visual Studio or MSBuild, follow these steps:
- Create a solution file in your project's file structure.
- In the same location, create the
msvc_setup.props
file. - Set the location of AREG SDK sources in the
AregSdkRoot
property. For example:<AregSdkRoot>$(SolutionDir)\thirdparty\areg-sdk</AregSdkRoot>
- Optionally, set other locations based on your project's file structure. Choose all or one of the following options:
- Set the location of the project build folder where binaries and generated files will be outputted:
<AregBuildRoot>$(SolutionDir)\product</AregBuildRoot>
- Set the location to output only compiled and built binaries:
This directory will contain three subdirectories:
<AregOutputDir>$(SolutionDir)\Bin\$(Configuration)</AregOutputDir>
bin
,lib
, andobj
. - Set the locations to output static libraries, binaries, and intermediate object files. It is recommended to set all three properties:
<AregOutputLib>$(SolutionDir)\lib</AregOutputLib> <AregOutputBin>$(SolutionDir)\bin</AregOutputBin> <AregOutputObj>$(SolutionDir)\$(Configuration)\$(ProjectName)</AregOutputObj>
$(SolutionDir)\product
. - Set the location of the project build folder where binaries and generated files will be outputted:
- Include the following three Visual Studio project files in the solution file:
-
areg.vcxproj
: AREG Framework project. -
areg-extend.vcxproj
: Extended library of AREG Framework. -
mcrouter.vcxproj
: Multicast Router project, if using Interprocess Communication (IPC) and Public Services.
-
- Include your own projects or create new ones within the solution.
- Set the project dependencies to establish the correct build order.
- Compile the Solution.
For configuration steps with other build tools, refer to the AREG SDK documentation.
💡 Please note that there is an open issue Integrate Makefile to build with make #11 in the
areg-sdk-demo
repository to build the Demo project with themake
tool. Any contributions to resolve this issue would be greatly appreciated.
Utilizing the AREG Framework involves developing Local and/or Public services for multithreading and/or multiprocessing applications. Follow these steps:
-
Create a Service Interface document (currently only available manually). The Service Interface document in the AREG SDK provides a detailed description of creating this document. Use XML format to define Data Types, Attributes, and Methods of the service.
-
Whenever you modify the Service Interface document, use the
codegen.jar
located in thetools
folder of the AREG SDK to generate codes. Alternatively, create script files to run scripts instead of manually typing commands in the command line. -
Once the codes are generated, build them as a static library. You can create one or more static libraries to include all generated codes or split them into modules. Compiling the generated codes as a static library will facilitate building Provider and Consumer components. Alternatively, you may build them as a shared library, but it may contain unnecessary objects when Providers and Consumers run in different processes.
During software development, it is recommended to enable logging, especially for Debug
builds. To enable or disable logging during builds, refer to the appropriate section of the Preprocessor define symbols Wiki page of AREG SDK.
Once logging is enabled, you can configure the logging settings and run your applications. Testing and debugging can be performed by analyzing the logs.
By following these steps, you will be able to seamlessly integrate the AREG Framework into your project or start a new project based on AREG Framework. For further information and additional steps, please refer to the AREG SDK documentation.
The areg-sdk-demo
repository serves as a showcase project demonstrating the integration of the AREG SDK into an existing project or as a foundation for creating a new project based on the AREG Framework. You can utilize this repository as a template and adapt it to suit your project structure. Below is an explanation of the configuration for compilation using the CMake tool.
The areg-sdk-demo
repository has the following structure:
- The AREG SDK source codes are included as a submodule in the
thirdparty
directory of the project. - The
demo
directory contains the source codes of several demo projects, which have been copied from theexamples
directory of theareg-sdk
repository. - The root of the Demo Project contains the
CMakeLists.txt
file, which configures and prepares the AREG Framework compilation and demo applications. - To prevent any collisions between the demo applications in the Demo Project and the examples from
areg-sdk
, the examples inareg-sdk
are disabled from building. After compiling the Demo Project, thebin
folder will only contain the projects that exist in thedemo
directory. This is achieved by settingoption(AREG_BUILD_EXAMPLES "Build AREG SDK examples" OFF)
.
Here is the content of the CMakeLists.txt
file in the Demo Project:
cmake_minimum_required(VERSION 3.16.0)
set(AREG_SDK_DEMO_ROOT "${CMAKE_SOURCE_DIR}")
set(AREG_DEMO_SOURCES "${AREG_SDK_DEMO_ROOT}/demo")
set(AREG_SDK_SOURCES "${AREG_SDK_DEMO_ROOT}/thirdparty/areg-sdk")
# Configure AREG SDK build
# Set the root path to output compiled binaries.
set(AREG_BUILD_ROOT "${AREG_SDK_DEMO_ROOT}/product")
# Disable building examples, instead, demo applications should be compiled.
option(AREG_BUILD_EXAMPLES "Build AREG SDK examples" OFF)
# Include areg-sdk files. This will initialize the options and compilers.
# You may include it after your project(s), but make sure that areg-sdk
# is properly configured.
include(${AREG_SDK_SOURCES}/CMakeLists.txt)
set(PROJECT_NAME "areg-sdk-demo")
set(PROJECT_VERSION "1.0.0")
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES C CXX)
# Start building Demo applications
include("${AREG_DEMO_SOURCES}/CMakeLists.txt")
To adapt the CMakeLists.txt
file to your project structure, make the following changes:
- Rename the
AREG_SDK_DEMO_ROOT
variable and set the desired value, or leave it as${CMAKE_SOURCE_DIR}
. - Rename the
AREG_DEMO_SOURCES
variable and specify the folder location of your development source code (e.g.,sources
ordevelop
). - Specify the location of the
areg-sdk
source
code in the AREG_SDK_SOURCES
variable.
- Set the folder name in the
AREG_BUILD_ROOT
variable to determine the output directory for binaries. - Optionally, you can set the values of:
-
AREG_OUTPUT_BIN
to specify the output directory for libraries and binaries. -
AREG_OUTPUT_LIB
to specify the output directory for libraries. -
AREG_OUTPUT_BIN
to specify the output directory for binaries. Note: TheAREG_OUTPUT_LIB
andAREG_OUTPUT_BIN
directories are automatically included in the library search path.
-
- In most cases, you may not need to compile the examples provided by
areg-sdk
since they might not be relevant to your project. Disable the building of examples by setting theAREG_BUILD_EXAMPLES
variable toOFF
likeoption(AREG_BUILD_EXAMPLES "Build AREG SDK examples" OFF)
. It is easier to set this value directly in your project'sCMakeLists.txt
file. - Optionally, you may need to disable the compilation and execution of unit tests. To do so, set the
AREG_BUILD_TESTS
variable directly in theCMakeLists.txt
file or pass it via the command line. - Additionally, you can set other options such as the compiler, build configuration, etc., either directly in the
CMakeLists.txt
file or through command-line parameters.
After making these changes, you should be able to compile your project successfully.
Please refer to the AREG SDK documentation for further details and instructions.
Help us to make docs greater: See something is wrong, unclear or need a help? Submit a change, open a discussion or ask AREG SDK community a question.
2023 © Aregtech, www.aregtech.com, email: info[at]aregtech.com