Show version of used libraries in --help
* Include only own libraries and Qt 5 modules so far * First step to implement https://github.com/Martchus/tageditor/issues/13
This commit is contained in:
parent
bfa12a9870
commit
91e5a8b0b0
|
@ -265,6 +265,8 @@ const char *applicationAuthor = nullptr;
|
|||
const char *applicationVersion = nullptr;
|
||||
/// \brief Specifies the URL to the application website (used by ArgumentParser::printHelp()).
|
||||
const char *applicationUrl = nullptr;
|
||||
/// \brief Specifies the dependency versions the application was linked against (used by ArgumentParser::printHelp()).
|
||||
std::initializer_list<const char *> dependencyVersions;
|
||||
|
||||
/*!
|
||||
* \brief Specifies a function quit the application.
|
||||
|
@ -603,7 +605,18 @@ void ArgumentParser::printHelp(ostream &os) const
|
|||
if(applicationVersion && *applicationVersion) {
|
||||
os << "version " << applicationVersion;
|
||||
}
|
||||
if((applicationName && *applicationName) || (applicationVersion && *applicationVersion)) {
|
||||
if(dependencyVersions.size()) {
|
||||
if((applicationName && *applicationName) || (applicationVersion && *applicationVersion)) {
|
||||
os << '\n';
|
||||
EscapeCodes::setStyle(os);
|
||||
}
|
||||
auto i = dependencyVersions.begin(), end = dependencyVersions.end();
|
||||
os << "Linked against: " << *i;
|
||||
for(++i; i != end; ++i) {
|
||||
os << ',' << ' ' << *i;
|
||||
}
|
||||
}
|
||||
if((applicationName && *applicationName) || (applicationVersion && *applicationVersion) || dependencyVersions.size()) {
|
||||
os << '\n' << '\n';
|
||||
}
|
||||
EscapeCodes::setStyle(os);
|
||||
|
|
|
@ -18,17 +18,33 @@ CPP_UTILITIES_EXPORT extern const char *applicationName;
|
|||
CPP_UTILITIES_EXPORT extern const char *applicationAuthor;
|
||||
CPP_UTILITIES_EXPORT extern const char *applicationVersion;
|
||||
CPP_UTILITIES_EXPORT extern const char *applicationUrl;
|
||||
CPP_UTILITIES_EXPORT extern std::initializer_list<const char *> dependencyVersions;
|
||||
|
||||
/*!
|
||||
* \macro SET_DEPENDENCY_INFO
|
||||
* \brief Sets meta data about the dependencies the application was linked against which is
|
||||
* used by ArgumentParser::printHelp().
|
||||
* \remarks Reads those data from the config header so "config.h" must be included.
|
||||
*/
|
||||
#ifndef APP_STATICALLY_LINKED
|
||||
#define SET_DEPENDENCY_INFO \
|
||||
::ApplicationUtilities::dependencyVersions = DEPENCENCY_VERSIONS
|
||||
#else
|
||||
#define SET_DEPENDENCY_INFO \
|
||||
::ApplicationUtilities::dependencyVersions = STATIC_DEPENCENCY_VERSIONS
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \macro SET_APPLICATION_INFO
|
||||
* \brief Sets application meta data used by ArgumentParser::printHelp().
|
||||
* \brief Sets application meta data (including SET_DEPENDENCY_INFO) used by ArgumentParser::printHelp().
|
||||
* \remarks Reads those data from the config header so "config.h" must be included.
|
||||
*/
|
||||
#define SET_APPLICATION_INFO \
|
||||
::ApplicationUtilities::applicationName = APP_NAME; \
|
||||
::ApplicationUtilities::applicationAuthor = APP_AUTHOR; \
|
||||
::ApplicationUtilities::applicationVersion = APP_VERSION; \
|
||||
::ApplicationUtilities::applicationUrl = APP_URL
|
||||
::ApplicationUtilities::applicationUrl = APP_URL; \
|
||||
SET_DEPENDENCY_INFO \
|
||||
|
||||
CPP_UTILITIES_EXPORT extern void(*exitFunction)(int);
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ if(NOT META_PUBLIC_SHARED_LIB_COMPILE_DEFINITIONS)
|
|||
endif()
|
||||
if(NOT META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS)
|
||||
set(META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS ${META_PRIVATE_COMPILE_DEFINITIONS} ${META_ADDITIONAL_PRIVATE_SHARED_COMPILE_DEFINITIONS})
|
||||
if(STATIC_LINKAGE)
|
||||
list(APPEND META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS APP_STATICALLY_LINKED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# set linker flags
|
||||
|
@ -41,6 +44,7 @@ target_compile_definitions(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX}
|
|||
PRIVATE "${META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS}"
|
||||
)
|
||||
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} PROPERTIES
|
||||
APP_NAME "${META_APP_NAME}"
|
||||
CXX_STANDARD "${META_CXX_STANDARD}"
|
||||
LINK_SEARCH_START_STATIC ${STATIC_LINKAGE}
|
||||
LINK_SEARCH_END_STATIC ${STATIC_LINKAGE}
|
||||
|
|
|
@ -9,6 +9,35 @@ endif()
|
|||
include(TemplateFinder)
|
||||
find_template_file("config.h" CPP_UTILITIES CONFIG_H_TEMPLATE_FILE)
|
||||
|
||||
# create list of dependency versions present at link time
|
||||
include(ListToString)
|
||||
foreach(LINKAGE IN ITEMS "" "STATIC_")
|
||||
unset(DEPENCENCY_VERSIONS)
|
||||
unset(${LINKAGE}DEPENCENCY_VERSIONS_ARRAY)
|
||||
foreach(DEPENDENCY IN LISTS PUBLIC_${LINKAGE}LIBRARIES PRIVATE_${LINKAGE}LIBRARIES)
|
||||
if(TARGET ${DEPENDENCY})
|
||||
string(SUBSTRING "${DEPENDENCY}" 0 5 DEPENDENCY_PREFIX)
|
||||
if("${DEPENDENCY_PREFIX}" STREQUAL "Qt5::")
|
||||
string(SUBSTRING "${DEPENDENCY}" 5 -1 DEPENDENCY_MODULE_NAME)
|
||||
set(DEPENDENCY "Qt ${DEPENDENCY_MODULE_NAME}")
|
||||
set(DEPENDENCY_VER "${Qt5${DEPENDENCY_MODULE_NAME}_VERSION_STRING}")
|
||||
else()
|
||||
get_target_property(DEPENDENCY_APP_NAME "${DEPENDENCY}" APP_NAME)
|
||||
get_target_property(DEPENDENCY_VER "${DEPENDENCY}" VERSION)
|
||||
if(DEPENDENCY_APP_NAME AND NOT "${DEPENDENCY_APP_NAME}" STREQUAL "DEPENDENCY_APP_NAME-NOTFOUND")
|
||||
set(DEPENDENCY "${DEPENDENCY_APP_NAME}")
|
||||
endif()
|
||||
endif()
|
||||
if(DEPENDENCY_VER AND NOT "${DEPENDENCY_VER}" STREQUAL "DEPENDENCY_VER-NOTFOUND")
|
||||
list(APPEND DEPENCENCY_VERSIONS "${DEPENDENCY}: ${DEPENDENCY_VER}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
if(DEPENCENCY_VERSIONS)
|
||||
list_to_string("," " \\\n \"" "\"" "${DEPENCENCY_VERSIONS}" ${LINKAGE}DEPENCENCY_VERSIONS_ARRAY)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# add configuration header
|
||||
configure_file(
|
||||
"${CONFIG_H_TEMPLATE_FILE}"
|
||||
|
|
|
@ -134,6 +134,7 @@ if(BUILD_SHARED_LIBS)
|
|||
PRIVATE "${META_PRIVATE_SHARED_LIB_COMPILE_DEFINITIONS}"
|
||||
)
|
||||
set_target_properties(${TARGET_PREFIX}${META_PROJECT_NAME}${TARGET_SUFFIX} PROPERTIES
|
||||
APP_NAME "${META_APP_NAME}"
|
||||
VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}"
|
||||
SOVERSION "${META_SOVERSION}"
|
||||
CXX_STANDARD "${META_CXX_STANDARD}"
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#define QT_TRANSLATION_FILES {@QT_TRANSLATION_FILES_ARRAY@}
|
||||
#define APP_SPECIFIC_QT_TRANSLATION_FILES {@APP_SPECIFIC_QT_TRANSLATION_FILES_ARRAY@}
|
||||
#define ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES@ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES@
|
||||
#define DEPENCENCY_VERSIONS {@DEPENCENCY_VERSIONS_ARRAY@}
|
||||
#define STATIC_DEPENCENCY_VERSIONS {@STATIC_DEPENCENCY_VERSIONS_ARRAY@}
|
||||
#cmakedefine SVG_SUPPORT
|
||||
#cmakedefine SVG_ICON_SUPPORT
|
||||
|
||||
|
|
Loading…
Reference in New Issue