Переделана структура проекта

This commit is contained in:
Andrei Astafev 2020-06-30 20:04:26 +03:00
parent cf52aba9a3
commit 6358fe0820
32 changed files with 315 additions and 135 deletions

View File

@ -36,16 +36,19 @@ find_package(Threads REQUIRED)
find_package(Qt5 COMPONENTS Core Network REQUIRED) find_package(Qt5 COMPONENTS Core Network REQUIRED)
# Библиотеки # Библиотеки
add_subdirectory(src/myx/base) add_subdirectory(src/myx/backports/compiler)
add_subdirectory(src/myx/backports/cpp)
add_subdirectory(src/myx/backports/qt)
add_subdirectory(src/myx/core)
add_subdirectory(src/myx/filesystem) add_subdirectory(src/myx/filesystem)
add_subdirectory(src/myx/qt) add_subdirectory(src/myx/qt)
# Примеры # Примеры
if(MYXLIB_BUILD_EXAMPLES) if(MYXLIB_BUILD_EXAMPLES)
add_subdirectory(examples/base) add_subdirectory(examples/core)
add_subdirectory(examples/filesystem) add_subdirectory(examples/filesystem)
add_subdirectory(examples/qt) add_subdirectory(examples/qt)
add_custom_target(examples example-base-endian example-filesystem-paths example-qt-tranlators add_custom_target(examples example-core-endian example-filesystem-paths example-qt-tranlators
example-qt-posix-signal-watcher) example-qt-posix-signal-watcher)
endif() endif()

View File

@ -9,4 +9,4 @@ set(CPACK_COMPONENTS_ALL examples)
set(CPACK_PACKAGE_CONTACT "Andrei Astafev <dev@246060.ru>") set(CPACK_PACKAGE_CONTACT "Andrei Astafev <dev@246060.ru>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mixed functions") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mixed functions")
set(CMLIB_GENERATED_HEADERS_PATH ${CMAKE_BINARY_DIR}/include/myx/base) set(CMLIB_GENERATED_HEADERS_PATH ${CMAKE_BINARY_DIR}/include/myx/core)

View File

@ -1,5 +1,5 @@
# Название основной цели в текущем каталоге # Название основной цели в текущем каталоге
set(TRGT example-base-endian) set(TRGT example-core-endian)
# Список файлов исходных текстов # Список файлов исходных текстов
set(TRGT_cpp ${CMAKE_CURRENT_SOURCE_DIR}/endian.cpp) set(TRGT_cpp ${CMAKE_CURRENT_SOURCE_DIR}/endian.cpp)
@ -32,9 +32,8 @@ if(MYXLIB_BUILD_EXAMPLES)
target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_dependencies(${TRGT} base) add_dependencies(${TRGT} core)
target_link_libraries(${TRGT} base_static)
target_link_libraries(${TRGT} Qt5::Core) target_link_libraries(${TRGT} Qt5::Core)
target_link_libraries(${TRGT} Threads::Threads) target_link_libraries(${TRGT} Threads::Threads)

View File

@ -1,8 +1,9 @@
#include <myx/base/config.hpp> #include <myx/core/config.hpp>
#include <myx/base/endian_types.hpp> #include <myx/core/endian_types.hpp>
#include <QDebug> #include <QDebug>
//NOLINTNEXTLINE
#define CMLIB_PROJECT_NAME "myxlib" #define CMLIB_PROJECT_NAME "myxlib"
@ -12,11 +13,11 @@ int main( int argc, char** argv )
(void)argv; (void)argv;
beint64 bi = 1; beint64 bi = 1;
int64_t bii = reinterpret_cast< int64_t* >( &bi )[0]; int64_t bii = reinterpret_cast< int64_t* >( &bi )[0]; //NOLINT
qDebug() << hex << bi << bii; qDebug() << hex << bi << bii;
leint64 li = 1; leint64 li = 1;
int64_t lii = reinterpret_cast< int64_t* >( &li )[0]; int64_t lii = reinterpret_cast< int64_t* >( &li )[0]; //NOLINT
qDebug() << hex << li << lii; qDebug() << hex << li << lii;
return( 0 ); return( 0 );

View File

@ -32,9 +32,9 @@ if(MYXLIB_BUILD_EXAMPLES)
target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_dependencies(${TRGT} base filesystem) add_dependencies(${TRGT} core filesystem)
target_link_libraries(${TRGT} base_static filesystem_static) target_link_libraries(${TRGT} filesystem_static)
target_link_libraries(${TRGT} Qt5::Core) target_link_libraries(${TRGT} Qt5::Core)
target_link_libraries(${TRGT} Threads::Threads) target_link_libraries(${TRGT} Threads::Threads)

