Compare commits

..

No commits in common. "bd49df9c7c92a9be97303cfaa2b25dac5cc2e081" and "cbaf6091002d423ad21b94ba239303939e6ef472" have entirely different histories.

5 changed files with 51 additions and 55 deletions

View File

@ -50,30 +50,31 @@ function(myx_add_interface_library TARGET_NAME)
add_library(${TARGET_NAME} INTERFACE ${ARG_HEADERS}) add_library(${TARGET_NAME} INTERFACE ${ARG_HEADERS})
endif() endif()
foreach(iter ${ARG_PACKAGES})
target_include_directories(${TARGET_NAME} INTERFACE ${${iter}_INCLUDE_DIRS}) foreach(__iter ${ARG_PACKAGES})
target_compile_definitions(${TARGET_NAME} INTERFACE ${${iter}_COMPILE_DEFINITIONS}) target_include_directories(${TARGET_NAME} INTERFACE ${${__iter}_INCLUDE_DIRS})
target_compile_definitions(${TARGET_NAME} INTERFACE ${${__iter}_COMPILE_DEFINITIONS})
endforeach() endforeach()
if(ARG_LINK_LIBRARIES) if(ARG_LINK_LIBRARIES)
foreach(lib ${ARG_LINK_LIBRARIES}) foreach(__lib ${ARG_LINK_LIBRARIES})
if(TARGET ${lib}) if(TARGET ${__lib})
set(exlib ${lib}) set(__exlib ${__lib})
if(${CMAKE_VERSION} VERSION_GREATER "3.13.0") if(${CMAKE_VERSION} VERSION_LESS "3.15.0")
install(TARGETS ${lib} get_target_property(__target_type ${__lib} TYPE)
if(__target_type STREQUAL "OBJECT_LIBRARY")
if(TARGET "${__lib}_static")
set(__exlib "${__lib}_static")
elseif(TARGET "${__lib}_shared")
set(__exlib "${__lib}_shared")
endif()
endif()
else()
install(TARGETS ${__lib}
EXPORT ${TARGET_NAME}Targets EXPORT ${TARGET_NAME}Targets
COMPONENT DEV) COMPONENT DEV)
else()
get_target_property(target_type ${lib} TYPE)
if(target_type STREQUAL "OBJECT_LIBRARY")
if(TARGET "${lib}_static")
set(exlib "${lib}_static")
elseif(TARGET "${lib}_shared")
set(exlib "${lib}_shared")
endif() endif()
endif() target_link_libraries(${TARGET_NAME} INTERFACE ${__exlib})
endif()
target_link_libraries(${TARGET_NAME} INTERFACE ${exlib})
endif() endif()
endforeach() endforeach()
endif() endif()
@ -115,12 +116,9 @@ function(myx_add_interface_library TARGET_NAME)
NO_CHECK_REQUIRED_COMPONENTS_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO
) )
if(${CMAKE_VERSION} VERSION_GREATER "3.13.0") install(EXPORT ${TARGET_NAME}Targets
install(
EXPORT ${TARGET_NAME}Targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
COMPONENT DEV) COMPONENT DEV)
endif()
install( install(
FILES FILES
@ -150,12 +148,10 @@ function(myx_add_interface_library TARGET_NAME)
# Установка библиотеки из заголовочных файлов # Установка библиотеки из заголовочных файлов
target_include_directories(${TARGET_NAME} SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) target_include_directories(${TARGET_NAME} SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
if(${CMAKE_VERSION} VERSION_GREATER "3.13.0")
install( install(
TARGETS ${TARGET_NAME} TARGETS ${TARGET_NAME}
EXPORT ${TARGET_NAME}Targets EXPORT ${TARGET_NAME}Targets
COMPONENT DEV) COMPONENT DEV)
endif()
# Установка публичных заголовочных файлов # Установка публичных заголовочных файлов
if(PROJECT_IS_TOP_LEVEL AND ARG_HEADERS) if(PROJECT_IS_TOP_LEVEL AND ARG_HEADERS)

View File

@ -44,12 +44,12 @@ function(myx_add_object_library TARGET_NAME)
# Вызов стандартной функции `add_library()` # Вызов стандартной функции `add_library()`
add_library(${TARGET_NAME} OBJECT ${ARG_UNPARSED_ARGUMENTS}) add_library(${TARGET_NAME} OBJECT ${ARG_UNPARSED_ARGUMENTS})
string(TOUPPER ${TARGET_NAME} project_name_upper) string(TOUPPER ${TARGET_NAME} __project_name_upper)
# Опция для разрешения сборки динамической библиотеки # Опция для разрешения сборки динамической библиотеки
cmake_dependent_option(${project_name_upper}_BUILD_SHARED cmake_dependent_option(${__project_name_upper}_BUILD_SHARED
"Build shared library for ${TARGET_NAME}" ON "BUILD_SHARED_LIBS" OFF) "Build shared library for ${TARGET_NAME}" ON "BUILD_SHARED_LIBS" OFF)
# Опция для разрешения сборки статической библиотеки # Опция для разрешения сборки статической библиотеки
cmake_dependent_option(${project_name_upper}_BUILD_STATIC cmake_dependent_option(${__project_name_upper}_BUILD_STATIC
"Build static library for ${TARGET_NAME}" ON "NOT BUILD_SHARED_LIBS" OFF) "Build static library for ${TARGET_NAME}" ON "NOT BUILD_SHARED_LIBS" OFF)
# Стандартные пути к заголовочным файлам # Стандартные пути к заголовочным файлам
@ -68,7 +68,7 @@ function(myx_add_object_library TARGET_NAME)
if(NOT ARG_NO_EXPORT) if(NOT ARG_NO_EXPORT)
include(GenerateExportHeader) include(GenerateExportHeader)
if(NOT EXPORT_BASE_NAME) if(NOT EXPORT_BASE_NAME)
set(ARG_EXPORT_BASE_NAME ${project_name_upper}) set(ARG_EXPORT_BASE_NAME ${__project_name_upper})
endif() endif()
if(NOT ARG_EXPORT_FILE_NAME) if(NOT ARG_EXPORT_FILE_NAME)
@ -89,7 +89,7 @@ function(myx_add_object_library TARGET_NAME)
endif() endif()
# Цель для создания динамической библиотеки из объектных файлов # Цель для создания динамической библиотеки из объектных файлов
if(${project_name_upper}_BUILD_SHARED) if(${__project_name_upper}_BUILD_SHARED)
# Для создания динамической библиотеки используются объектные файлы цели ${TARGET_NAME} # Для создания динамической библиотеки используются объектные файлы цели ${TARGET_NAME}
add_library(${TARGET_NAME}_shared SHARED $<TARGET_OBJECTS:${TARGET_NAME}>) add_library(${TARGET_NAME}_shared SHARED $<TARGET_OBJECTS:${TARGET_NAME}>)
# Установка дополнительных свойств для цели ${TARGET_NAME}_shared # Установка дополнительных свойств для цели ${TARGET_NAME}_shared
@ -105,7 +105,7 @@ function(myx_add_object_library TARGET_NAME)
endif() endif()
# Цель для создания статической библиотеки из объектных файлов # Цель для создания статической библиотеки из объектных файлов
if(${project_name_upper}_BUILD_STATIC) if(${__project_name_upper}_BUILD_STATIC)
# Для создания статической библиотеки используются # Для создания статической библиотеки используются
# объектные файлы цели ${TARGET_NAME} # объектные файлы цели ${TARGET_NAME}
add_library(${TARGET_NAME}_static STATIC $<TARGET_OBJECTS:${TARGET_NAME}>) add_library(${TARGET_NAME}_static STATIC $<TARGET_OBJECTS:${TARGET_NAME}>)

View File

@ -5,11 +5,11 @@ include_guard(GLOBAL)
# (Файл перемещён из каталога backports в lib для myx_download_content) # (Файл перемещён из каталога backports в lib для myx_download_content)
# #
if(${CMAKE_VERSION} VERSION_LESS 3.21) if(${CMAKE_VERSION} VERSION_LESS 3.21)
get_property(pd DIRECTORY PROPERTY PARENT_DIRECTORY) get_property(__parent_directory DIRECTORY PROPERTY PARENT_DIRECTORY)
if(NOT pd) if(NOT __parent_directory)
set(PROJECT_IS_TOP_LEVEL TRUE) set(PROJECT_IS_TOP_LEVEL TRUE)
else() else()
set(PROJECT_IS_TOP_LEVEL FALSE) set(PROJECT_IS_TOP_LEVEL FALSE)
endif() endif()
unset(pd) unset(__parent_directory)
endif() endif()

View File

@ -12,8 +12,8 @@ function(myx_target_setup TARGET_NAME)
myx_message_fatal_error("Target ${TARGET_NAME} does not exists.") myx_message_fatal_error("Target ${TARGET_NAME} does not exists.")
endif() endif()
get_target_property(target_type ${TARGET_NAME} TYPE) get_target_property(__target_type ${TARGET_NAME} TYPE)
if(${target_type} STREQUAL "INTERFACE_LIBRARY") if(${__target_type} STREQUAL "INTERFACE_LIBRARY")
myx_message_fatal_error("This function will not work for interface targets.") myx_message_fatal_error("This function will not work for interface targets.")
endif() endif()
@ -54,7 +54,7 @@ function(myx_target_setup TARGET_NAME)
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>) $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
endif() endif()
if(target_type STREQUAL "EXECUTABLE") if(__target_type STREQUAL "EXECUTABLE")
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/include") if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/include")
target_include_directories(${PROJECT_NAME} PRIVATE target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>) $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
@ -86,8 +86,8 @@ function(myx_target_setup TARGET_NAME)
if(${CMAKE_VERSION} VERSION_GREATER "3.11.99") if(${CMAKE_VERSION} VERSION_GREATER "3.11.99")
target_link_libraries(${TARGET_NAME} PRIVATE ${ARG_LINK_LIBRARIES}) target_link_libraries(${TARGET_NAME} PRIVATE ${ARG_LINK_LIBRARIES})
else() else()
if((NOT ${target_type} STREQUAL "OBJECT_LIBRARY") AND if((NOT ${__target_type} STREQUAL "OBJECT_LIBRARY") AND
(NOT ${target_type} STREQUAL "EXECUTABLE")) (NOT ${__target_type} STREQUAL "EXECUTABLE"))
target_link_libraries(${TARGET_NAME} PRIVATE ${ARG_LINK_LIBRARIES}) target_link_libraries(${TARGET_NAME} PRIVATE ${ARG_LINK_LIBRARIES})
else() else()
foreach(__link_library ${ARG_LINK_LIBRARIES}) foreach(__link_library ${ARG_LINK_LIBRARIES})
@ -98,7 +98,7 @@ function(myx_target_setup TARGET_NAME)
if(__include_dirs) if(__include_dirs)
target_include_directories(${TARGET_NAME} PUBLIC ${__include_dirs}) target_include_directories(${TARGET_NAME} PUBLIC ${__include_dirs})
endif() endif()
if(${target_type} STREQUAL "EXECUTABLE") if(${__target_type} STREQUAL "EXECUTABLE")
if(${__lib_type} STREQUAL "OBJECT_LIBRARY") if(${__lib_type} STREQUAL "OBJECT_LIBRARY")
if(TARGET ${__link_library}_static) if(TARGET ${__link_library}_static)
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}_static) target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}_static)
@ -111,7 +111,7 @@ function(myx_target_setup TARGET_NAME)
endif() endif()
endif() endif()
else() else()
if((${CMAKE_VERSION} VERSION_GREATER "3.7.99") OR (NOT target_type STREQUAL "OBJECT_LIBRARY")) if((${CMAKE_VERSION} VERSION_GREATER "3.7.99") OR (NOT __target_type STREQUAL "OBJECT_LIBRARY"))
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}) target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library})
endif() endif()
endif() endif()

