Retrieving core name and version from CMakeLists.txt and use it in GenericCore::toString().

This commit is contained in:
2025-10-03 11:15:06 +02:00
parent b631f4200e
commit 7ec346b5a5
3 changed files with 11 additions and 1 deletions

View File

@ -12,6 +12,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools)
configure_file(CoreConfig.h.in CoreConfig.h)
set(TS_FILES ${TARGET_APP}_en_US.ts)
add_library(${TARGET_APP} STATIC
@ -20,6 +22,8 @@ add_library(${TARGET_APP} STATIC
${TS_FILES}
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(${TARGET_APP} PRIVATE Qt${QT_VERSION_MAJOR}::Core)
target_compile_definitions(${TARGET_APP} PRIVATE ${TARGET_APP}_LIBRARY)

2
CoreConfig.h.in Normal file
View File

@ -0,0 +1,2 @@
#define CORE_NAME "${PROJECT_NAME}"
#define CORE_VERSION "${PROJECT_VERSION}"

View File

@ -3,12 +3,16 @@
#include <QDebug>
#include <QString>
#include "CoreConfig.h"
using namespace std;
GenericCore::GenericCore() { qDebug() << "Creating core..."; }
GenericCore::~GenericCore() { qDebug() << "Destroying core..."; }
QString GenericCore::toString() const { return QString("GenericCore (Version x.y.z)"); }
QString GenericCore::toString() const {
return QString("%1 (Version %2)").arg(CORE_NAME).arg(CORE_VERSION);
}
void GenericCore::sayHello() const { qDebug() << "Hello from the core!"; }