View File

@ -1,10 +1,11 @@
#include <myx/base/config.hpp> #include <myx/core/config.hpp>
#include <myx/filesystem/paths.hpp> #include <myx/filesystem/paths.hpp>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
//NOLINTNEXTLINE
#define CMLIB_PROJECT_NAME "myxlib" #define CMLIB_PROJECT_NAME "myxlib"
namespace MF = myx::filesystem; namespace MF = myx::filesystem;

View File

@ -38,9 +38,9 @@ if(MYXLIB_BUILD_EXAMPLES)
target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_dependencies(${TRGT} base qt) add_dependencies(${TRGT} core qt)
target_link_libraries(${TRGT} base_static qt_static) target_link_libraries(${TRGT} qt_static)
target_link_libraries(${TRGT} Qt5::Core) target_link_libraries(${TRGT} Qt5::Core)
target_link_libraries(${TRGT} Threads::Threads) target_link_libraries(${TRGT} Threads::Threads)

View File

@ -32,9 +32,9 @@ if(MYXLIB_BUILD_EXAMPLES)
target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src)
add_dependencies(${TRGT} base qt) add_dependencies(${TRGT} core qt)
target_link_libraries(${TRGT} base_static qt_static) target_link_libraries(${TRGT} qt_static)
target_link_libraries(${TRGT} Qt5::Core) target_link_libraries(${TRGT} Qt5::Core)
target_link_libraries(${TRGT} Threads::Threads) target_link_libraries(${TRGT} Threads::Threads)

View File

@ -15,7 +15,7 @@ int main( int argc, char* argv[] )
sigwatch.watchForSignal( SIGTERM ); sigwatch.watchForSignal( SIGTERM );
QObject::connect( &sigwatch, &MQ::PosixSignalWatcher::posixSignal, &app, &QCoreApplication::quit ); QObject::connect( &sigwatch, &MQ::PosixSignalWatcher::posixSignal, &app, &QCoreApplication::quit );
int exitcode = app.exec(); int exitcode = QCoreApplication::exec();
qDebug() << "Goodbye"; qDebug() << "Goodbye";
return( exitcode ); return( exitcode );
} }

View File