View File

@ -16,21 +16,21 @@ function(myx_target_setup_qt TARGET_NAME)
myx_message_fatal_error("Supported Qt versions are 5 and 6") myx_message_fatal_error("Supported Qt versions are 5 and 6")
endif() endif()
get_target_property(target_type ${TARGET_NAME} TYPE) get_target_property(__target_type ${TARGET_NAME} TYPE)
foreach(iter ${ARG_COMPONENTS}) foreach(iter ${ARG_COMPONENTS})
if(target_type STREQUAL "INTERFACE_LIBRARY") if(__target_type STREQUAL "INTERFACE_LIBRARY")
target_include_directories(${TARGET_NAME} INTERFACE ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} INTERFACE ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS})
else() else()
target_include_directories(${TARGET_NAME} PRIVATE ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} PRIVATE ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS})
if(NOT iter STREQUAL "LinguistTools") if(NOT iter STREQUAL "LinguistTools")
if(target_type STREQUAL "EXECUTABLE") if(__target_type STREQUAL "EXECUTABLE")
target_link_libraries(${TARGET_NAME} PRIVATE Qt${myx_qt_ver}::${iter}) target_link_libraries(${TARGET_NAME} PRIVATE Qt${myx_qt_ver}::${iter})
endif() endif()
if(target_type STREQUAL "SHARED_LIBRARY") if(__target_type STREQUAL "SHARED_LIBRARY")
target_link_libraries(${TARGET_NAME} PUBLIC Qt${myx_qt_ver}::${iter}) target_link_libraries(${TARGET_NAME} PUBLIC Qt${myx_qt_ver}::${iter})
endif() endif()
if((${CMAKE_VERSION} VERSION_GREATER "3.8.0") AND (target_type STREQUAL "OBJECT_LIBRARY")) if((${CMAKE_VERSION} VERSION_GREATER "3.8.0") AND (__target_type STREQUAL "OBJECT_LIBRARY"))
target_link_libraries(${TARGET_NAME} PUBLIC Qt${myx_qt_ver}::${iter}) target_link_libraries(${TARGET_NAME} PUBLIC Qt${myx_qt_ver}::${iter})
else() else()
target_include_directories(${TARGET_NAME} PUBLIC ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} PUBLIC ${Qt${myx_qt_ver}${iter}_INCLUDE_DIRS})
@ -40,14 +40,14 @@ function(myx_target_setup_qt TARGET_NAME)
endforeach() endforeach()
foreach(iter ${ARG_PRIVATE}) foreach(iter ${ARG_PRIVATE})
if(target_type STREQUAL "INTERFACE_LIBRARY") if(__target_type STREQUAL "INTERFACE_LIBRARY")
target_include_directories(${TARGET_NAME} INTERFACE ${Qt${myx_qt_ver}${iter}_PRIVATE_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} INTERFACE ${Qt${myx_qt_ver}${iter}_PRIVATE_INCLUDE_DIRS})
else() else()
target_include_directories(${TARGET_NAME} PRIVATE ${Qt${myx_qt_ver}${iter}_PRIVATE_INCLUDE_DIRS}) target_include_directories(${TARGET_NAME} PRIVATE ${Qt${myx_qt_ver}${iter}_PRIVATE_INCLUDE_DIRS})
endif() endif()
endforeach() endforeach()
if(target_type STREQUAL "EXECUTABLE") if(__target_type STREQUAL "EXECUTABLE")
target_compile_options(${TARGET_NAME} PRIVATE ${Qt${myx_qt_ver}Core_EXECUTABLE_COMPILE_FLAGS}) target_compile_options(${TARGET_NAME} PRIVATE ${Qt${myx_qt_ver}Core_EXECUTABLE_COMPILE_FLAGS})
endif() endif()
@ -94,7 +94,7 @@ function(myx_target_setup_qt TARGET_NAME)
endif() endif()
# Перечень файлов, подлежащих переводу # Перечень файлов, подлежащих переводу
if(target_type STREQUAL "INTERFACE_LIBRARY") if(__target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(tr ${TARGET_NAME} INTERFACE_TR_FILES) get_target_property(tr ${TARGET_NAME} INTERFACE_TR_FILES)
else() else()
get_target_property(tr ${TARGET_NAME} TR_FILES) get_target_property(tr ${TARGET_NAME} TR_FILES)
@ -138,7 +138,7 @@ function(myx_target_setup_qt TARGET_NAME)
endif() endif()
endif() endif()
unset(tr) unset(tr)
if(target_type STREQUAL "INTERFACE_LIBRARY") if(__target_type STREQUAL "INTERFACE_LIBRARY")
target_sources(${TARGET_NAME} INTERFACE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp}) target_sources(${TARGET_NAME} INTERFACE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})
else() else()
target_sources(${TARGET_NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp}) target_sources(${TARGET_NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})