Merge branch 'master' of gitlab.2:f1x1t/myxlib
This commit is contained in:
commit
bba3eff05a
@ -35,21 +35,24 @@ pkg_check_modules(SPDLOG spdlog>=1.3.1)
|
|||||||
# Автоматически генерируемый заголовочный файл
|
# Автоматически генерируемый заголовочный файл
|
||||||
cmlib_config_hpp_generate()
|
cmlib_config_hpp_generate()
|
||||||
|
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/src/base/config_flags.hpp.in
|
configure_file(${CMAKE_SOURCE_DIR}/src/myx/base/config_flags.hpp.in
|
||||||
${CMAKE_BINARY_DIR}/include/config_flags.hpp)
|
${CMAKE_BINARY_DIR}/include/config_flags.hpp)
|
||||||
|
|
||||||
# Подключение внешних проектов
|
# Подключение внешних проектов
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
# Библиотеки
|
# Библиотеки
|
||||||
add_subdirectory(src/base)
|
add_subdirectory(src/myx/base)
|
||||||
add_subdirectory(src/filesystem)
|
add_subdirectory(src/myx/filesystem)
|
||||||
add_subdirectory(src/log)
|
add_subdirectory(src/myx/log)
|
||||||
|
add_subdirectory(src/myx/qt)
|
||||||
|
add_subdirectory(doc)
|
||||||
|
|
||||||
# Примеры
|
# Примеры
|
||||||
if (BUILD_EXAMPLES)
|
if (BUILD_EXAMPLES)
|
||||||
add_subdirectory(examples/filesystem)
|
add_subdirectory(examples/filesystem)
|
||||||
add_subdirectory(examples/log)
|
add_subdirectory(examples/log)
|
||||||
|
add_subdirectory(examples/qt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(doc)
|
add_subdirectory(doc)
|
||||||
|
@ -8,7 +8,7 @@ set(current_target_sources
|
|||||||
|
|
||||||
# Путь поиска библиотек внутри проекта
|
# Путь поиска библиотек внутри проекта
|
||||||
link_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
link_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||||
link_directories(${CMAKE_BINARY_DIR}/src/filesystem/lib)
|
link_directories(${CMAKE_BINARY_DIR}/src/myx/filesystem/lib)
|
||||||
|
|
||||||
# Цель для создания исполняемого файла
|
# Цель для создания исполняемого файла
|
||||||
add_executable(${current_target} ${current_target_sources})
|
add_executable(${current_target} ${current_target_sources})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "filesystem/paths.hpp"
|
#include <myx/filesystem/paths.hpp>
|
||||||
|
|
||||||
namespace MF = myx::filesystem;
|
namespace MF = myx::filesystem;
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ int main( int argc, char** argv )
|
|||||||
MF::Paths paths;
|
MF::Paths paths;
|
||||||
|
|
||||||
paths.updatePaths();
|
paths.updatePaths();
|
||||||
paths.makePaths();
|
paths.makeDefaultDirectories();
|
||||||
paths.findConfigFile( "test" );
|
paths.findConfigFile( "test" );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
@ -7,8 +7,8 @@ set(current_target_sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Путь поиска библиотек внутри проекта
|
# Путь поиска библиотек внутри проекта
|
||||||
link_directories(${CMAKE_INSTALL_LIBDIR})
|
link_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||||
link_directories(${CMAKE_BINARY_DIR}/src/log/lib)
|
link_directories(${CMAKE_BINARY_DIR}/src/myx/log/lib)
|
||||||
|
|
||||||
# Цель для создания исполняемого файла
|
# Цель для создания исполняемого файла
|
||||||
add_executable(${current_target} ${current_target_sources})
|
add_executable(${current_target} ${current_target_sources})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "log/spdlog.hpp"
|
#include <myx/log/spdlog.hpp>
|
||||||
|
|
||||||
namespace ML = myx::log;
|
namespace ML = myx::log;
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ set(current_target_sources
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Путь поиска библиотек внутри проекта
|
# Путь поиска библиотек внутри проекта
|
||||||
link_directories(${CMAKE_INSTALL_LIBDIR})
|
link_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||||
link_directories(${CMAKE_BINARY_DIR}/src/log/lib)
|
link_directories(${CMAKE_BINARY_DIR}/src/myx/log/lib)
|
||||||
|
|
||||||
# Цель для создания исполняемого файла
|
# Цель для создания исполняемого файла
|
||||||
add_executable(${current_target} ${current_target_sources})
|
add_executable(${current_target} ${current_target_sources})
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "log/spdlog.hpp"
|
#include <myx/log/spdlog.hpp>
|
||||||
#include "log/spdlog_qt.hpp"
|
#include <myx/log/spdlog_qt.hpp>
|
||||||
|
|
||||||
namespace ML = myx::log;
|
namespace ML = myx::log;
|
||||||
|
|
||||||
|
48
examples/qt/01_translators/CMakeLists.txt
Normal file
48
examples/qt/01_translators/CMakeLists.txt
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Название основной цели в текущем каталоге
|
||||||
|
set(current_target example-qt-translators)
|
||||||
|
|
||||||
|
# Список файлов исходных текстов
|
||||||
|
set(current_target_sources
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/translators.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Путь поиска библиотек внутри проекта
|
||||||
|
link_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||||
|
link_directories(${CMAKE_BINARY_DIR}/src/myx/qt/lib)
|
||||||
|
|
||||||
|
# Цель для создания исполняемого файла
|
||||||
|
add_executable(${current_target} ${current_target_sources})
|
||||||
|
common_target_properties(${current_target})
|
||||||
|
add_clang_tidy_check(${current_target} ${current_target_sources})
|
||||||
|
add_clang_analyze_check(${current_target} ${current_target_sources})
|
||||||
|
add_clazy_check(${current_target} ${current_target_sources})
|
||||||
|
add_uncrustify_format(${current_target} ${current_target_sources})
|
||||||
|
add_pvs_check(${current_target})
|
||||||
|
|
||||||
|
add_dependencies(${current_target} base)
|
||||||
|
add_dependencies(${current_target} qt)
|
||||||
|
|
||||||
|
# Qt5
|
||||||
|
qt_translation(TARGET ${current_target} TS_DIR ${CMAKE_SOURCE_DIR}/l10n LANGUAGES ru_RU)
|
||||||
|
target_include_directories(${current_target} PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
||||||
|
target_include_directories(${current_target} SYSTEM PUBLIC ${FMT_INCLUDE_DIRS})
|
||||||
|
target_include_directories(${current_target} SYSTEM PUBLIC ${SPDLOG_INCLUDE_DIRS})
|
||||||
|
target_include_directories(${current_target} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
|
||||||
|
target_compile_options(${current_target} PUBLIC "${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
|
||||||
|
|
||||||
|
target_link_libraries(${current_target} myx-qt)
|
||||||
|
target_link_libraries(${current_target} Qt5::Core)
|
||||||
|
|
||||||
|
# Имя выходного файла для цели
|
||||||
|
set_target_properties(${current_target}
|
||||||
|
PROPERTIES
|
||||||
|
OUTPUT_NAME qt-translators
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_sanitizers(${current_target})
|
||||||
|
|
||||||
|
# cotire(${current_target})
|
||||||
|
|
||||||
|
# Правила для установки
|
||||||
|
install(TARGETS ${current_target} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
19
examples/qt/01_translators/translators.cpp
Normal file
19
examples/qt/01_translators/translators.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include <myx/qt/translators.hpp>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
namespace MQ = myx::qt;
|
||||||
|
|
||||||
|
|
||||||
|
int main( int argc, char** argv )
|
||||||
|
{
|
||||||
|
QCoreApplication app( argc, argv );
|
||||||
|
MQ::QTranslatorsList tl;
|
||||||
|
|
||||||
|
qDebug() << QObject::tr( "Yes" );
|
||||||
|
MQ::append_translators( tl, "example-qt-translators" );
|
||||||
|
qDebug() << QObject::tr( "Yes" );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
2
examples/qt/CMakeLists.txt
Normal file
2
examples/qt/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
add_subdirectory(01_translators)
|
||||||
|
|
17
l10n/example-qt-translators_ru_RU.ts
Normal file
17
l10n/example-qt-translators_ru_RU.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="ru_RU">
|
||||||
|
<context>
|
||||||
|
<name>QObject</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../examples/qt/01_translators/translators.cpp" line="16"/>
|
||||||
|
<source>Yes</source>
|
||||||
|
<translation>Да</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../examples/qt/01_translators/translators.cpp" line="18"/>
|
||||||
|
<source>Cancel</source>
|
||||||
|
<translation>Отмена</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
@ -1,25 +0,0 @@
|
|||||||
#ifndef MYX_BASE_CONFIG_HPP_
|
|
||||||
#define MYX_BASE_CONFIG_HPP_
|
|
||||||
|
|
||||||
#include "cmlib_config.hpp"
|
|
||||||
#include "config_flags.hpp"
|
|
||||||
|
|
||||||
#if ( defined ( TARGET_LSB_ID_AstraLinuxSE ) && defined ( TARGET_LSB_CODENAME_smolensk ) )
|
|
||||||
|
|
||||||
#define override
|
|
||||||
|
|
||||||
#if QT_VERSION <= 0x050700
|
|
||||||
#include <QtGlobal>
|
|
||||||
template< typename ... Args >
|
|
||||||
struct QOverload
|
|
||||||
{
|
|
||||||
template< typename C, typename R >
|
|
||||||
static constexpr auto of( R ( C::* pmf )( Args... ) )->decltype( pmf )
|
|
||||||
{
|
|
||||||
return( pmf );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // MYX_BASE_CONFIG_HPP_
|
|
7
src/myx/base/config.hpp
Normal file
7
src/myx/base/config.hpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef MYX_BASE_CONFIG_HPP_
|
||||||
|
#define MYX_BASE_CONFIG_HPP_
|
||||||
|
|
||||||
|
#include "cmlib_config.hpp"
|
||||||
|
#include "config_flags.hpp"
|
||||||
|
|
||||||
|
#endif // MYX_BASE_CONFIG_HPP_
|
@ -27,7 +27,7 @@ add_uncrustify_format(${current_target} ${current_target_sources} ${current_targ
|
|||||||
target_include_directories(${current_target} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
|
target_include_directories(${current_target} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
|
||||||
target_include_directories(${current_target} SYSTEM PUBLIC ${FMT_INCLUDE_DIRS})
|
target_include_directories(${current_target} SYSTEM PUBLIC ${FMT_INCLUDE_DIRS})
|
||||||
target_include_directories(${current_target} SYSTEM PUBLIC ${SPDLOG_INCLUDE_DIRS})
|
target_include_directories(${current_target} SYSTEM PUBLIC ${SPDLOG_INCLUDE_DIRS})
|
||||||
target_include_directories(${current_target} PRIVATE ${CMAKE_SOURCE_DIR}/src/base)
|
target_include_directories(${current_target} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
||||||
target_include_directories(${current_target} PRIVATE ${CMAKE_BINARY_DIR}/include)
|
target_include_directories(${current_target} PRIVATE ${CMAKE_BINARY_DIR}/include)
|
||||||
|
|
||||||
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
|
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
|
@ -1,9 +1,11 @@
|
|||||||
#include "paths.hpp"
|
#include "paths.hpp"
|
||||||
#include "config.hpp"
|
|
||||||
|
#include <myx/base/config.hpp>
|
||||||
#include "whereami++.h"
|
#include "whereami++.h"
|
||||||
|
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
namespace myx {
|
namespace myx {
|
||||||
|
|
||||||
@ -57,19 +59,22 @@ void Paths::setConfigFilePath( const QFileInfo& configFilePath )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Paths::Paths() :
|
Paths::Paths()
|
||||||
m_prefixDirectory( "/opt/" ORGANIZATION_NAME_LOWER "/" PROJECT_NAME_LOWER ),
|
|
||||||
m_binaryDirectory( m_prefixDirectory.absolutePath() + "/bin" ),
|
|
||||||
m_configDirectory( m_prefixDirectory.absolutePath() + "/etc" ),
|
|
||||||
m_cacheDirectory( m_prefixDirectory.absolutePath() + "/var" ),
|
|
||||||
m_tempDirectory( QString::fromLocal8Bit( qgetenv( qPrintable( "TMPDIR" ) ) ) ),
|
|
||||||
m_dataDirectory( m_prefixDirectory.absolutePath() + "/share" ),
|
|
||||||
m_homeDirectory( QString::fromLocal8Bit( qgetenv( qPrintable( "HOME" ) ) ) ),
|
|
||||||
m_executableFileName( PROJECT_NAME_LOWER ),
|
|
||||||
m_configFileName( PROJECT_NAME_LOWER ".conf" ),
|
|
||||||
m_executableFilePath( m_binaryDirectory.absolutePath() + "/" + m_executableFileName ),
|
|
||||||
m_configFilePath( m_binaryDirectory.absolutePath() + "/" + m_configFileName )
|
|
||||||
{
|
{
|
||||||
|
m_prefixDirectory = "/opt/" + QCoreApplication::organizationName().toLower() +
|
||||||
|
"/" + QCoreApplication::applicationName().toLower();
|
||||||
|
m_binaryDirectory = m_prefixDirectory.absolutePath() + "/bin";
|
||||||
|
m_configDirectory = m_prefixDirectory.absolutePath() + "/etc";
|
||||||
|
m_cacheDirectory = m_prefixDirectory.absolutePath() + "/var";
|
||||||
|
m_tempDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "TMPDIR" ) ) );
|
||||||
|
m_dataDirectory = m_prefixDirectory.absolutePath() + "/share";
|
||||||
|
m_homeDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "HOME" ) ) );
|
||||||
|
m_executableFileName = QCoreApplication::applicationName().toLower();
|
||||||
|
m_configFileName = m_executableFileName + ".conf";
|
||||||
|
m_executableFilePath = m_binaryDirectory.absolutePath() + "/" + m_executableFileName;
|
||||||
|
m_configFilePath = m_binaryDirectory.absolutePath() + "/" + m_configFileName;
|
||||||
|
|
||||||
|
|
||||||
if ( m_tempDirectory.absolutePath().isEmpty() || ( m_tempDirectory.path() == "." ) )
|
if ( m_tempDirectory.absolutePath().isEmpty() || ( m_tempDirectory.path() == "." ) )
|
||||||
{
|
{
|
||||||
m_tempDirectory = _PATH_TMP;
|
m_tempDirectory = _PATH_TMP;
|
||||||
@ -163,7 +168,8 @@ bool Paths::updatePaths()
|
|||||||
m_configDirectory = m_prefixDirectory.absolutePath() + "/etc";
|
m_configDirectory = m_prefixDirectory.absolutePath() + "/etc";
|
||||||
m_cacheDirectory = m_prefixDirectory.absolutePath() + "/var";
|
m_cacheDirectory = m_prefixDirectory.absolutePath() + "/var";
|
||||||
m_dataDirectory = m_prefixDirectory.absolutePath() + "/share";
|
m_dataDirectory = m_prefixDirectory.absolutePath() + "/share";
|
||||||
m_configFilePath = QFile( m_configDirectory.absolutePath() + "/" + PROJECT_NAME_LOWER + ".conf" );
|
m_configFilePath = QFile( m_configDirectory.absolutePath() + "/" +
|
||||||
|
QCoreApplication::applicationName() + ".conf" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_prefixDirectory.absolutePath().startsWith( "/opt" ) ||
|
if ( m_prefixDirectory.absolutePath().startsWith( "/opt" ) ||
|
||||||
@ -172,30 +178,36 @@ bool Paths::updatePaths()
|
|||||||
QString dataDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "XDG_DATA_HOME" ) ) );
|
QString dataDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "XDG_DATA_HOME" ) ) );
|
||||||
if ( dataDirectory.isEmpty() )
|
if ( dataDirectory.isEmpty() )
|
||||||
{
|
{
|
||||||
dataDirectory = m_homeDirectory.absolutePath() + ".local/share/";
|
dataDirectory = m_homeDirectory.absolutePath() + ".local/share";
|
||||||
}
|
}
|
||||||
m_dataDirectory = dataDirectory + ORGANIZATION_NAME_LOWER + "/" + PROJECT_NAME_LOWER;
|
m_dataDirectory = dataDirectory + "/" +
|
||||||
|
QCoreApplication::organizationName().toLower() + "/" +
|
||||||
|
QCoreApplication::applicationName().toLower();
|
||||||
|
|
||||||
QString configDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "XDG_CONFIG_HOME" ) ) );
|
QString configDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "XDG_CONFIG_HOME" ) ) );
|
||||||
if ( configDirectory.isEmpty() )
|
if ( configDirectory.isEmpty() )
|
||||||
{
|
{
|
||||||
configDirectory = m_homeDirectory.absolutePath() + ".config/";
|
configDirectory = m_homeDirectory.absolutePath() + ".config";
|
||||||
}
|
}
|
||||||
m_configDirectory = configDirectory + ORGANIZATION_NAME_LOWER + "/" + PROJECT_NAME_LOWER;
|
m_configDirectory = configDirectory + "/" +
|
||||||
|
QCoreApplication::organizationName().toLower() + "/" +
|
||||||
|
QCoreApplication::applicationName().toLower();
|
||||||
|
|
||||||
QString cacheDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "XDG_CACHE_HOME" ) ) );
|
QString cacheDirectory = QString::fromLocal8Bit( qgetenv( qPrintable( "XDG_CACHE_HOME" ) ) );
|
||||||
if ( cacheDirectory.isEmpty() )
|
if ( cacheDirectory.isEmpty() )
|
||||||
{
|
{
|
||||||
cacheDirectory = m_homeDirectory.absolutePath() + ".cache/";
|
cacheDirectory = m_homeDirectory.absolutePath() + ".cache";
|
||||||
}
|
}
|
||||||
m_cacheDirectory = cacheDirectory + ORGANIZATION_NAME_LOWER + "/" + PROJECT_NAME_LOWER;
|
m_cacheDirectory = cacheDirectory + "/" +
|
||||||
|
QCoreApplication::organizationName().toLower() + "/" +
|
||||||
|
QCoreApplication::applicationName().toLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
return( true );
|
return( true );
|
||||||
} // Paths::updatePaths
|
} // Paths::updatePaths
|
||||||
|
|
||||||
|
|
||||||
bool Paths::makePaths()
|
bool Paths::makeDefaultDirectories()
|
||||||
{
|
{
|
||||||
bool status = true;
|
bool status = true;
|
||||||
|
|
||||||
@ -214,7 +226,8 @@ QString Paths::findConfigFile( const QString& defaultConfigFile )
|
|||||||
return( defaultConfigFile );
|
return( defaultConfigFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fileName = QString::fromLocal8Bit( qgetenv( qPrintable( PROJECT_NAME_UPPER "_CONFIG" ) ) );
|
auto fileName = QString::fromLocal8Bit( qgetenv( QCoreApplication::applicationName()
|
||||||
|
.toUpper().toUtf8() + "_CONFIG" ) );
|
||||||
if ( QFileInfo( fileName ).isReadable() )
|
if ( QFileInfo( fileName ).isReadable() )
|
||||||
{
|
{
|
||||||
m_configFilePath = fileName;
|
m_configFilePath = fileName;
|
@ -47,7 +47,8 @@ public:
|
|||||||
void setConfigFilePath( const QFileInfo& configFilePath );
|
void setConfigFilePath( const QFileInfo& configFilePath );
|
||||||
|
|
||||||
bool updatePaths();
|
bool updatePaths();
|
||||||
bool makePaths();
|
bool makeDefaultDirectories();
|
||||||
|
|
||||||
QString findConfigFile( const QString& defaultConfigFile = "" );
|
QString findConfigFile( const QString& defaultConfigFile = "" );
|
||||||
}; // class Paths
|
}; // class Paths
|
||||||
|
|
@ -25,7 +25,7 @@ add_uncrustify_format(${current_target} ${current_target_sources} ${current_targ
|
|||||||
target_include_directories(${current_target} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
|
target_include_directories(${current_target} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
|
||||||
target_include_directories(${current_target} SYSTEM PUBLIC ${FMT_INCLUDE_DIRS})
|
target_include_directories(${current_target} SYSTEM PUBLIC ${FMT_INCLUDE_DIRS})
|
||||||
target_include_directories(${current_target} SYSTEM PUBLIC ${SPDLOG_INCLUDE_DIRS})
|
target_include_directories(${current_target} SYSTEM PUBLIC ${SPDLOG_INCLUDE_DIRS})
|
||||||
target_include_directories(${current_target} PRIVATE ${CMAKE_SOURCE_DIR}/src/base)
|
target_include_directories(${current_target} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
||||||
|
|
||||||
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
|
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
|
||||||
add_custom_target(${current_target}-install-headers
|
add_custom_target(${current_target}-install-headers
|
@ -1,5 +1,5 @@
|
|||||||
#include "spdlog.hpp"
|
#include "spdlog.hpp"
|
||||||
#include "config.hpp"
|
#include <myx/base/config.hpp>
|
||||||
|
|
||||||
namespace myx {
|
namespace myx {
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ Logger::Logger( std::string name ) :
|
|||||||
m_logger( nullptr ),
|
m_logger( nullptr ),
|
||||||
m_name( std::move( name ) ),
|
m_name( std::move( name ) ),
|
||||||
m_outputPattern( "[%H:%M:%S %z] [%n] [%^---%L---%$] %v" ),
|
m_outputPattern( "[%H:%M:%S %z] [%n] [%^---%L---%$] %v" ),
|
||||||
m_baseFileName( fmt::format( "{}_{}", PROJECT_NAME, "st" ) ),
|
m_baseFileName( "default" ),
|
||||||
m_maxRotatingFileSize( rotatingFileSize ),
|
m_maxRotatingFileSize( rotatingFileSize ),
|
||||||
m_maxRotatingFilesCount( 3 ),
|
m_maxRotatingFilesCount( 3 ),
|
||||||
m_outputLevel( spdlog::level::trace ),
|
m_outputLevel( spdlog::level::trace ),
|
43
src/myx/qt/CMakeLists.txt
Normal file
43
src/myx/qt/CMakeLists.txt
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# Название основной цели и имя библиотеки в текущем каталоге
|
||||||
|
set(current_target qt)
|
||||||
|
|
||||||
|
# Список файлов исходных текстов
|
||||||
|
set(current_target_sources ${CMAKE_CURRENT_SOURCE_DIR}/translators.cpp)
|
||||||
|
|
||||||
|
# Список заголовочных файлов (используется для установки)
|
||||||
|
set(current_target_headers ${CMAKE_CURRENT_SOURCE_DIR}/backports.hpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/translators.hpp)
|
||||||
|
|
||||||
|
add_common_library(TARGET ${current_target}
|
||||||
|
OUTPUT_NAME myx-${current_target}
|
||||||
|
SOURCES ${current_target_sources})
|
||||||
|
common_target_properties(${current_target})
|
||||||
|
add_clang_tidy_check(${current_target} ${current_target_sources})
|
||||||
|
add_clang_analyze_check(${current_target} ${current_target_sources})
|
||||||
|
add_clazy_check(${current_target} ${current_target_sources})
|
||||||
|
add_pvs_check(${current_target})
|
||||||
|
add_uncrustify_format(${current_target} ${current_target_sources} ${current_target_headers})
|
||||||
|
|
||||||
|
target_include_directories(${current_target} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
|
||||||
|
target_include_directories(${current_target} SYSTEM PUBLIC ${FMT_INCLUDE_DIRS})
|
||||||
|
target_include_directories(${current_target} SYSTEM PUBLIC ${SPDLOG_INCLUDE_DIRS})
|
||||||
|
target_include_directories(${current_target} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
||||||
|
|
||||||
|
# Цель, используемая только для установки заголовочных файлов без компиляции
|
||||||
|
# проекта
|
||||||
|
add_custom_target(${current_target}-install-headers
|
||||||
|
COMMAND "${CMAKE_COMMAND}"
|
||||||
|
-DCMAKE_INSTALL_COMPONENT=headers
|
||||||
|
-P
|
||||||
|
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
||||||
|
|
||||||
|
# Правила для установки
|
||||||
|
install(TARGETS ${current_target}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
install(TARGETS ${current_target}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
|
endif()
|
||||||
|
install(FILES ${current_target_headers}
|
||||||
|
COMPONENT headers
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${current_target})
|
||||||
|
install(FILES ${CMAKE_BINARY_DIR}/${current_target}.pc
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
31
src/myx/qt/backports.hpp
Normal file
31
src/myx/qt/backports.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef MYX_QT_BACKPORTS_HPP_
|
||||||
|
#define MYX_QT_BACKPORTS_HPP_
|
||||||
|
|
||||||
|
#if ( defined ( TARGET_LSB_ID_AstraLinuxSE ) && defined ( TARGET_LSB_CODENAME_smolensk ) )
|
||||||
|
|
||||||
|
#define override
|
||||||
|
|
||||||
|
#if QT_VERSION <= 0x050700
|
||||||
|
#include <QtGlobal>
|
||||||
|
template< typename ... Args >
|
||||||
|
struct QOverload
|
||||||
|
{
|
||||||
|
template< typename C, typename R >
|
||||||
|
static constexpr auto of( R ( C::* pmf )( Args... ) )->decltype( pmf )
|
||||||
|
{
|
||||||
|
return( pmf );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// this adds const to non-const objects (like std::as_const)
|
||||||
|
template < typename T >
|
||||||
|
Q_DECL_CONSTEXPR typename std::add_const< T >::type& qAsConst( T& t ) noexcept { return( t ); }
|
||||||
|
// prevent rvalue arguments:
|
||||||
|
template < typename T >
|
||||||
|
void qAsConst( const T&& ) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // if QT_VERSION <= 0x050700
|
||||||
|
#endif // if ( defined ( TARGET_LSB_ID_AstraLinuxSE ) && defined ( TARGET_LSB_CODENAME_smolensk ) )
|
||||||
|
|
||||||
|
#endif // MYX_QT_BACKPORTS_HPP_
|
57
src/myx/qt/translators.cpp
Normal file
57
src/myx/qt/translators.cpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#include <myx/base/config.hpp>
|
||||||
|
#include "translators.hpp"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QLibraryInfo>
|
||||||
|
|
||||||
|
namespace myx {
|
||||||
|
|
||||||
|
namespace qt {
|
||||||
|
|
||||||
|
void append_translators( QTranslatorsList& translators, const QString& appName )
|
||||||
|
{
|
||||||
|
auto* translator = new QTranslator( qApp );
|
||||||
|
|
||||||
|
if ( translator->load( QLocale(), appName, QStringLiteral( "_" ),
|
||||||
|
QStringLiteral( ":/qm" ) ) )
|
||||||
|
{
|
||||||
|
translators.append( translator );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
translator->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
translator = new QTranslator( qApp );
|
||||||
|
if ( translator->load( QLocale::system(),
|
||||||
|
QStringLiteral( "qt" ), QStringLiteral( "_" ),
|
||||||
|
QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
|
||||||
|
{
|
||||||
|
translators.append( translator );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
translator->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
translator = new QTranslator( qApp );
|
||||||
|
if ( translator->load( QStringLiteral( "qtbase_" ) + QLocale::system().name(),
|
||||||
|
QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ) )
|
||||||
|
{
|
||||||
|
translators.append( translator );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
translator->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( auto i : qAsConst( translators ) )
|
||||||
|
{
|
||||||
|
qApp->installTranslator( i );
|
||||||
|
}
|
||||||
|
} // install_translators
|
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
|
||||||
|
} // namespace myx
|
20
src/myx/qt/translators.hpp
Normal file
20
src/myx/qt/translators.hpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef MYX_LOG_QT_TRANSLATORS_HPP_
|
||||||
|
#define MYX_LOG_QT_TRANSLATORS_HPP_
|
||||||
|
|
||||||
|
#include <myx/qt/backports.hpp>
|
||||||
|
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
|
namespace myx {
|
||||||
|
|
||||||
|
namespace qt {
|
||||||
|
|
||||||
|
typedef QList< QTranslator* > QTranslatorsList;
|
||||||
|
|
||||||
|
void append_translators( QTranslatorsList& translators, const QString& appName );
|
||||||
|
|
||||||
|
} // namespace qt
|
||||||
|
|
||||||
|
} // namespace myx
|
||||||
|
|
||||||
|
#endif // ifndef MYX_LOG_QT_TRANSLATORS_HPP_
|
Loading…
Reference in New Issue
Block a user