Skip to content

Commit

Permalink
444 fix demo build (#445)
Browse files Browse the repository at this point in the history
* Fixed Demo build.
* Updated documentations considering experience of integration areg-sdk in Demo project.
  • Loading branch information
aregtech authored Nov 15, 2024
1 parent 9be7ffc commit 44d9a0c
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 35 deletions.
1 change: 1 addition & 0 deletions areg-sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mcrouter", "framework\mcrou
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FD549A95-E734-4E26-A5B2-2330FC310C8D}"
ProjectSection(SolutionItems) = preProject
areg.cmake = areg.cmake
CMakeLists.txt = CMakeLists.txt
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
CONTRIBUTING.md = CONTRIBUTING.md
Expand Down
8 changes: 7 additions & 1 deletion areg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,31 @@ if (NOT DEFINED AREG_SDK_ROOT OR "${AREG_SDK_ROOT}" STREQUAL "")
# Make sure that AREG_SDK_ROOT is set before the 'setup.cmake' is included
message(FATAL_ERROR "AREG: >>> Set \'AREG_SDK_ROOT\' before including \'setup.cmake\'. Stopping building the project.")
return()
else()
message(STATUS "AREG: >>> Specified AREG_SDK_ROOT = \'${AREG_SDK_ROOT}\'")
endif()

# The location of cmake configuration files.
if (NOT DEFINED AREG_CMAKE_CONFIG_DIR OR "${AREG_CMAKE_CONFIG_DIR}" STREQUAL "")
set(AREG_CMAKE_CONFIG_DIR "${AREG_SDK_ROOT}/conf/cmake")
else()
message(STATUS "AREG: >>> Specified AREG_CMAKE_CONFIG_DIR = \'${AREG_CMAKE_CONFIG_DIR}\'")
endif()

# Disable or enable areg-sdk specific outputs
if (NOT DEFINED AREG_ENABLE_OUTPUTS OR "${AREG_ENABLE_OUTPUTS}" STREQUAL "")
option(AREG_ENABLE_OUTPUTS "Disable AREG SDK specific outputs, use defaults" OFF)
message(STATUS "AREG: >>> Disable AREG SDK specific outputs, use defaults")
endif()

# Include setup.cmake to initialize variables
message(STATUS "AREG: >>> Including \'${AREG_CMAKE_CONFIG_DIR}/setup.cmake\'")
include("${AREG_CMAKE_CONFIG_DIR}/setup.cmake")

# Include common.cmake to initialize compile options
message(STATUS "AREG: >>> Including \'${AREG_CMAKE_CONFIG_DIR}/common.cmake\'")
include("${AREG_CMAKE_CONFIG_DIR}/common.cmake")

# Set the 'framework' in the include directories
include_directories("${AREG_FRAMEWORK}")

