From 9e1f686ba6e6327742d91b51eb4695736084006d Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Thu, 20 Jul 2023 15:57:41 +1000 Subject: [PATCH] Added an optional argument to the ADD_ACTION macro that defines the class from which the action class is derived. --- include/actiondep.h | 6 +++--- src/CMakeLists.txt | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/actiondep.h b/include/actiondep.h index 4f2a8cc..eb3978b 100644 --- a/include/actiondep.h +++ b/include/actiondep.h @@ -9,10 +9,10 @@ using michlib::MDateTime; #if defined GENACTIONLIST -#define ADD_ACTION(actclass, actname, suptest) ADD ACTION CLASS: actclass +#define ADD_ACTION(actclass, actname, suptest, ...) ADD ACTION CLASS: actclass #else -#define ADD_ACTION(actclass, actname, suptest) \ - class Action##actclass \ +#define ADD_ACTION(actclass, actname, suptest, ...) \ + class Action##actclass __VA_OPT__( : public) __VA_ARGS__ \ { \ public: \ static constexpr const char* name = #actname; \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 367813b..79fec9a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,6 +37,10 @@ string(REPLACE ";" "," actclist "${actlist}") file(WRITE ${ACTIONLISTINC} "#define ACTLIST ${actclist}\n") foreach(actfile ${actfilelist}) + string(REGEX REPLACE "\.h$" ".cpp" actcpp "${actfile}") + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${actcpp} ) + target_sources(${EXENAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${actcpp}) + endif() file(APPEND ${ACTIONLISTINC} "#include \"${actfile}\"\n") endforeach(actfile) # End generation of actions list