Переименования

This commit is contained in:
Andrei Astafev 2024-03-12 16:27:30 +03:00
parent 2077833259
commit 205c4d7f80
5 changed files with 39 additions and 40 deletions

View File

@ -50,31 +50,30 @@ 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})
foreach(__iter ${ARG_PACKAGES}) target_include_directories(${TARGET_NAME} INTERFACE ${${iter}_INCLUDE_DIRS})
target_include_directories(${TARGET_NAME} INTERFACE ${${__iter}_INCLUDE_DIRS}) target_compile_definitions(${TARGET_NAME} INTERFACE ${${iter}_COMPILE_DEFINITIONS})
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_GREATER "3.13.0")
install(TARGETS ${__lib} install(TARGETS ${lib}
EXPORT ${TARGET_NAME}Targets EXPORT ${TARGET_NAME}Targets
COMPONENT DEV) COMPONENT DEV)
get_target_property(__target_type ${__lib} TYPE) get_target_property(target_type ${lib} TYPE)
else() else()
if(__target_type STREQUAL "OBJECT_LIBRARY") if(target_type STREQUAL "OBJECT_LIBRARY")
if(TARGET "${__lib}_static") if(TARGET "${lib}_static")
set(__exlib "${__lib}_static") set(exlib "${lib}_static")
elseif(TARGET "${__lib}_shared") elseif(TARGET "${lib}_shared")
set(__exlib "${__lib}_shared") set(exlib "${lib}_shared")
endif() endif()
endif() endif()
endif() endif()
target_link_libraries(${TARGET_NAME} INTERFACE ${__exlib}) target_link_libraries(${TARGET_NAME} INTERFACE ${exlib})
endif() endif()
endforeach() endforeach()
endif() endif()

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(__parent_directory DIRECTORY PROPERTY PARENT_DIRECTORY) get_property(pd DIRECTORY PROPERTY PARENT_DIRECTORY)
if(NOT __parent_directory) if(NOT pd)
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(__parent_directory) unset(pd)
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})