From b2731ac32f12d79950045a6b94b18163ff2fe582 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Wed, 22 Apr 2020 18:54:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 29 +++----- cmake/cmlib | 2 +- examples/filesystem/01_minimal/CMakeLists.txt | 10 +-- examples/qt/01_translators/CMakeLists.txt | 10 +-- src/myx/base/CMakeLists.txt | 72 +++++++------------ src/myx/base/config.hpp | 6 +- src/myx/filesystem/CMakeLists.txt | 55 +++++++------- src/myx/filesystem/current_executable.hpp | 2 + src/myx/filesystem/paths.hpp | 1 + src/myx/filesystem/paths_mt.hpp | 1 + src/myx/math/CMakeLists.txt | 52 ++++++++------ src/myx/qt/CMakeLists.txt | 71 +++++++++--------- src/myx/qt/translators.hpp | 1 + src/myx/redis/CMakeLists.txt | 55 +++++++------- 14 files changed, 180 insertions(+), 187 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27ad1b3..4880b31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.3) cmake_policy(VERSION 3.0.2..3.7) # Название проекта -project(myx VERSION 0.3.0 LANGUAGES C CXX) +project(myx VERSION 0.4.0 LANGUAGES C CXX) # В каталоге cmake/lib находятся файлы с библиотечными функциями if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/cmake/cmlib) @@ -14,7 +14,7 @@ endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/find) if(NOT DEFINED MYXLIB_MASTER_PROJECT) - if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(MYXLIB_MASTER_PROJECT ON) else() set(MYXLIB_MASTER_PROJECT OFF) @@ -23,8 +23,11 @@ endif() include(CMLibCommon) -option(MYXLIB_HEADER_ONLY "Build header only version of library" ON) -option(MYXLIB_BUILD_EXAMPLES "Build examples" OFF) +option(MYXLIB_BUILD_LIBRARIES "Build libraries" OFF) +if(MYXLIB_BUILD_LIBRARIES) + option(MYXLIB_BUILD_EXAMPLES "Build examples" OFF) +endif() +option(MYXLIB_BUILD_EXAMPLES_HO "Build examples using header only version" OFF) # Поиск библиотек с помощью pkgconfig find_package(PkgConfig REQUIRED) @@ -34,21 +37,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) # Qt5 -find_package( - Qt5 - COMPONENTS - Core - Network - REQUIRED) - -# Автоматически генерируемый заголовочный файл -# cmlib_config_hpp_generate() - -# configure_file(${CMAKE_SOURCE_DIR}/src/myx/base/config_flags.hpp.in -# ${CMAKE_BINARY_DIR}/include/myx/base/config_flags.hpp) - -# Подключение внешних проектов -include(ExternalProject) +find_package(Qt5 COMPONENTS Core Network REQUIRED) # Библиотеки add_subdirectory(src/myx/base) @@ -58,7 +47,7 @@ add_subdirectory(src/myx/math) add_subdirectory(src/myx/redis) # Примеры -if(BUILD_EXAMPLES) +if(MYXLIB_BUILD_EXAMPLES OR MYXLIB_BUILD_EXAMPLES_HO) add_subdirectory(examples/filesystem) add_subdirectory(examples/qt) diff --git a/cmake/cmlib b/cmake/cmlib index e5fbb90..83a9e94 160000 --- a/cmake/cmlib +++ b/cmake/cmlib @@ -1 +1 @@ -Subproject commit e5fbb9023546a5e98c832e8596586c71edcc5b2f +Subproject commit 83a9e94e31ab410c3346a36ddd2d10aa91375617 diff --git a/examples/filesystem/01_minimal/CMakeLists.txt b/examples/filesystem/01_minimal/CMakeLists.txt index 212224f..c9fa8db 100644 --- a/examples/filesystem/01_minimal/CMakeLists.txt +++ b/examples/filesystem/01_minimal/CMakeLists.txt @@ -31,12 +31,12 @@ target_include_directories(${TRGT} PRIVATE ${CMAKE_SOURCE_DIR}/src) target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) if(NOT MYXLIB_HEADER_ONLY) - add_dependencies(${TRGT} base_static filesystem_static) - target_link_libraries(${TRGT} myx-filesystem) + add_dependencies(${TRGT} base_static filesystem_static) + target_link_libraries(${TRGT} myx-filesystem) else() - target_compile_definitions(${TRGT} PUBLIC MYXLIB_HEADER_ONLY) - target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) - add_dependencies(${TRGT} base filesystem) + target_compile_definitions(${TRGT} PUBLIC MYXLIB_HEADER_ONLY) + target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) + add_dependencies(${TRGT} base filesystem) endif() target_link_libraries(${TRGT} Qt5::Core) diff --git a/examples/qt/01_translators/CMakeLists.txt b/examples/qt/01_translators/CMakeLists.txt index cfa7b7b..dda7cfb 100644 --- a/examples/qt/01_translators/CMakeLists.txt +++ b/examples/qt/01_translators/CMakeLists.txt @@ -38,12 +38,12 @@ target_include_directories(${TRGT} PRIVATE ${CMAKE_SOURCE_DIR}/src) target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) if(NOT MYXLIB_HEADER_ONLY) - add_dependencies(${TRGT} base_static qt_static) - target_link_libraries(${TRGT} myx-qt) + add_dependencies(${TRGT} base_static qt_static) + target_link_libraries(${TRGT} myx-qt) else() - target_compile_definitions(${TRGT} PUBLIC MYXLIB_HEADER_ONLY) - target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) - add_dependencies(${TRGT} base qt) + target_compile_definitions(${TRGT} PUBLIC MYXLIB_HEADER_ONLY) + target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) + add_dependencies(${TRGT} base qt) endif() target_link_libraries(${TRGT} Qt5::Core) diff --git a/src/myx/base/CMakeLists.txt b/src/myx/base/CMakeLists.txt index 6469ccf..8b2a283 100644 --- a/src/myx/base/CMakeLists.txt +++ b/src/myx/base/CMakeLists.txt @@ -16,63 +16,45 @@ set(TRGT_hpp set(TRGT_headers ${TRGT_hpp}) # cmake-format: on -if(MYXLIB_HEADER_ONLY) - add_library(${TRGT} INTERFACE) -else() - add_common_library( - ${TRGT} - OUTPUT_NAME myx-${TRGT} - SOURCES ${TRGT_cpp} ${TRGT_headers}) - common_target_properties(${TRGT}) -endif() +add_library(${TRGT}-header-only INTERFACE) +target_include_directories( + ${TRGT}-header-only SYSTEM INTERFACE "$" + "$") -# Создание цели для проверки утилитой clang-tidy -add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) +if(MYXLIB_BUILD_LIBRARIES) + add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_cpp} ${TRGT_headers}) + common_target_properties(${TRGT}) -# Создание цели для проверки утилитой clang-analyze -add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + # Создание цели для проверки утилитой clang-tidy + add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -# Создание цели для проверки утилитой clazy -add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + # Создание цели для проверки утилитой clang-analyze + add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -# Создание цели для проверки утилитой pvs-studio -add_pvs_check(${TRGT}) + # Создание цели для проверки утилитой clazy + add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -# Создание цели для автоматического форматирования кода -add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + # Создание цели для проверки утилитой pvs-studio + add_pvs_check(${TRGT}) -if(MYXLIB_HEADER_ONLY) - target_include_directories(${TRGT} SYSTEM INTERFACE - "$" - "$") -else() - target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) + # Создание цели для автоматического форматирования кода + add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + + target_compile_definitions(${TRGT} PUBLIC MYXLIB_BUILD_LIBRARIES) + target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) cotire(${TRGT}) - install( - TARGETS ${TRGT}_static - COMPONENT libs-dev - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + 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}) + install(TARGETS ${TRGT}_shared COMPONENT main LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() endif() -install( - FILES ${TRGT_headers} - ${CMAKE_BINARY_DIR}/include/myx/base/compiler_features.hpp - COMPONENT headers - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) +install(FILES ${TRGT_headers} ${CMAKE_BINARY_DIR}/include/myx/base/compiler_features.hpp COMPONENT headers + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) -install( - FILES ${CMAKE_BINARY_DIR}/${TRGT}.pc - COMPONENT headers - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${CMAKE_BINARY_DIR}/${TRGT}.pc COMPONENT headers DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) # Цель, используемая только для установки заголовочных файлов без компиляции проекта -add_custom_target( - ${TRGT}-install-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=headers -P - "${CMAKE_BINARY_DIR}/cmake_install.cmake") +add_custom_target(${TRGT}-install-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=headers -P + "${CMAKE_BINARY_DIR}/cmake_install.cmake") diff --git a/src/myx/base/config.hpp b/src/myx/base/config.hpp index 4c46e74..d90a0ef 100644 --- a/src/myx/base/config.hpp +++ b/src/myx/base/config.hpp @@ -3,7 +3,11 @@ #pragma once -// #include +#ifdef MYXLIB_BUILD_LIBRARIES +#undef MYXLIB_HEADER_ONLY +#else +#define MYXLIB_HEADER_ONLY +#endif #ifdef MYXLIB_HEADER_ONLY #include "config-inl.hpp" diff --git a/src/myx/filesystem/CMakeLists.txt b/src/myx/filesystem/CMakeLists.txt index 67251cb..b38ea82 100644 --- a/src/myx/filesystem/CMakeLists.txt +++ b/src/myx/filesystem/CMakeLists.txt @@ -22,41 +22,40 @@ set(TRGT_hpp set(TRGT_headers ${TRGT_hpp}) # cmake-format: on -if(NOT MYXLIB_HEADER_ONLY) - add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_cpp} ${TRGT_headers}) - common_target_properties(${TRGT}) -else() - add_library(${TRGT} INTERFACE) -endif() +add_library(${TRGT}-header-only INTERFACE) +target_include_directories( + ${TRGT}-header-only SYSTEM INTERFACE "$" + "$") -# Создание цели для проверки утилитой clang-tidy -add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) +if(MYXLIB_BUILD_LIBRARIES) -# Создание цели для проверки утилитой clang-analyze -add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_cpp} ${TRGT_headers}) + common_target_properties(${TRGT}) -# Создание цели для проверки утилитой clazy -add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + # Создание цели для проверки утилитой clang-tidy + add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -# Создание цели для проверки утилитой pvs-studio -add_pvs_check(${TRGT}) + # Создание цели для проверки утилитой clang-analyze + add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -# Создание цели для автоматического форматирования кода -add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + # Создание цели для проверки утилитой clazy + add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -if(NOT MYXLIB_HEADER_ONLY) - target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) - target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) - cotire(${TRGT}) + # Создание цели для проверки утилитой pvs-studio + add_pvs_check(${TRGT}) - 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() -else() - target_include_directories(${TRGT} SYSTEM INTERFACE - "$" - "$") + # Создание цели для автоматического форматирования кода + add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + + target_compile_definitions(${TRGT} PUBLIC MYXLIB_BUILD_LIBRARIES) + target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) + target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) + cotire(${TRGT}) + + 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() endif() install(FILES ${TRGT_headers} COMPONENT DEV DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) diff --git a/src/myx/filesystem/current_executable.hpp b/src/myx/filesystem/current_executable.hpp index f8d0402..737f3d0 100644 --- a/src/myx/filesystem/current_executable.hpp +++ b/src/myx/filesystem/current_executable.hpp @@ -8,6 +8,8 @@ #pragma once +#include + #include #include #include diff --git a/src/myx/filesystem/paths.hpp b/src/myx/filesystem/paths.hpp index 7049428..812a5a9 100644 --- a/src/myx/filesystem/paths.hpp +++ b/src/myx/filesystem/paths.hpp @@ -8,6 +8,7 @@ #pragma once +#include #include #include diff --git a/src/myx/filesystem/paths_mt.hpp b/src/myx/filesystem/paths_mt.hpp index 9a85287..0d3e4c2 100644 --- a/src/myx/filesystem/paths_mt.hpp +++ b/src/myx/filesystem/paths_mt.hpp @@ -8,6 +8,7 @@ #pragma once +#include #include #include diff --git a/src/myx/math/CMakeLists.txt b/src/myx/math/CMakeLists.txt index cdcd70b..266b98c 100644 --- a/src/myx/math/CMakeLists.txt +++ b/src/myx/math/CMakeLists.txt @@ -26,36 +26,44 @@ set(TRGT_hpp set(TRGT_headers ${TRGT_hpp}) # cmake-format: on -add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_sources} ${TRGT_headers}) -common_target_properties(${TRGT}) +add_library(${TRGT}-header-only INTERFACE) +target_include_directories( + ${TRGT}-header-only SYSTEM INTERFACE "$" + "$") -# Создание цели для проверки утилитой clang-tidy -add_clang_tidy_check(${TRGT} ${TRGT_sources} ${TRGT_headers}) +if(MYXLIB_BUILD_LIBRARIES) -# Создание цели для проверки утилитой clang-analyze -add_clang_analyze_check(${TRGT} ${TRGT_sources} ${TRGT_headers}) + add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_sources} ${TRGT_headers}) + common_target_properties(${TRGT}) -# Создание цели для проверки утилитой clazy -add_clazy_check(${TRGT} ${TRGT_sources} ${TRGT_headers}) + # Создание цели для проверки утилитой clang-tidy + add_clang_tidy_check(${TRGT} ${TRGT_sources} ${TRGT_headers}) -# Создание цели для проверки утилитой pvs-studio -add_pvs_check(${TRGT}) + # Создание цели для проверки утилитой clang-analyze + add_clang_analyze_check(${TRGT} ${TRGT_sources} ${TRGT_headers}) -# Создание цели для автоматического форматирования кода -add_format_sources(${TRGT} ${TRGT_sources} ${TRGT_headers}) + # Создание цели для проверки утилитой clazy + add_clazy_check(${TRGT} ${TRGT_sources} ${TRGT_headers}) -target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) + # Создание цели для проверки утилитой pvs-studio + add_pvs_check(${TRGT}) -cotire(${TRGT}) + # Создание цели для автоматического форматирования кода + add_format_sources(${TRGT} ${TRGT_sources} ${TRGT_headers}) + + target_compile_definitions(${TRGT} PUBLIC MYXLIB_BUILD_LIBRARIES) + target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) + + cotire(${TRGT}) + install(TARGETS ${TRGT}_static COMPONENT DEV ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + if(BUILD_SHARED_LIBS) + install(TARGETS ${TRGT}_shared COMPONENT DEV LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() +endif() + +install(FILES ${TRGT_headers} COMPONENT DEV DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) +install(FILES ${CMAKE_BINARY_DIR}/${TRGT}.pc COMPONENT DEV DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) # Цель, используемая только для установки заголовочных файлов без компиляции проекта add_custom_target(${TRGT}-install-headers COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=DEV -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") - -# Правила для установки -install(TARGETS ${TRGT}_static COMPONENT DEV ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -if(BUILD_SHARED_LIBS) - install(TARGETS ${TRGT}_shared COMPONENT DEV LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() -install(FILES ${TRGT_headers} COMPONENT DEV DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) -install(FILES ${CMAKE_BINARY_DIR}/${TRGT}.pc COMPONENT DEV DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/src/myx/qt/CMakeLists.txt b/src/myx/qt/CMakeLists.txt index d1951e8..83d8878 100644 --- a/src/myx/qt/CMakeLists.txt +++ b/src/myx/qt/CMakeLists.txt @@ -17,44 +17,43 @@ set(TRGT_hpp set(TRGT_headers ${TRGT_hpp}) # cmake-format: on -if(NOT MYXLIB_HEADER_ONLY) - add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_cpp} ${TRGT_headers}) - common_target_properties(${TRGT}) -else() - add_library(${TRGT} INTERFACE) +add_library(${TRGT}-header-only INTERFACE) +target_include_directories( + ${TRGT}-header-only SYSTEM INTERFACE "$" + "$") + +if(MYXLIB_BUILD_LIBRARIES) + add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_cpp} ${TRGT_headers}) + common_target_properties(${TRGT}) + + # Создание цели для проверки утилитой 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_compile_definitions(${TRGT} PUBLIC MYXLIB_BUILD_LIBRARIES) + target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) + target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) + cotire(${TRGT}) + + 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() endif() -# Создание цели для проверки утилитой 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}) - -if(NOT MYXLIB_HEADER_ONLY) - target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) - target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) - cotire(${TRGT}) - - 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() -else() - target_include_directories(${TRGT} SYSTEM INTERFACE - "$" - "$") -endif() - -install(FILES ${TRGT_headers} COMPONENT headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) +install(FILES ${TRGT_headers} COMPONENT headers + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) install(FILES ${CMAKE_BINARY_DIR}/${TRGT}.pc COMPONENT headers DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) # Цель, используемая только для установки заголовочных файлов без компиляции проекта diff --git a/src/myx/qt/translators.hpp b/src/myx/qt/translators.hpp index 9d2dc87..1529c4c 100644 --- a/src/myx/qt/translators.hpp +++ b/src/myx/qt/translators.hpp @@ -1,6 +1,7 @@ #ifndef MYX_LOG_QT_TRANSLATORS_HPP_ #define MYX_LOG_QT_TRANSLATORS_HPP_ +#include #include #include diff --git a/src/myx/redis/CMakeLists.txt b/src/myx/redis/CMakeLists.txt index 6042023..42eacee 100644 --- a/src/myx/redis/CMakeLists.txt +++ b/src/myx/redis/CMakeLists.txt @@ -22,38 +22,45 @@ set(TRGT_moc_hpp set(TRGT_headers ${TRGT_hpp}) # cmake-format: on -add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_cpp} ${TRGT_headers}) -common_target_properties(${TRGT}) +add_library(${TRGT}-header-only INTERFACE) +target_include_directories( + ${TRGT}-header-only SYSTEM INTERFACE "$" + "$") -# Создание цели для проверки утилитой clang-tidy -add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) +if(MYXLIB_BUILD_LIBRARIES) + add_common_library(${TRGT} OUTPUT_NAME myx-${TRGT} SOURCES ${TRGT_cpp} ${TRGT_headers}) + common_target_properties(${TRGT}) -# Создание цели для проверки утилитой clang-analyze -add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + # Создание цели для проверки утилитой clang-tidy + add_clang_tidy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -# Создание цели для проверки утилитой clazy -add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + # Создание цели для проверки утилитой clang-analyze + add_clang_analyze_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -# Создание цели для проверки утилитой pvs-studio -add_pvs_check(${TRGT}) + # Создание цели для проверки утилитой clazy + add_clazy_check(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -# Создание цели для автоматического форматирования кода -add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers}) + # Создание цели для проверки утилитой pvs-studio + add_pvs_check(${TRGT}) -target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) -target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Network_INCLUDE_DIRS}) -target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) + # Создание цели для автоматического форматирования кода + add_format_sources(${TRGT} ${TRGT_cpp} ${TRGT_headers}) -cotire(${TRGT}) + target_compile_definitions(${TRGT} PUBLIC MYXLIB_BUILD_LIBRARIES) + target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS}) + target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Network_INCLUDE_DIRS}) + target_include_directories(${TRGT} SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/src) + + cotire(${TRGT}) + install(TARGETS ${TRGT}_static COMPONENT DEV ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + if(BUILD_SHARED_LIBS) + install(TARGETS ${TRGT}_shared COMPONENT DEV LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() +endif() + +install(FILES ${TRGT_headers} COMPONENT DEV DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) +install(FILES ${CMAKE_BINARY_DIR}/${TRGT}.pc COMPONENT DEV DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) # Цель, используемая только для установки заголовочных файлов без компиляции проекта add_custom_target(${TRGT}-install-headers COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_COMPONENT=DEV -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") - -# Правила для установки -install(TARGETS ${TRGT}_static COMPONENT DEV ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) -if(BUILD_SHARED_LIBS) - install(TARGETS ${TRGT}_shared COMPONENT DEV LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() -install(FILES ${TRGT_headers} COMPONENT DEV DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${TRGT}) -install(FILES ${CMAKE_BINARY_DIR}/${TRGT}.pc COMPONENT DEV DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)