diff --git a/conf/cmake/functions.cmake b/conf/cmake/functions.cmake index 5e3e79a8..eb2a65a8 100644 --- a/conf/cmake/functions.cmake +++ b/conf/cmake/functions.cmake @@ -73,10 +73,15 @@ endfunction(setAppOptions) # --------------------------------------------------------------------------- function(addExecutableEx target_name target_namespace source_list library_list) + # Ensure the source list is not empty + if (NOT source_list) + message(FATAL_ERROR "AREG: >>> Source list for executable \'${target_name}\' is empty") + endif() + # Gather any additional libraries passed as arguments (ARGN) set(exList "${ARGN}") - foreach(item IN LISTS exList) - list(APPEND library_list "${item}") + foreach(_item IN LISTS exList) + list(APPEND library_list "${_item}") endforeach() # Create the executable with the specified source files @@ -149,8 +154,8 @@ function(addStaticLibEx target_name target_namespace source_list library_list) # Gather any additional libraries passed as arguments (ARGN) set(exList "${ARGN}") - foreach(item IN LISTS exList) - list(APPEND library_list "${item}") + foreach(_item IN LISTS exList) + list(APPEND library_list "${_item}") endforeach() # Create the static library with the specified source files @@ -195,8 +200,8 @@ endfunction(addStaticLib) # --------------------------------------------------------------------------- function(addStaticLibEx_C target_name target_namespace source_list library_list) set(exList "${ARGN}") - foreach(item IN LISTS exList) - list(APPEND library_list "${item}") + foreach(_item IN LISTS exList) + list(APPEND library_list "${_item}") endforeach() add_library(${target_name} STATIC ${source_list}) if (NOT "${target_namespace}" STREQUAL "") @@ -277,8 +282,8 @@ function(addSharedLibEx target_name target_namespace source_list library_list) # Gather any additional libraries passed as arguments (ARGN) set(exList "${ARGN}") - foreach(item IN LISTS exList) - list(APPEND library_list "${item}") + foreach(_item IN LISTS exList) + list(APPEND library_list "${_item}") endforeach() # Create the shared library with the specified source files @@ -575,13 +580,211 @@ endfunction(removeEmptyDirs) # --------------------------------------------------------------------------- macro(macro_add_source result_list src_base_dir) set(_list "${ARGN}") - foreach(item IN LISTS _list) - set(_src "${src_base_dir}/${item}") + foreach(_item IN LISTS _list) + set(_src "${src_base_dir}/${_item}") if (EXISTS "${_src}") list(APPEND ${result_list} "${_src}") else() - message(FATAL_ERROR "AREG: >>> The item '${item}' does not exist in '${src_base_dir}'") + message(FATAL_ERROR "AREG: >>> The item '${_item}' does not exist in '${src_base_dir}'") endif() endforeach() unset(_list) endmacro(macro_add_source) + + +# --------------------------------------------------------------------------- +# Description : This macro processes a list of input arguments that can include: +# 1. **CMake targets** (predefined libraries or targets). +# 2. **Source files**: Files provided with either absolute paths or +# paths relative to the current directory. +# 3. **Resource files** (*.rc): Windows-specific resource files. +# The macro categorizes the input arguments into three separate lists: +# 1. **Libraries list**: Contains any known CMake targets. +# 2. **Source files list**: Includes valid source files (.cpp, .c) +# from either the provided absolute paths or relative paths. +# 3. **Resource files list**: Filters out .rc files, specifically for Windows, +# and stores them in a separate list. +# +# Parameters : ${res_sources} -- Output: A list containing the parsed source files. +# ${res_libs} -- Output: A list containing the recognized CMake targets (libraries). +# ${res_resources} -- Output: A list containing the identified resource files (*.rc). +# ${ARGN} -- Input: A list of files, libraries, or resources to be categorized. +# +# Behavior ...: +# - If a file does not exist, either as a full path or relative to the current directory, +# the macro throws a fatal error. +# - On Windows, it specifically identifies and appends resource files (*.rc) to the +# resources list. +# +# Usage ......: macro_parse_arguments( my_target my/app/main.cpp my/lib/object.cpp my/resource/resource.rc) +# Example: macro_parse_arguments(src_files lib_targets res_files my_lib src/main.cpp src/object.cpp res/resource.rc) +# --------------------------------------------------------------------------- +macro(macro_parse_arguments res_sources res_libs res_resources) + set(_list "${ARGN}") + foreach(_item IN LISTS _list) + # Check if the _item is a known CMake target + if (TARGET ${_item}) + list(APPEND ${res_libs} ${_item}) + # Check if the _item is an existing file, relative or full path + elseif (EXISTS "${_item}") + list(APPEND ${res_sources} "${_item}") + elseif (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${_item}") + list(APPEND ${res_sources} "${CMAKE_CURRENT_LIST_DIR}/${_item}") + else() + message(FATAL_ERROR "AREG: >>> File \'${_item}\' does not exist, ignoring") + endif() + endforeach() + + # Separate out resource files (*.rc) for setting their properties on Windows + foreach(_file IN LISTS ${res_sources}) + cmake_path(GET _file EXTENSION _ext) + if (_ext STREQUAL "rc") + list(APPEND ${res_resources} "${_file}") + endif() + endforeach() + +endmacro(macro_parse_arguments) + +# --------------------------------------------------------------------------- +# Description : This macro declares a static library by processing the provided list of +# arguments and categorizing them into three main groups: +# 1. **Source Files**: These are the .cpp or .c files used to build the library. +# The macro supports both absolute paths and paths relative to the current directory. +# 2. **Libraries**: These are existing CMake targets (predefined libraries) +# that the static library depends on. +# 3. **Resource Files**: These are .rc files (Windows resource files). +# On Windows systems, the macro ensures they are processed using the appropriate RC language settings. +# The macro declares a static library target using the collected source files and linked libraries. +# It also handles resource file configuration on Windows platforms. +# +# Parameters : ${lib_name} -- The name of the static library to be declared. +# ${ARGN} -- The list of source files, libraries, and resource files. +# The files can be specified with full or relative paths. +# +# Notes ......: +# - Throws a fatal error if no source files are provided. +# - On Windows, resource files (*.rc) are set to use the RC language automatically. +# +# Usage ......: macro_declare_static_library( ) +# Example: macro_declare_static_library(myStaticLib src/main.cpp src/resource.rc libSomeDependency) +# --------------------------------------------------------------------------- +macro(macro_declare_static_library lib_name) + + # Parse arguments to get sources, libraries, and resources + macro_parse_arguments(_sources _libs _resources "${ARGN}") + + # Ensure the source list is not empty + if (NOT _sources) + message(FATAL_ERROR "AREG: >>> Source list for executable \'${exe_name}\' is empty") + endif() + + # Declare the static library using gathered sources and libraries + addStaticLibEx(${lib_name} "" "${_sources}" "${_libs}") + + # If on Windows, set the RC files' language property + if (AREG_DEVELOP_ENV MATCHES "Win32" AND _resources) + set_source_files_properties(${_resources} PROPERTIES LANGUAGE RC) + endif() + + # Clean up temporary variables + unset(_sources) + unset(_libs) + unset(_resources) + +endmacro(macro_declare_static_library) + +# --------------------------------------------------------------------------- +# Description : This macro declares a shared library by processing the provided list of +# arguments and categorizing them into three main groups: +# 1. **Source Files**: These are the .cpp or .c files used to build the library. +# The macro supports both absolute paths and paths relative to the current directory. +# 2. **Libraries**: These are existing CMake targets (predefined libraries) +# that the shared library depends on. +# 3. **Resource Files**: These are .rc files (Windows resource files). +# On Windows systems, the macro ensures they are processed using the appropriate RC language settings. +# The macro declares a shared library target using the collected source files and linked libraries. +# It also handles resource file configuration on Windows platforms. +# +# Parameters : ${lib_name} -- The name of the shared library to be declared. +# ${ARGN} -- The list of source files, libraries, and resource files. +# The files can be specified with full or relative paths. +# +# Notes ......: +# - Throws a fatal error if no source files are provided. +# - On Windows, resource files (*.rc) are set to use the RC language automatically. +# +# Usage ......: macro_declare_static_library( ) +# Example: macro_declare_static_library(myStaticLib src/main.cpp src/resource.rc libSomeDependency) +# --------------------------------------------------------------------------- +macro(macro_declare_shared_library lib_name) + + # Parse arguments to get sources, libraries, and resources + macro_parse_arguments(_sources _libs _resources "${ARGN}") + + # Ensure the source list is not empty + if (NOT _sources) + message(FATAL_ERROR "AREG: >>> Source list for executable \'${exe_name}\' is empty") + endif() + + # Declare the shared library using gathered sources and libraries + addSharedLibEx(${lib_name} "" "${_sources}" "${_libs}") + + # If on Windows, set the RC files' language property + if (AREG_DEVELOP_ENV MATCHES "Win32" AND _resources) + set_source_files_properties(${_resources} PROPERTIES LANGUAGE RC) + endif() + + # Clean up temporary variables + unset(_sources) + unset(_libs) + unset(_resources) + +endmacro(macro_declare_shared_library) + +# --------------------------------------------------------------------------- +# Description : This macro declares an executable by processing the provided list of +# arguments and categorizing them into three main groups: +# 1. **Source Files**: These are the .cpp or .c files used to build the library. +# The macro supports both absolute paths and paths relative to the current directory. +# 2. **Libraries**: These are existing CMake targets (predefined libraries) +# that the executable depends on. +# 3. **Resource Files**: These are .rc files (Windows resource files). +# On Windows systems, the macro ensures they are processed using the appropriate RC language settings. +# The macro declares a executable target using the collected source files and linked libraries. +# It also handles resource file configuration on Windows platforms. +# +# Parameters : ${lib_name} -- The name of the executable to be declared. +# ${ARGN} -- The list of source files, libraries, and resource files. +# The files can be specified with full or relative paths. +# +# Notes ......: +# - Throws a fatal error if no source files are provided. +# - On Windows, resource files (*.rc) are set to use the RC language automatically. +# +# Usage ......: macro_declare_static_library( ) +# Example: macro_declare_static_library(myStaticLib src/main.cpp src/resource.rc libSomeDependency) +# --------------------------------------------------------------------------- +macro(macro_declare_executable exe_name) + + # Parse arguments to get sources, libraries, and resources + macro_parse_arguments(_sources _libs _resources "${ARGN}") + + # Ensure the source list is not empty + if (NOT _sources) + message(FATAL_ERROR "AREG: >>> Source list for executable \'${exe_name}\' is empty") + endif() + + # Declare the executable using gathered sources and libraries + addExecutableEx(${exe_name} "" "${_sources}" "${_libs}") + + # If on Windows, set the RC files' language property + if (AREG_DEVELOP_ENV MATCHES "Win32" AND _resources) + set_source_files_properties(${_resources} PROPERTIES LANGUAGE RC) + endif() + + # Clean up temporary variables + unset(_sources) + unset(_libs) + unset(_resources) + +endmacro(macro_declare_executable) diff --git a/examples/00_helloservice/CMakeLists.txt b/examples/00_helloservice/CMakeLists.txt index 88be41ad..3b62ab3c 100644 --- a/examples/00_helloservice/CMakeLists.txt +++ b/examples/00_helloservice/CMakeLists.txt @@ -3,25 +3,25 @@ addServiceInterface(00_generated res HelloService) # add projects -macro_example_declare_runnable(00_pubclient 00_generated +macro_declare_executable(00_pubclient 00_generated common/src/ClientComponent.cpp common/src/ServiceComponent.cpp multiprocess/clientproc/src/main.cpp ) -macro_example_declare_runnable(00_pubservice 00_generated +macro_declare_executable(00_pubservice 00_generated common/src/ClientComponent.cpp common/src/ServiceComponent.cpp multiprocess/serviceproc/src/main.cpp ) -macro_example_declare_runnable(00_onethread 00_generated +macro_declare_executable(00_onethread 00_generated common/src/ClientComponent.cpp common/src/ServiceComponent.cpp onethread/src/main.cpp ) -macro_example_declare_runnable(00_twothreads 00_generated +macro_declare_executable(00_twothreads 00_generated common/src/ClientComponent.cpp common/src/ServiceComponent.cpp twothreads/src/main.cpp diff --git a/examples/01_hello/CMakeLists.txt b/examples/01_hello/CMakeLists.txt index e3886a9f..a0ec8100 100644 --- a/examples/01_hello/CMakeLists.txt +++ b/examples/01_hello/CMakeLists.txt @@ -1 +1 @@ -macro_example_declare_runnable(01_hello src/main.cpp) +macro_declare_executable(01_hello src/main.cpp) diff --git a/examples/02_buffer/CMakeLists.txt b/examples/02_buffer/CMakeLists.txt index 684b2e96..fde6d934 100644 --- a/examples/02_buffer/CMakeLists.txt +++ b/examples/02_buffer/CMakeLists.txt @@ -1 +1 @@ -macro_example_declare_runnable(02_buffer src/main.cpp) +macro_declare_executable(02_buffer src/main.cpp) diff --git a/examples/03_file/CMakeLists.txt b/examples/03_file/CMakeLists.txt index 247a9864..392ab732 100644 --- a/examples/03_file/CMakeLists.txt +++ b/examples/03_file/CMakeLists.txt @@ -1 +1 @@ -macro_example_declare_runnable(03_file src/main.cpp) +macro_declare_executable(03_file src/main.cpp) diff --git a/examples/04_trace/CMakeLists.txt b/examples/04_trace/CMakeLists.txt index 62dcf069..125879d3 100644 --- a/examples/04_trace/CMakeLists.txt +++ b/examples/04_trace/CMakeLists.txt @@ -1 +1 @@ -macro_example_declare_runnable(04_trace src/main.cpp) +macro_declare_executable(04_trace src/main.cpp) diff --git a/examples/05_timer/CMakeLists.txt b/examples/05_timer/CMakeLists.txt index 98327714..c26f8911 100644 --- a/examples/05_timer/CMakeLists.txt +++ b/examples/05_timer/CMakeLists.txt @@ -1 +1 @@ -macro_example_declare_runnable(05_timer src/main.cpp) +macro_declare_executable(05_timer src/main.cpp) diff --git a/examples/06_threads/CMakeLists.txt b/examples/06_threads/CMakeLists.txt index 521c7d86..ddcdeea4 100644 --- a/examples/06_threads/CMakeLists.txt +++ b/examples/06_threads/CMakeLists.txt @@ -1 +1 @@ -macro_example_declare_runnable(06_threads src/main.cpp) +macro_declare_executable(06_threads src/main.cpp) diff --git a/examples/07_synch/CMakeLists.txt b/examples/07_synch/CMakeLists.txt index d0942837..ca977c5b 100644 --- a/examples/07_synch/CMakeLists.txt +++ b/examples/07_synch/CMakeLists.txt @@ -1 +1 @@ -macro_example_declare_runnable(07_synch src/main.cpp) +macro_declare_executable(07_synch src/main.cpp) diff --git a/examples/08_service/CMakeLists.txt b/examples/08_service/CMakeLists.txt index d60ce977..03e436f5 100644 --- a/examples/08_service/CMakeLists.txt +++ b/examples/08_service/CMakeLists.txt @@ -1,4 +1,4 @@ -macro_example_declare_runnable(08_service +macro_declare_executable(08_service src/main.cpp src/ServicingComponent.cpp ) diff --git a/examples/09_svcmulti/CMakeLists.txt b/examples/09_svcmulti/CMakeLists.txt index 2fbf771f..54d36bbd 100644 --- a/examples/09_svcmulti/CMakeLists.txt +++ b/examples/09_svcmulti/CMakeLists.txt @@ -1,4 +1,4 @@ -macro_example_declare_runnable(09_svcmulti +macro_declare_executable(09_svcmulti src/main.cpp src/ServicingComponent.cpp ) diff --git a/examples/10_locsvc/CMakeLists.txt b/examples/10_locsvc/CMakeLists.txt index df82a411..214fc23d 100644 --- a/examples/10_locsvc/CMakeLists.txt +++ b/examples/10_locsvc/CMakeLists.txt @@ -3,7 +3,7 @@ addServiceInterface(10_generated res HelloWorld) # add project -macro_example_declare_runnable(10_locservice 10_generated +macro_declare_executable(10_locservice 10_generated locservice/src/main.cpp locservice/src/ServiceClient.cpp locservice/src/ServicingComponent.cpp diff --git a/examples/11_locmesh/CMakeLists.txt b/examples/11_locmesh/CMakeLists.txt index 4c1c4d46..01a3cc92 100644 --- a/examples/11_locmesh/CMakeLists.txt +++ b/examples/11_locmesh/CMakeLists.txt @@ -3,7 +3,7 @@ addServiceInterface(11_generated res HelloWorld) # add project -macro_example_declare_runnable(11_locmesh 11_generated +macro_declare_executable(11_locmesh 11_generated locsvcmesh/src/ClientComponent.cpp locsvcmesh/src/ServiceClient.cpp locsvcmesh/src/ServiceHelloWorld.cpp diff --git a/examples/12_pubsvc/CMakeLists.txt b/examples/12_pubsvc/CMakeLists.txt index f8b171a6..1901a690 100644 --- a/examples/12_pubsvc/CMakeLists.txt +++ b/examples/12_pubsvc/CMakeLists.txt @@ -3,13 +3,13 @@ addServiceInterface(12_generated res HelloWorld) # add project -macro_example_declare_runnable(12_pubclient 12_generated +macro_declare_executable(12_pubclient 12_generated pubclient/src/main.cpp pubclient/src/ServiceClient.cpp ) # add project -macro_example_declare_runnable(12_pubservice 12_generated +macro_declare_executable(12_pubservice 12_generated pubservice/src/main.cpp pubservice/src/ServicingComponent.cpp ) diff --git a/examples/13_pubmesh/CMakeLists.txt b/examples/13_pubmesh/CMakeLists.txt index 0dad5b9e..6af24302 100644 --- a/examples/13_pubmesh/CMakeLists.txt +++ b/examples/13_pubmesh/CMakeLists.txt @@ -6,7 +6,7 @@ addServiceInterface(13_generated res SystemShutdown) # add projects # add static library -macro_example_declare_lib(13_common 13_generated +macro_declare_static_library(13_common 13_generated common/src/LocalHelloWorldClient.cpp common/src/LocalHelloWorldService.cpp common/src/PublicHelloWorldClient.cpp @@ -14,15 +14,15 @@ macro_example_declare_lib(13_common 13_generated ) # add examples -macro_example_declare_runnable(13_pubclients 13_generated 13_common +macro_declare_executable(13_pubclients 13_generated 13_common pubclients/src/main.cpp ) -macro_example_declare_runnable(13_pubservice 13_generated 13_common +macro_declare_executable(13_pubservice 13_generated 13_common pubservice/src/main.cpp pubservice/src/PublicServiceComponent.cpp ) -macro_example_declare_runnable(13_pubsvcmesh 13_generated 13_common +macro_declare_executable(13_pubsvcmesh 13_generated 13_common pubsvcmesh/src/main.cpp ) diff --git a/examples/14_pubtraffic/CMakeLists.txt b/examples/14_pubtraffic/CMakeLists.txt index 8140db64..eca182c3 100644 --- a/examples/14_pubtraffic/CMakeLists.txt +++ b/examples/14_pubtraffic/CMakeLists.txt @@ -3,12 +3,12 @@ addServiceInterface(14_generated res SimpleTrafficLight) # add projects -macro_example_declare_runnable(14_pubclient 14_generated +macro_declare_executable(14_pubclient 14_generated pubclient/src/main.cpp pubclient/src/TrafficLightClient.cpp ) -macro_example_declare_runnable(14_pubservice 14_generated +macro_declare_executable(14_pubservice 14_generated pubservice/src/main.cpp pubservice/src/TrafficLightService.cpp ) diff --git a/examples/15_pubworker/CMakeLists.txt b/examples/15_pubworker/CMakeLists.txt index 092856dd..3923eac8 100644 --- a/examples/15_pubworker/CMakeLists.txt +++ b/examples/15_pubworker/CMakeLists.txt @@ -3,13 +3,13 @@ addServiceInterface(15_generated res PatientInformation) # add projects -macro_example_declare_runnable(15_pubclient 15_generated +macro_declare_executable(15_pubclient 15_generated pubclient/src/HardwareWorkerConsumer.cpp pubclient/src/main.cpp pubclient/src/PatientClient.cpp ) -macro_example_declare_runnable(15_pubservice 15_generated +macro_declare_executable(15_pubservice 15_generated pubservice/src/main.cpp pubservice/src/PatientService.cpp pubservice/src/PatientServiceWorkerConsumer.cpp diff --git a/examples/16_pubfsm/CMakeLists.txt b/examples/16_pubfsm/CMakeLists.txt index 24599e82..94278ae2 100644 --- a/examples/16_pubfsm/CMakeLists.txt +++ b/examples/16_pubfsm/CMakeLists.txt @@ -4,12 +4,12 @@ addServiceInterface(16_generated res PowerManager) addServiceInterface(16_generated res TrafficController) # add projects -macro_example_declare_runnable(16_pubclient 16_generated +macro_declare_executable(16_pubclient 16_generated pubclient/src/main.cpp pubclient/src/TrafficLightClient.cpp ) -macro_example_declare_runnable(16_pubservice 16_generated +macro_declare_executable(16_pubservice 16_generated pubservice/src/IETrafficLightActionHandler.cpp pubservice/src/main.cpp pubservice/src/NETrafficLightFSM.cpp diff --git a/examples/17_winchat/CMakeLists.txt b/examples/17_winchat/CMakeLists.txt index 3e0d12d4..fc0d4f91 100644 --- a/examples/17_winchat/CMakeLists.txt +++ b/examples/17_winchat/CMakeLists.txt @@ -14,7 +14,8 @@ list(APPEND MFC_DEFINES _AFXDLL _BIND_TO_CURRENT_CRT_VERSION _BIND_TO_CURRENT_MF # #################################### # 'chatter' project -macro_example_declare_runnable(17_chatter 17_generated +macro_declare_executable(17_chatter + 17_generated chatter/res/stdafx.cpp chatter/res/chatter.rc @@ -40,9 +41,6 @@ macro_example_declare_runnable(17_chatter 17_generated chatter/ui/PageNetworkSetup.cpp ) -# Set resource files to compile with Microsoft RC compiler -set_source_files_properties(chatter/res/chatter.rc PROPERTIES LANGUAGE RC) - # Ensure Windows Subsystem and switch the entry point from main() method to 'wWinMainCRTStartup' implemented in MFC DLL. set_target_properties(17_chatter PROPERTIES WIN32_EXECUTABLE TRUE @@ -56,7 +54,7 @@ target_compile_options(17_chatter PRIVATE "${AREG_OPT_DISABLE_WARN_EXAMPLES}") # 'register' project -macro_example_declare_runnable(17_register 17_generated +macro_declare_executable(17_register 17_generated register/res/stdafx.cpp register/res/register.rc @@ -70,9 +68,6 @@ macro_example_declare_runnable(17_register 17_generated register/ui/PageConnections.cpp ) -# Set resource files to compile with Microsoft RC compiler -set_source_files_properties(register/res/register.rc PROPERTIES LANGUAGE RC) - # Ensure Windows Subsystem and switch the entry point from main() method to 'wWinMainCRTStartup' implemented in MFC DLL. set_target_properties(17_register PROPERTIES WIN32_EXECUTABLE TRUE diff --git a/examples/17_winchat/chatter/ui/PageMessaging.cpp b/examples/17_winchat/chatter/ui/PageMessaging.cpp index cc3ef0c3..0549d797 100644 --- a/examples/17_winchat/chatter/ui/PageMessaging.cpp +++ b/examples/17_winchat/chatter/ui/PageMessaging.cpp @@ -6,7 +6,6 @@ #include "chatter/services/CentralMessaging.hpp" #include "chatter/DistrbutedApp.hpp" #include "chatter/NEDistributedApp.hpp" -#include "generate/examples/17_winchat/NEConnectionManager.hpp" #include "areg/base/GEGlobal.h" #include "chatter/services/ConnectionHandler.hpp" diff --git a/examples/18_locwatchdog/CMakeLists.txt b/examples/18_locwatchdog/CMakeLists.txt index 76618c97..5d490f8c 100644 --- a/examples/18_locwatchdog/CMakeLists.txt +++ b/examples/18_locwatchdog/CMakeLists.txt @@ -2,7 +2,7 @@ addServiceInterface(18_generated res HelloWatchdog) # add project -macro_example_declare_runnable(18_locservice 18_generated +macro_declare_executable(18_locservice 18_generated locservice/src/main.cpp locservice/src/ServicingComponent.cpp locservice/src/ServiceClient.cpp diff --git a/examples/19_pubwatchdog/CMakeLists.txt b/examples/19_pubwatchdog/CMakeLists.txt index 30f8f5ca..76ec78bd 100644 --- a/examples/19_pubwatchdog/CMakeLists.txt +++ b/examples/19_pubwatchdog/CMakeLists.txt @@ -3,12 +3,12 @@ addServiceInterface(19_generated res HelloWatchdog) # add projects -macro_example_declare_runnable(19_pubclient 19_generated +macro_declare_executable(19_pubclient 19_generated pubclient/src/main.cpp pubclient/src/ServiceClient.cpp ) -macro_example_declare_runnable(19_pubservice 19_generated +macro_declare_executable(19_pubservice 19_generated pubservice/src/main.cpp pubservice/src/ServicingComponent.cpp ) diff --git a/examples/20_pubdatarate/CMakeLists.txt b/examples/20_pubdatarate/CMakeLists.txt index 6cd1fdc1..cbdb6dd2 100644 --- a/examples/20_pubdatarate/CMakeLists.txt +++ b/examples/20_pubdatarate/CMakeLists.txt @@ -2,12 +2,12 @@ addServiceInterface(20_generated res LargeData) # add projects -macro_example_declare_runnable(20_pubclient 20_generated +macro_declare_executable(20_pubclient 20_generated pubclient/src/main.cpp pubclient/src/ServiceClient.cpp ) -macro_example_declare_runnable(20_pubservice 20_generated +macro_declare_executable(20_pubservice 20_generated pubservice/src/main.cpp pubservice/src/NEUtilities.cpp pubservice/src/ServicingComponent.cpp diff --git a/examples/21_pubunblock/CMakeLists.txt b/examples/21_pubunblock/CMakeLists.txt index b9644f9d..16c4f723 100644 --- a/examples/21_pubunblock/CMakeLists.txt +++ b/examples/21_pubunblock/CMakeLists.txt @@ -2,12 +2,12 @@ addServiceInterface(21_generated res HelloUnblock) # add projects -macro_example_declare_runnable(21_pubclient 21_generated +macro_declare_executable(21_pubclient 21_generated pubclient/src/main.cpp pubclient/src/ServiceClient.cpp ) -macro_example_declare_runnable(21_pubservice 21_generated +macro_declare_executable(21_pubservice 21_generated pubservice/src/main.cpp pubservice/src/ServiceComponent.cpp ) diff --git a/examples/22_pubsub/CMakeLists.txt b/examples/22_pubsub/CMakeLists.txt index 501d754c..6403b6ab 100644 --- a/examples/22_pubsub/CMakeLists.txt +++ b/examples/22_pubsub/CMakeLists.txt @@ -2,12 +2,12 @@ addServiceInterface(22_generated res PubSub) # add projects -macro_example_declare_runnable(22_publisher 22_generated +macro_declare_executable(22_publisher 22_generated publisher/src/main.cpp publisher/src/Publisher.cpp ) -macro_example_declare_runnable(22_subscriber 22_generated +macro_declare_executable(22_subscriber 22_generated subscriber/src/main.cpp subscriber/src/Subscriber.cpp ) diff --git a/examples/23_pubsubmix/CMakeLists.txt b/examples/23_pubsubmix/CMakeLists.txt index 951f4f19..cc3c97a5 100644 --- a/examples/23_pubsubmix/CMakeLists.txt +++ b/examples/23_pubsubmix/CMakeLists.txt @@ -5,7 +5,7 @@ addServiceInterface(23_generated res PubSubMix) # add projects # add static library -macro_example_declare_lib(23_common 23_generated +macro_declare_static_library(23_common 23_generated common/src/NECommon.cpp common/src/Publisher.cpp common/src/PubSubMixed.cpp @@ -13,11 +13,11 @@ macro_example_declare_lib(23_common 23_generated ) # add examples -macro_example_declare_runnable(23_pubsubctrl 23_generated 23_common +macro_declare_executable(23_pubsubctrl 23_generated 23_common pubsubctrl/src/main.cpp pubsubctrl/src/PubSubController.cpp ) -macro_example_declare_runnable(23_pubsubdyn 23_generated 23_common +macro_declare_executable(23_pubsubdyn 23_generated 23_common pubsubdyn/src/main.cpp ) diff --git a/examples/24_pubsubmulti/CMakeLists.txt b/examples/24_pubsubmulti/CMakeLists.txt index 0b106ecd..87b7afc6 100644 --- a/examples/24_pubsubmulti/CMakeLists.txt +++ b/examples/24_pubsubmulti/CMakeLists.txt @@ -3,12 +3,12 @@ addServiceInterface(24_generated res PubSub) # add projects -macro_example_declare_runnable(24_publisher 24_generated +macro_declare_executable(24_publisher 24_generated publisher/src/main.cpp publisher/src/Publisher.cpp ) -macro_example_declare_runnable(24_subscribermulti 24_generated +macro_declare_executable(24_subscribermulti 24_generated subscribermulti/src/main.cpp subscribermulti/src/Subscriber.cpp subscribermulti/src/SubscriberBase.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b0cbdcce..c8b45ee3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,70 +3,6 @@ # Copyright 2022-2023 Aregtech # ########################################################################### -# ########################################################################### -# CMake functions for examples -# ########################################################################### - -# --------------------------------------------------------------------------- -# Description : Collects sources, dependent libraries and declares a static -# library to use in examples. -# Parameters .: ${lib_name} -- Name of the static library to create. -# ${ARGN} -- The list of libraries or source code files. -# Macro ......: macro_example_declare_lib -# Usage ......: macro_example_declare_lib( ) -# Example ....: macro_example_declare_lib(13_common 13_generated common/src/HelloWorldClient.cpp common/src/HelloWorldService.cpp) -# See ........: as a use, see examples #13 and 23 -# --------------------------------------------------------------------------- -macro(macro_example_declare_lib lib_name) - set(_sources) - set(_libs) - set(_list "${ARGN}") - foreach(item IN LISTS _list) - if (TARGET ${item}) - list(APPEND _libs ${item}) - elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${item}") - list(APPEND _sources "${CMAKE_CURRENT_LIST_DIR}/${item}") - elseif(EXISTS "${item}") - list(APPEND _sources "${item}") - else() - message(WARNING "AREG Examples: >>> The item \'${item}\' of target \'${example_name}\' has unknown type, ignored.") - endif() - endforeach() - addStaticLibEx(${lib_name} "" "${_sources}" "${_libs}") - unset(_list) - unset(_sources) - unset(_libs) -endmacro(macro_example_declare_lib) - -# --------------------------------------------------------------------------- -# Description : Collects sources, dependent libraries and declares an executable. -# Parameters .: ${example_name} -- Name of the executable to create. -# ${ARGN} -- The list of libraries or source code files. -# Macro ......: macro_example_declare_runnable -# Usage ......: macro_example_declare_runnable( ) -# Example ....: macro_example_declare_runnable(01_hello src/main.cpp) -# --------------------------------------------------------------------------- -macro(macro_example_declare_runnable example_name) - set(_sources) - set(_libs) - set(_list "${ARGN}") - foreach(item IN LISTS _list) - if (TARGET ${item}) - list(APPEND _libs ${item}) - elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${item}") - list(APPEND _sources "${CMAKE_CURRENT_LIST_DIR}/${item}") - elseif(EXISTS "${item}") - list(APPEND _sources "${item}") - else() - message(WARNING "AREG Examples: >>> The item \'${item}\' of target \'${example_name}\' has unknown type, ignored.") - endif() - endforeach() - addExecutableEx(${example_name} "" "${_sources}" "${_libs}") - unset(_list) - unset(_sources) - unset(_libs) -endmacro(macro_example_declare_runnable) - # ########################################################################### # List of examples to build # ###########################################################################