# Now the header files of the areg framework can be included in the projects.
4 changes: 2 additions & 2 deletions conf/cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ macro(macro_setup_compilers_data compiler_path compiler_family compiler_short co

set(${is_identified} FALSE)
if (DEFINED AREG_PROCESSOR)
set(${sys_platform} AREG_PROCESSOR)
set(${sys_platform} ${AREG_PROCESSOR})
endif()
if (DEFINED AREG_BITNESS)
set(${sys_bitness} AREG_BITNESS)
set(${sys_bitness} ${AREG_BITNESS})
endif()

# Iterate over known compilers to identify the compiler type
Expand Down
7 changes: 5 additions & 2 deletions conf/cmake/user.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# 16. AREG_OUTPUT_DIR = '<areg-sdk>/product/build/<default-compiler family-name>/<os>-<bitness>-<cpu>-release-<areg-lib>'
# 17. AREG_OUTPUT_BIN = '<areg-sdk>/product/build/<default-compiler family-name>/<os>-<bitness>-<cpu>-release-<areg-lib>/bin'
# 18. AREG_OUTPUT_LIB = '<areg-sdk>/product/build/<default-compiler family-name>/<os>-<bitness>-<cpu>-release-<areg-lib>/lib'
# 19. AREG_PACKAGES = '${AREG_BUILD_ROOT}/packages'
# 19. AREG_PACKAGES = '${CMAKE_BINARY_DIR}/packages'
# 20. AREG_INSTALL = ON (possible values: ON, OFF)
# 21. AREG_INSTALL_PATH = '${HOME}/areg-sdk' (or '${USERPROFILE}' on Windows, defaults to current directory if unset)
#
Expand All @@ -69,6 +69,9 @@
# Example Command with AREG_BUILD_ROOT to output binaries in custom directory:
# $ cmake -B ./build -DAREG_BUILD_ROOT="/home/developer/projects/my_project/product"
#
# Hint:
# To use AREG SDK cmake options in other project, the 'user.cmake' file should be included before first call of "project()". Otherwise, AREG SDK settings uses cmake options CMAKE_CXX_COMPILER and CMAKE_BUILD_TYPE options.
#
# Integration:
# - Visit https://github.com/aregtech/areg-sdk-demo repository to see various ways of AREG Framework integration.
# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -271,7 +274,7 @@ if (NOT DEFINED AREG_ENABLE_OUTPUTS OR AREG_ENABLE_OUTPUTS)
endif()

if (NOT DEFINED AREG_PACKAGES OR "${AREG_PACKAGES}" STREQUAL "")
set(AREG_PACKAGES "${AREG_BUILD_ROOT}/packages")
set(AREG_PACKAGES "${CMAKE_BINARY_DIR}/packages")
endif()
else()
option(AREG_ENABLE_OUTPUTS "Enable changing output directories" FALSE)
Expand Down
9 changes: 0 additions & 9 deletions conf/msvc/user.props
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@
<!-- ********************************************************************************************************************************** -->
<ItemGroup>

<BuildMacro Include="AregGenerateDir">
<Value>$(AregGenerateDir)</Value>
</BuildMacro>
<BuildMacro Include="AregPackages">
<Value>$(AregPackages)</Value>
</BuildMacro>
<BuildMacro Include="AregFramewor">
<Value>$(AregFramewor)</Value>
</BuildMacro>
<BuildMacro Include="AregFrameworkResources">
<Value>$(AregFrameworkResources)</Value>
</BuildMacro>
Expand Down
16 changes: 14 additions & 2 deletions docs/wiki/02a-cmake-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ The following are the available CMake options to configure the AREG SDK build. O
- **Default**: `gnu` on Linux and Cygwin, `msvc` on Windows
- **Example**: `cmake -B ./build -DAREG_COMPILER_FAMILY=llvm`

> [!NOTE]
> The value of `AREG_COMPILER_FAMILY` variable is ignored and overridden by the value of the standard CMake variable `CMAKE_CXX_COMPILER` if the `<areg-sdk-config>/user.cmake` file is included in the project *after* the first invocation of `project()`.
<div align="right"><kbd><a href="#options-table">↑ Back to top ↑</a></kbd></div>

---
Expand All @@ -114,6 +117,9 @@ The following are the available CMake options to configure the AREG SDK build. O
- **Defaults**: System default compiler.
- **Example**: `cmake -B ./build -DAREG_COMPILER=g++`

> [!NOTE]
> The value of `AREG_COMPILER` variable is ignored and overridden by the value of the standard CMake variable `CMAKE_CXX_COMPILER` if the `<areg-sdk-config>/user.cmake` file is included in the project *after* the first invocation of `project()`.
<div align="right"><kbd><a href="#options-table">↑ Back to top ↑</a></kbd></div>

---
Expand All @@ -125,6 +131,9 @@ The following are the available CMake options to configure the AREG SDK build. O
- **Default**: *System-Defined*
- **Example**: `cmake -B ./build -DAREG_PROCESSOR=x86`

> [!NOTE]
> The value of `AREG_PROCESSOR` may be ignored depending on the selected compiler and the inclusion timing of `<areg-sdk-config>/user.cmake`. For instance, if `AREG_PROCESSOR` is set to `arm`, the `AREG_COMPILER_FAMILY` is `gnu` and `user.cmake` is included *after* the first invocation of `project()`, the sources will be built for the host processor (like `x86_x64` using the default compiler settings.
> [!TIP]
> To check if an application has been compiled for a 32-bit or 64-bit system, navigate to the build binary directory and run:
> ```bash
Expand Down Expand Up @@ -174,6 +183,9 @@ The following are the available CMake options to configure the AREG SDK build. O
- **Default**: `Release`
- **Example**: `cmake -B ./build -DAREG_BUILD_TYPE=Debug`
> [!NOTE]
> The value of `AREG_BUILD_TYPE` variable is ignored and overridden by the value of the standard CMake variable `CMAKE_BUILD_TYPE` if the `<areg-sdk-config>/user.cmake` file is included in the project *after* the first invocation of `project()`.
<div align="right"><kbd><a href="#options-table">↑ Back to top ↑</a></kbd></div>
---
Expand Down Expand Up @@ -295,8 +307,8 @@ The following are the available CMake options to configure the AREG SDK build. O
---
### 19. **AREG_PACKAGES**
- **Description**: Defines where third-party packages are stored. By default, this is set to a `packages` subdirectory within `AREG_BUILD_ROOT`.
- **Default**: `{AREG_BUILD_ROOT}/packages`
- **Description**: Defines where third-party packages are stored. By default, this is set to a `packages` subdirectory within `CMAKE_BINARY_DIR`.
- **Default**: `{CMAKE_BINARY_DIR}/packages`
- **Example**: `cmake -B ./build -DAREG_PACKAGES=/path/to/packages`
<div align="right"><kbd><a href="#options-table">↑ Back to top ↑</a></kbd></div>
Expand Down
3 changes: 3 additions & 0 deletions docs/wiki/02c-cmake-integrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ Also see [Installing and Using AREG SDK with vcpkg Package Manager](./01a-areg-p

## 5. Advanced Integration

> [!IMPORTANT]
> To utilize AREG SDK-specific CMake variables such as `AREG_COMPILER`, `AREG_COMPILER_FAMILY`, or `AREG_BUILD_TYPE`, ensure that `<areg-sdk>/areg.cmake` is included in your project's `CMakeLists.txt` file *before* the first invocation of `project()`. Otherwise, the values of these variables are ignored and overwritten by values of CMake variables `CMAKE_CXX_COMPILER` and `CMAKE_BUILD_TYPE`. Alternatively, you can directly use the `CMAKE_XXX` variables to specify the compiler or build type.
### Advanced CMake Options
The AREG SDK offers flexible configurations via CMake, allowing customization of compilation settings, output directories, and additional features. For the full list, refer to the [CMake Configuration Options for Building AREG SDK](./02a-cmake-config.md) document.
Expand Down
21 changes: 20 additions & 1 deletion docs/wiki/07b-troubleshooting-cmake-linux-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This guide provides solutions for common issues encountered when compiling proje

1. [Issue 1: Missing `<asm/errno.h>` File](#issue-1-missing-asmerrnoh-file)
- [Solution: Create a Symbolic Link](#solution-create-a-symbolic-link)
2. [Issue 2: Values of `AREG_XXX` Variables are Ignored](#issue-2-values-of-areg_xxx-variables-are-ignored)
- [Solution 1: Fetch Sources Before Project Declaration](#solution-fetch-sources-before-project-declaration)
- [Solution 2: Use Standard CMake Variables](#solution-2-use-standard-cmake-variables)

---

Expand Down Expand Up @@ -35,4 +38,20 @@ To address this issue, create a symbolic link from the `asm-generic` directory t
> Alternatively, the `asm/errno.h` header file is included in some system packages. You can try installing it by running:
> ```bash
> sudo apt-get install -y linux-libc-dev
> ```
> ```
---
## Issue 2: Values of `AREG_XXX` Variables are Ignored
During the build process, the values of `AREG_COMPILER_FAMILY`, `AREG_COMPILER`, `AREG_BUILD_TYPE`, and even the target processor defined in `AREG_PROCESSOR` variable may be ignored. This typically occurs when the AREG SDK is integrated *after* the first invocation of `project()`, as these AREG-specific variables are overwritten by standard CMake values.
### Solution 1: Fetch Sources Before Project Declaration
Fetch the AREG SDK sources *before* calling `project()`. Additionally, you can set the values of AREG-specific CMake variables prior to fetching the SDK.
### Solution 2: Use Standard CMake Variables
Alternatively, use standard CMake variables such as `CMAKE_CXX_COMPILER` to specify the compiler and `CMAKE_BUILD_TYPE` to define the build type. These variables are compatible with AREG-specific CMake configurations and help avoid conflicts.
---
26 changes: 13 additions & 13 deletions framework/areg/component/Event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@
* Do not use them directly, instead use DECLARE_RUNTIME_EVENT
**/
#define DECLARE_EVENT_STATIC_REGISTRATION(EventClass) \
public: \
/* Declare static function to add/register event consumer to start processing event. */ \
static bool addListener(IEEventConsumer& eventConsumer, const String & whichThread = String::getEmptyString()); \
/* Declare static function to add/register event consumer to start processing event. */ \
static bool addListener(IEEventConsumer& eventConsumer, id_type whichThread); \
/* Declare static function to add/register event consumer to start processing event. */ \
static bool addListener(IEEventConsumer& eventConsumer, DispatcherThread & dispThread); \
/* Declare static function to remove/unregister event consumer to stop processing event. */ \
static bool removeListener(IEEventConsumer& eventConsumer, const String & whichThread = String::getEmptyString()); \
/* Declare static function to remove/unregister event consumer to stop processing event. */ \
static bool removeListener(IEEventConsumer& eventConsumer, id_type whichThread); \
/* Declare static function to remove/unregister event consumer to stop processing event. */ \
static bool removeListener(IEEventConsumer& eventConsumer, DispatcherThread & dispThread);
public: \
/* Declare static function to add/register event consumer to start processing event. */ \
static bool addListener(IEEventConsumer& eventConsumer, const String & whichThread = String::getEmptyString()); \
/* Declare static function to add/register event consumer to start processing event. */ \
static bool addListener(IEEventConsumer& eventConsumer, id_type whichThread); \
/* Declare static function to add/register event consumer to start processing event. */ \
static bool addListener(IEEventConsumer& eventConsumer, DispatcherThread & dispThread); \
/* Declare static function to remove/unregister event consumer to stop processing event. */ \
static bool removeListener(IEEventConsumer& eventConsumer, const String & whichThread = String::getEmptyString()); \
/* Declare static function to remove/unregister event consumer to stop processing event. */ \
static bool removeListener(IEEventConsumer& eventConsumer, id_type whichThread); \
/* Declare static function to remove/unregister event consumer to stop processing event. */ \
static bool removeListener(IEEventConsumer& eventConsumer, DispatcherThread & dispThread);

/**
* \brief MACRO, implements static functions to add and remove
Expand Down
24 changes: 19 additions & 5 deletions msvc_setup.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,24 @@
<!-- ********************************************************************************************************************************** -->
<AregSdkRoot>$(SolutionDir)</AregSdkRoot>
<!-- ********************************************************************************************************************************** -->
<!-- Property to set the location of MS Visual Studio configuration files for AREG SDK. Normally, it is in '$(AregSdkRoot)conf\msvc\' -->
<!-- Only 'msvc_setup.props' file should be located in the $(SolutionDir). Other files should be in 'AregConfigDir' -->
<!-- ********************************************************************************************************************************** -->
<AregConfigDir>$(AregSdkRoot)conf\msvc\</AregConfigDir>
<!-- ********************************************************************************************************************************** -->
<!-- Property to set the root directory for build and generated codes outputs. Change if integrate in your project. -->
<!-- Example to set the directory: <my project path>\product -->
<!-- By default, the output is in '$(SolutionDir)product' -->
<!-- ********************************************************************************************************************************** -->
<AregOutputRoot>$(SolutionDir)product\</AregOutputRoot>
<!-- ********************************************************************************************************************************** -->
<!-- Property to set the location of MS Visual Studio configuration files for AREG SDK. Normally, it is in '$(AregSdkRoot)conf\msvc\' -->
<!-- Only 'msvc_setup.props' file should be located in the $(SolutionDir). Other files should be in 'AregConfigDir' -->
<!-- Set the directory for generated source files. -->
<!-- ********************************************************************************************************************************** -->
<AregConfigDir>$(AregSdkRoot)conf\msvc\</AregConfigDir>
<AregGenerateDir>$(AregOutputRoot)generate\</AregGenerateDir>
<!-- ********************************************************************************************************************************** -->
<!-- Set the directory to download thirdparty packages. If change, also change the location in nuget.config file. -->
<!-- ********************************************************************************************************************************** -->
<AregPackages>$(AregOutputRoot)packages\</AregPackages>
<!-- ********************************************************************************************************************************** -->
<!-- Property to set the location of AREG Framework header. -->
<!-- ********************************************************************************************************************************** -->
Expand Down Expand Up @@ -91,11 +99,17 @@
<BuildMacro Include="AregSdkRoot">
<Value>$(AregSdkRoot)</Value>
</BuildMacro>
<BuildMacro Include="AregConfigDir">
<Value>$(AregConfigDir)</Value>
</BuildMacro>
<BuildMacro Include="AregOutputRoot">
<Value>$(AregOutputRoot)</Value>
</BuildMacro>
<BuildMacro Include="AregConfigDir">
<Value>$(AregConfigDir)</Value>
<BuildMacro Include="AregGenerateDir">
<Value>$(AregGenerateDir)</Value>
</BuildMacro>
<BuildMacro Include="AregPackages">
<Value>$(AregPackages)</Value>
</BuildMacro>
<BuildMacro Include="AregFramework">
<Value>$(AregFramework)</Value>
Expand Down

0 comments on commit 44d9a0c

Please sign in to comment.