@ -0,0 +1,42 @@
# Название основной цели и имя библиотеки в текущем каталоге
set(TRGT backports-compiler)
# cmake-format: off
# Список файлов исходных текстов
set(TRGT_cpp)
# Список заголовочных файлов
set(TRGT_hpp
${CMAKE_CURRENT_SOURCE_DIR}/gcc.hpp
)
set(TRGT_headers ${TRGT_hpp})
# cmake-format: on
add_library(${TRGT} INTERFACE)
target_sources(${TRGT} INTERFACE ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clang-tidy
add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clang-analyze
add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clazy
add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой pvs-studio
add_pvs_check(${TRGT})
# Создание цели для автоматического форматирования кода
add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers})
target_include_directories(${TRGT} INTERFACE ${CMAKE_SOURCE_DIR}/src)
generate_pkgconfig(myx-${TRGT} COMPONENT base-dev INSTALL_LIBRARY ${MYXLIB_BUILD_LIBRARIES})
install(FILES ${TRGT_headers} COMPONENT base-dev
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/backports/compiler)
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
add_custom_target(${TRGT}-install-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=base-dev -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")

View File

@ -0,0 +1,29 @@
#ifndef MYX_BACKPORTS_COMPILER_GCC_HPP_
#define MYX_BACKPORTS_COMPILER_GCC_HPP_
#pragma once
#ifdef __GNUC__
// NOLINTNEXTLINE
#define GCC_VERSION ( __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ )
#if GCC_VERSION <= 40702
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wkeyword-macro"
#endif
// NOLINTNEXTLINE
#define override
// NOLINTNEXTLINE
#define constexpr const
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // if GCC_VERSION <= 40702
#endif // ifdef __GNUC__
#endif // ifndef MYX_BACKPORTS_COMPILER_GCC_HPP_

View File

@ -0,0 +1,43 @@
# Название основной цели и имя библиотеки в текущем каталоге
set(TRGT backports-cpp)
# cmake-format: off
# Список файлов исходных текстов
set(TRGT_cpp)
# Список заголовочных файлов
set(TRGT_hpp
${CMAKE_CURRENT_SOURCE_DIR}/helpers.hpp
${CMAKE_CURRENT_SOURCE_DIR}/span.hpp
)
set(TRGT_headers ${TRGT_hpp})
# cmake-format: on
add_library(${TRGT} INTERFACE)
target_sources(${TRGT} INTERFACE ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clang-tidy
add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clang-analyze
add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clazy
add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой pvs-studio
add_pvs_check(${TRGT})
# Создание цели для автоматического форматирования кода
add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers})
target_include_directories(${TRGT} INTERFACE ${CMAKE_SOURCE_DIR}/src)
generate_pkgconfig(myx-${TRGT} COMPONENT base-dev INSTALL_LIBRARY ${MYXLIB_BUILD_LIBRARIES})
install(FILES ${TRGT_headers} COMPONENT base-dev
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/backports/cpp)
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
add_custom_target(${TRGT}-install-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=base-dev -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")

View File

@ -0,0 +1,36 @@
#ifndef MYX_BACKPORTS_CPP_HELPERS_HPP_
#define MYX_BACKPORTS_CPP_HELPERS_HPP_
#pragma once
#if ( __cplusplus >= 201103L )
#include <type_traits>
#endif
#if ( __cplusplus >= 201103L ) && ( __cplusplus < 201402L )
namespace std
{
template< class T >
using underlying_type_t = typename std::underlying_type< T >::type;
} // namespace std
#endif
#if ( __cplusplus >= 201103L ) && ( __cplusplus < 201702L )
namespace std
{
#if defined( __STRICT_ANSI__ )
template< typename ... Ts > struct make_void { typedef void type; };
template< typename ... Ts > using void_t = typename make_void< Ts... >::type;
#endif
} // namespace std
#endif
#endif // ifndef MYX_BACKPORTS_CPP_HELPERS_HPP_

View File

@ -7,23 +7,24 @@
// Official repository: https://github.com/boostorg/beast // Official repository: https://github.com/boostorg/beast
// //
#ifndef MYX_BASE_SPAN_HPP_ #ifndef MYX_BACKPORTS_CPP_SPAN_HPP_
#define MYX_BASE_SPAN_HPP_ #define MYX_BACKPORTS_CPP_SPAN_HPP_
#pragma once
#if ( __cplusplus >= 201103L ) && ( __cplusplus < 201703L )
#include <myx/backports/cpp/helpers.hpp>
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
namespace myx { namespace std {
namespace base {
template< typename ... Ts > struct make_void { typedef void type;}; // NOLINT
template< typename ... Ts > using void_t = typename make_void< Ts... >::type; // NOLINT
template< class T, class E, class = void > template< class T, class E, class = void >
struct is_contiguous_container : std::false_type {}; // NOLINT struct is_contiguous_container : std::false_type {}; // NOLINT
template< class T, class E > template< class T, class E >
struct is_contiguous_container< T, E, void_t< struct is_contiguous_container< T, E, void_t<
@ -52,38 +53,38 @@ struct is_contiguous_container< T, E, void_t<
@tparam T The type pointed to by span iterators @tparam T The type pointed to by span iterators
*/ */
template< class T > template< class T >
class span // NOLINT class span // NOLINT
{ {
T* m_data = nullptr; T* m_data = nullptr;
std::size_t m_size = 0; std::size_t m_size = 0;
public: public:
/// The type of value, including cv qualifiers /// The type of value, including cv qualifiers
using element_type = T; using ElementType = T;
/// The type of value of each span element /// The type of value of each span element
using value_type = typename std::remove_const< T >::type; using ValueType = typename std::remove_const< T >::type;
/// The type of integer used to index the span /// The type of integer used to index the span
using index_type = std::ptrdiff_t; using IndexType = std::ptrdiff_t;
/// A pointer to a span element /// A pointer to a span element
using pointer = T*; using Pointer = T*;
/// A reference to a span element /// A reference to a span element
using reference = T&; using Reference = T&;
/// The iterator used by the container /// The iterator used by the container
using iterator = pointer; using Iterator = Pointer;
/// The const pointer used by the container /// The const pointer used by the container
using const_pointer = T const*; using ConstPointer = T const*;
/// The const reference used by the container /// The const reference used by the container
using const_reference = T const&; using ConstReference = T const&;
/// The const iterator used by the container /// The const iterator used by the container
using const_iterator = const_pointer; using ConstIterator = ConstPointer;
/// Constructor /// Constructor
span() = default; span() = default;
@ -95,11 +96,9 @@ public:
span& operator=( span const& ) = default; span& operator=( span const& ) = default;
/** Constructor /** Constructor
* @param data A pointer to the beginning of the range of elements
@param data A pointer to the beginning of the range of elements * @param size The number of elements pointed to by `data`
*/
@param size The number of elements pointed to by `data`
*/
span( T* data, std::size_t size ) : span( T* data, std::size_t size ) :
m_data( data ), m_data( data ),
m_size( size ) m_size( size )
@ -108,9 +107,8 @@ public:
/** Constructor /** Constructor
* @param container The container to construct from
@param container The container to construct from */
*/
template< class ContiguousContainer, template< class ContiguousContainer,
class = typename std::enable_if< class = typename std::enable_if<
is_contiguous_container< is_contiguous_container<
@ -143,9 +141,8 @@ public:
/** Assignment /** Assignment
* @param container The container to assign from
@param container The container to assign from */
*/
template< class ContiguousContainer > template< class ContiguousContainer >
typename std::enable_if< is_contiguous_container< typename std::enable_if< is_contiguous_container<
ContiguousContainer, T >::value, ContiguousContainer, T >::value,
@ -205,7 +202,7 @@ public:
/// Returns an iterator to the beginning of the span /// Returns an iterator to the beginning of the span
iterator Iterator
begin() const begin() const
{ {
return( m_data ); return( m_data );
@ -213,7 +210,7 @@ public:
/// Returns an iterator to the beginning of the span /// Returns an iterator to the beginning of the span
const_iterator ConstIterator
cbegin() const cbegin() const
{ {
return( m_data ); return( m_data );
@ -221,7 +218,7 @@ public:
/// Returns an iterator to one past the end of the span /// Returns an iterator to one past the end of the span
iterator Iterator
end() const end() const
{ {
return( m_data + m_size ); return( m_data + m_size );
@ -229,15 +226,15 @@ public:
/// Returns an iterator to one past the end of the span /// Returns an iterator to one past the end of the span
const_iterator ConstIterator
cend() const cend() const
{ {
return( m_data + m_size ); return( m_data + m_size );
} }
}; // class span }; // class span
} // namespace base } // namespace std
} // namespace myx #endif // if ( __cplusplus >= 201103L ) && ( __cplusplus < 201703L )
#endif // ifndef MYX_BASE_SPAN_HPP_ #endif // ifndef MYX_BACKPORTS_CPP_SPAN_HPP_

View File

@ -0,0 +1,42 @@
# Название основной цели и имя библиотеки в текущем каталоге
set(TRGT backports-qt)
# cmake-format: off
# Список файлов исходных текстов
set(TRGT_cpp)
# Список заголовочных файлов
set(TRGT_hpp
${CMAKE_CURRENT_SOURCE_DIR}/common.hpp
)
set(TRGT_headers ${TRGT_hpp})
# cmake-format: on
add_library(${TRGT} INTERFACE)
target_sources(${TRGT} INTERFACE ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clang-tidy
add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clang-analyze
add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clazy
add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой pvs-studio
add_pvs_check(${TRGT})
# Создание цели для автоматического форматирования кода
add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers})
target_include_directories(${TRGT} INTERFACE ${CMAKE_SOURCE_DIR}/src)
install(FILES ${TRGT_headers} COMPONENT base-dev
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/backports/qt)
generate_pkgconfig(myx-${TRGT} COMPONENT base-dev INSTALL_LIBRARY ${MYXLIB_BUILD_LIBRARIES})
# Цель, используемая только для установки заголовочных файлов без компиляции проекта
add_custom_target(${TRGT}-install-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=base-dev -P
"${CMAKE_BINARY_DIR}/cmake_install.cmake")

View File

@ -1,11 +1,9 @@
#ifndef MYX_QT_BACKPORTS_HPP_ #ifndef MYX_BACKPORTS_QT_COMMON_HPP_
#define MYX_QT_BACKPORTS_HPP_ #define MYX_BACKPORTS_QT_COMMON_HPP_
#pragma once #pragma once
#if ( defined ( TARGET_LSB_ID_AstraLinuxSE ) && defined ( TARGET_LSB_CODENAME_smolensk ) ) #if defined( QT_VERSION )
#define override
#if QT_VERSION <= 0x050700 #if QT_VERSION <= 0x050700
#include <QtGlobal> #include <QtGlobal>
@ -33,6 +31,7 @@ void qAsConst( const T&& ) = delete;
#endif // if QT_VERSION <= 0x050700 #endif // if QT_VERSION <= 0x050700
#endif // if ( defined ( TARGET_LSB_ID_AstraLinuxSE ) && defined ( TARGET_LSB_CODENAME_smolensk ) )
#endif // MYX_QT_BACKPORTS_HPP_ #endif // if defined( QT_VERSION )
#endif // MYX_BACKPORTS_QT_COMMON_HPP_

View File

@ -1 +0,0 @@
#include <myx/base/config.hpp>

View File

@ -1,24 +1,22 @@
# Название основной цели и имя библиотеки в текущем каталоге # Название основной цели и имя библиотеки в текущем каталоге
set(TRGT base) set(TRGT core)
# cmake-format: off # cmake-format: off
# Список файлов исходных текстов # Список файлов исходных текстов
set(TRGT_cpp set(TRGT_cpp)
${CMAKE_CURRENT_SOURCE_DIR}/config.cpp)
# Список заголовочных файлов # Список заголовочных файлов
set(TRGT_hpp set(TRGT_hpp
${CMAKE_CURRENT_SOURCE_DIR}/config.hpp ${CMAKE_CURRENT_SOURCE_DIR}/config.hpp
${CMAKE_CURRENT_SOURCE_DIR}/limits.hpp ${CMAKE_CURRENT_SOURCE_DIR}/limits.hpp
${CMAKE_CURRENT_SOURCE_DIR}/span.hpp
${CMAKE_CURRENT_SOURCE_DIR}/endian_types.hpp ${CMAKE_CURRENT_SOURCE_DIR}/endian_types.hpp
${CMAKE_CURRENT_SOURCE_DIR}/enum_bitmask_operations.hpp) ${CMAKE_CURRENT_SOURCE_DIR}/enum_bitmask_operations.hpp)
set(TRGT_headers ${TRGT_hpp}) set(TRGT_headers ${TRGT_hpp})
# cmake-format: on # cmake-format: on
add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_cpp} ${TRGT_headers}) add_library(${TRGT} INTERFACE)
common_target_properties(${TRGT}) target_sources(${TRGT} INTERFACE ${TRGT_cpp} ${TRGT_headers})
# Создание цели для проверки утилитой clang-tidy # Создание цели для проверки утилитой clang-tidy
add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers})
@ -35,15 +33,10 @@ add_pvs_check(${TRGT})
# Создание цели для автоматического форматирования кода # Создание цели для автоматического форматирования кода
add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers}) add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers})
target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) target_include_directories(${TRGT} INTERFACE ${CMAKE_SOURCE_DIR}/src)
install(TARGETS ${TRGT}_static COMPONENT libs-dev ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(BUILD_SHARED_LIBS)
install(TARGETS ${TRGT}_shared COMPONENT main LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
generate_pkgconfig(myx-${TRGT} COMPONENT base-dev INSTALL_LIBRARY ${MYXLIB_BUILD_LIBRARIES}) generate_pkgconfig(myx-${TRGT} COMPONENT base-dev INSTALL_LIBRARY ${MYXLIB_BUILD_LIBRARIES})
install(FILES ${TRGT_headers} ${CMAKE_BINARY_DIR}/include/myx/base/compiler_features.hpp COMPONENT base-dev install(FILES ${TRGT_headers} ${CMAKE_BINARY_DIR}/include/myx/core/compiler_features.hpp COMPONENT base-dev
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT})
# Цель, используемая только для установки заголовочных файлов без компиляции проекта # Цель, используемая только для установки заголовочных файлов без компиляции проекта

View File

@ -1,5 +1,5 @@
#ifndef MYX_BASE_CONFIG_HPP_ #ifndef MYX_CORE_CONFIG_HPP_
#define MYX_BASE_CONFIG_HPP_ #define MYX_CORE_CONFIG_HPP_
#pragma once #pragma once
@ -14,4 +14,4 @@
#endif #endif
#define MYXLIB_INLINE #define MYXLIB_INLINE
#endif // MYX_BASE_CONFIG_HPP_ #endif // MYX_CORE_CONFIG_HPP_

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include <myx/base/span.hpp> #include <myx/backports/cpp/span.hpp>
#include <cassert> #include <cassert>
#include <cstdint> #include <cstdint>
@ -17,7 +17,7 @@
namespace myx { namespace myx {
namespace base { namespace core {
template< typename T > template< typename T >
class EndianTypesBase class EndianTypesBase
@ -29,8 +29,8 @@ protected:
static T swapBytes( const T& b ) static T swapBytes( const T& b )
{ {
T n; T n;
myx::base::span< uint8_t > sn( reinterpret_cast< uint8_t* >( &n ), sizeof( T ) ); std::span< uint8_t > sn( reinterpret_cast< uint8_t* >( &n ), sizeof( T ) ); //NOLINT
myx::base::span< const uint8_t > sb( reinterpret_cast< const uint8_t* >( &b ), sizeof( T ) ); std::span< const uint8_t > sb( reinterpret_cast< const uint8_t* >( &b ), sizeof( T ) ); //NOLINT
std::reverse_copy( sb.begin(), sb.end(), sn.begin() ); std::reverse_copy( sb.begin(), sb.end(), sn.begin() );
return( n ); return( n );
} // swapBytes } // swapBytes
@ -45,12 +45,12 @@ template< typename T >
class LittleEndianType : public EndianTypesBase< T > class LittleEndianType : public EndianTypesBase< T >
{ {
protected: protected:
T m_data; T m_data; //NOLINT
static T transform( const T& b ) static T transform( const T& b )
{ {
const uint16_t k_i = 1; const uint16_t k_i = 1;
return( ( reinterpret_cast< const char& >( k_i ) == 1 ) ? b : EndianTypesBase< T >::swapBytes( b ) ); return( ( reinterpret_cast< const char& >( k_i ) == 1 ) ? b : EndianTypesBase< T >::swapBytes( b ) ); //NOLINT
} }
@ -106,12 +106,12 @@ template< typename T >
class BigEndianType : public EndianTypesBase< T > class BigEndianType : public EndianTypesBase< T >
{ {
protected: protected:
T m_data; T m_data; //NOLINT
static T transform( const T& b ) static T transform( const T& b )
{ {
const uint16_t k_i = 1; const uint16_t k_i = 1;
return( ( reinterpret_cast< const char& >( k_i ) == 1 ) ? EndianTypesBase< T >::swapBytes( b ) : b ); return( ( reinterpret_cast< const char& >( k_i ) == 1 ) ? EndianTypesBase< T >::swapBytes( b ) : b ); //NOLINT
} }
@ -163,30 +163,30 @@ public:
#endif #endif
}; // class BigEndianType }; // class BigEndianType
} // namespace base } // namespace core
} // namespace myx } // namespace myx
using leint16 = myx::base::LittleEndianType< int16_t >; using leint16 = myx::core::LittleEndianType< int16_t >; //NOLINT
using leint32 = myx::base::LittleEndianType< int32_t >; using leint32 = myx::core::LittleEndianType< int32_t >; //NOLINT
using leint64 = myx::base::LittleEndianType< int64_t >; using leint64 = myx::core::LittleEndianType< int64_t >; //NOLINT
using leuint16 = myx::base::LittleEndianType< uint16_t >; using leuint16 = myx::core::LittleEndianType< uint16_t >; //NOLINT
using leuint32 = myx::base::LittleEndianType< uint32_t >; using leuint32 = myx::core::LittleEndianType< uint32_t >; //NOLINT
using leuint64 = myx::base::LittleEndianType< uint64_t >; using leuint64 = myx::core::LittleEndianType< uint64_t >; //NOLINT
using lefloat = myx::base::LittleEndianType< float >; using lefloat = myx::core::LittleEndianType< float >; //NOLINT
using ledouble = myx::base::LittleEndianType< double >; using ledouble = myx::core::LittleEndianType< double >; //NOLINT
using beint16 = myx::base::BigEndianType< int16_t >; using beint16 = myx::core::BigEndianType< int16_t >; //NOLINT
using beint32 = myx::base::BigEndianType< int32_t >; using beint32 = myx::core::BigEndianType< int32_t >; //NOLINT
using beint64 = myx::base::BigEndianType< int64_t >; using beint64 = myx::core::BigEndianType< int64_t >; //NOLINT
using beuint16 = myx::base::BigEndianType< uint16_t >; using beuint16 = myx::core::BigEndianType< uint16_t >; //NOLINT
using beuint32 = myx::base::BigEndianType< uint32_t >; using beuint32 = myx::core::BigEndianType< uint32_t >; //NOLINT
using beuint64 = myx::base::BigEndianType< uint64_t >; using beuint64 = myx::core::BigEndianType< uint64_t >; //NOLINT
using befloat = myx::base::BigEndianType< float >; using befloat = myx::core::BigEndianType< float >; //NOLINT
using bedouble = myx::base::BigEndianType< double >; using bedouble = myx::core::BigEndianType< double >; //NOLINT
#endif // MYX_BASE_ENDIAN_TYPES_HPP_ #endif // MYX_BASE_ENDIAN_TYPES_HPP_

View File

@ -1,5 +1,5 @@
#ifndef MYX_BASE_ENUM_BITWISE_OPERATIONS_HPP_ #ifndef MYX_CORE_ENUM_BITWISE_OPERATIONS_HPP_
#define MYX_BASE_ENUM_BITWISE_OPERATIONS_HPP_ #define MYX_CORE_ENUM_BITWISE_OPERATIONS_HPP_
#pragma once #pragma once
@ -7,7 +7,7 @@
namespace myx { namespace myx {
namespace base { namespace core {
template< typename Enum > template< typename Enum >
struct EnableBitMaskOperators struct EnableBitMaskOperators
@ -61,7 +61,7 @@ operator &=( Enum& lhs, Enum rhs )
return( lhs ); return( lhs );
} }
} // namespace base } // namespace core
} // namespace myx } // namespace myx
@ -85,9 +85,9 @@ operator &=( Enum& lhs, Enum rhs )
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define ENABLE_BITMASK_OPERATORS( x ) \ #define ENABLE_BITMASK_OPERATORS( x ) \
template<> \ template<> \
struct myx::base::EnableBitMaskOperators< x > \ struct myx::core::EnableBitMaskOperators< x > \
{ \ { \
static const bool kEnable = true; \ static const bool kEnable = true; \
}; };
#endif // ifndef MYX_BASE_ENUM_BITWISE_OPERATIONS_HPP_ #endif // ifndef MYX_CORE_ENUM_BITWISE_OPERATIONS_HPP_

View File

@ -1,5 +1,5 @@
#ifndef MYX_BASE_LIMITS_HPP_ #ifndef MYX_CORE_LIMITS_HPP_
#define MYX_BASE_LIMITS_HPP_ #define MYX_CORE_LIMITS_HPP_
#pragma once #pragma once
@ -7,7 +7,7 @@
namespace myx { namespace myx {
namespace base { namespace core {
/** /**
* @brief Константа, представляющая значение, не являющееся числом, для типа float * @brief Константа, представляющая значение, не являющееся числом, для типа float
@ -24,8 +24,8 @@ constexpr double kDoubleNAN { std::numeric_limits< double >::quiet_NaN() };
*/ */
constexpr double kLongDoubleNAN { std::numeric_limits< long double >::quiet_NaN() }; constexpr double kLongDoubleNAN { std::numeric_limits< long double >::quiet_NaN() };
} // namespace base } // namespace core
} // namespace myx } // namespace myx
#endif // MYX_BASE_LIMITS_HPP_ #endif // MYX_CORE_LIMITS_HPP_

View File

@ -1,7 +1,7 @@
#ifndef MYX_BASE_PATHS_CPP_ #ifndef MYX_CORE_PATHS_CPP_
#define MYX_BASE_PATHS_CPP_ #define MYX_CORE_PATHS_CPP_
#include <myx/base/config.hpp> #include <myx/core/config.hpp>
#include <myx/filesystem/paths.hpp> #include <myx/filesystem/paths.hpp>
#include <paths.h> #include <paths.h>
@ -368,4 +368,4 @@ MYXLIB_INLINE const QString& Paths::prefixDirectory() const
} // namespace myx } // namespace myx
#endif // MYX_BASE_PATHS_CPP_ #endif // MYX_CORE_PATHS_CPP_

View File

@ -8,7 +8,7 @@
#pragma once #pragma once
#include <myx/base/config.hpp> #include <myx/core/config.hpp>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>

View File

@ -17,7 +17,6 @@ set(TRGT_moc_private_hpp
) )
set(TRGT_hpp set(TRGT_hpp
${CMAKE_CURRENT_SOURCE_DIR}/backports.hpp
${CMAKE_CURRENT_SOURCE_DIR}/translators.hpp ${CMAKE_CURRENT_SOURCE_DIR}/translators.hpp
) )

View File

@ -1,7 +1,7 @@
#ifndef MYX_QT_POSIX_SIGNAL_WATCHER_CPP_ #ifndef MYX_QT_POSIX_SIGNAL_WATCHER_CPP_
#define MYX_QT_POSIX_SIGNAL_WATCHER_CPP_ #define MYX_QT_POSIX_SIGNAL_WATCHER_CPP_
#include <myx/base/config.hpp> #include <myx/core/config.hpp>
#include <myx/qt/posix_signal_watcher.hpp> #include <myx/qt/posix_signal_watcher.hpp>
#include <myx/qt/posix_signal_watcher_p.hpp> #include <myx/qt/posix_signal_watcher_p.hpp>
@ -27,8 +27,8 @@ PosixSignalWatcherPrivate::PosixSignalWatcherPrivate( PosixSignalWatcher* q ) :
#endif #endif
// Create a notifier for the read end of the pair // Create a notifier for the read end of the pair
m_notifier.reset( new QSocketNotifier( mSockpair[1], QSocketNotifier::Read ) ); // m_notifier.reset( new QSocketNotifier( mSockpair[1], QSocketNotifier::Read ) );
m_notifier = std::make_unique< QSocketNotifier >( mSockpair[1], QSocketNotifier::Read );
// Called when the signal handler has written to the socket pair. // Called when the signal handler has written to the socket pair.
// Emits the Posix signal as a Qt signal. // Emits the Posix signal as a Qt signal.
@ -63,7 +63,7 @@ MYXLIB_INLINE void PosixSignalWatcherPrivate::watchForSignal( int signal )
#if MYX_QT_HAS_POSIX_SIGNALS #if MYX_QT_HAS_POSIX_SIGNALS
// Register a sigaction which will write to the socket pair // Register a sigaction which will write to the socket pair
struct sigaction sigact {}; struct sigaction sigact {};
sigact.sa_handler = PosixSignalWatcherPrivate::signalHandler; sigact.sa_handler = PosixSignalWatcherPrivate::signalHandler; //NOLINT
sigact.sa_flags = 0; sigact.sa_flags = 0;
sigemptyset( &sigact.sa_mask ); sigemptyset( &sigact.sa_mask );
sigact.sa_flags |= SA_RESTART; sigact.sa_flags |= SA_RESTART;
@ -98,8 +98,6 @@ MYXLIB_INLINE PosixSignalWatcher::PosixSignalWatcher( QObject* parent ) :
} }
MYXLIB_INLINE PosixSignalWatcher::~PosixSignalWatcher() = default;
/*! /*!
* Register a signal handler for the given \a signal. * Register a signal handler for the given \a signal.
* *

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include <myx/base/config.hpp> #include <myx/core/config.hpp>
#include <QObject> #include <QObject>
@ -33,14 +33,13 @@ class PosixSignalWatcher : public QObject
public: public:
explicit PosixSignalWatcher( QObject* parent = nullptr ); explicit PosixSignalWatcher( QObject* parent = nullptr );
~PosixSignalWatcher() override;
void watchForSignal( int signal ); void watchForSignal( int signal );
Q_SIGNAL void posixSignal( int signal ); Q_SIGNAL void posixSignal( int signal );
private: private:
PosixSignalWatcherPrivate* const d_ptr = nullptr; PosixSignalWatcherPrivate* const d_ptr = nullptr;
Q_DECLARE_PRIVATE( PosixSignalWatcher ) Q_DECLARE_PRIVATE( PosixSignalWatcher ) //NOLINT
}; // class PosixSignalWatcher }; // class PosixSignalWatcher
} // namespace qt } // namespace qt

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include <myx/base/config.hpp> #include <myx/core/config.hpp>
#include <myx/qt/posix_signal_watcher.hpp> #include <myx/qt/posix_signal_watcher.hpp>
#include <QObject> #include <QObject>

View File

@ -1,7 +1,7 @@
#ifndef MYX_QT_TRANSLATORS_CPP_ #ifndef MYX_QT_TRANSLATORS_CPP_
#define MYX_QT_TRANSLATORS_CPP_ #define MYX_QT_TRANSLATORS_CPP_
#include <myx/base/config.hpp> #include <myx/core/config.hpp>
#include <myx/qt/translators.hpp> #include <myx/qt/translators.hpp>
#include <QCoreApplication> #include <QCoreApplication>

View File

@ -3,8 +3,8 @@
#pragma once #pragma once
#include <myx/base/config.hpp> #include <myx/backports/qt/common.hpp>
#include <myx/qt/backports.hpp> #include <myx/core/config.hpp>
#include <QTranslator> #include <QTranslator>