myx update
This commit is contained in:
parent
3d18e29714
commit
a1a22464df
@ -16,11 +16,6 @@ set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib")
|
||||
|
||||
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
|
||||
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.9.0")
|
||||
include(${MYX_CMAKE_BACKPORTS_DIR}/CheckIPOSupported.cmake)
|
||||
else()
|
||||
include(CheckIPOSupported)
|
||||
endif()
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
|
||||
include(${MYX_CMAKE_BACKPORTS_DIR}/FetchContent.cmake)
|
||||
else()
|
||||
|
@ -1,4 +1,4 @@
|
||||
set(MYX_CMAKE_PACKAGE_VERSION "2.0.17")
|
||||
set(MYX_CMAKE_PACKAGE_VERSION "2.0.19")
|
||||
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
|
@ -1,186 +0,0 @@
|
||||
# X_RESULT - name of the final result variable
|
||||
# X_OUTPUT - name of the variable with information about error
|
||||
macro(_ipo_not_supported output)
|
||||
if(NOT X_RESULT)
|
||||
message(FATAL_ERROR "IPO is not supported (${output}).")
|
||||
endif()
|
||||
|
||||
set("${X_RESULT}" NO PARENT_SCOPE)
|
||||
if(X_OUTPUT)
|
||||
set("${X_OUTPUT}" "${output}" PARENT_SCOPE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Run IPO/LTO test
|
||||
macro(_ipo_run_language_check language)
|
||||
set(testdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/_CMakeLTOTest-${language}")
|
||||
|
||||
file(REMOVE_RECURSE "${testdir}")
|
||||
file(MAKE_DIRECTORY "${testdir}")
|
||||
|
||||
set(bindir "${testdir}/bin")
|
||||
set(srcdir "${testdir}/src")
|
||||
|
||||
file(MAKE_DIRECTORY "${bindir}")
|
||||
file(MAKE_DIRECTORY "${srcdir}")
|
||||
|
||||
set(TRY_COMPILE_PROJECT_NAME "lto-test")
|
||||
|
||||
set(try_compile_src "${CMAKE_ROOT}/Modules/CheckIPOSupported")
|
||||
|
||||
# Use:
|
||||
# * TRY_COMPILE_PROJECT_NAME
|
||||
# * CMAKE_VERSION
|
||||
configure_file(
|
||||
"${try_compile_src}/CMakeLists-${language}.txt.in"
|
||||
"${srcdir}/CMakeLists.txt"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
string(COMPARE EQUAL "${language}" "C" is_c)
|
||||
string(COMPARE EQUAL "${language}" "CXX" is_cxx)
|
||||
string(COMPARE EQUAL "${language}" "Fortran" is_fortran)
|
||||
|
||||
if(is_c)
|
||||
set(copy_sources foo.c main.c)
|
||||
elseif(is_cxx)
|
||||
set(copy_sources foo.cpp main.cpp)
|
||||
elseif(is_fortran)
|
||||
set(copy_sources foo.f main.f)
|
||||
else()
|
||||
message(FATAL_ERROR "Language not supported")
|
||||
endif()
|
||||
|
||||
foreach(x ${copy_sources})
|
||||
configure_file(
|
||||
"${try_compile_src}/${x}"
|
||||
"${srcdir}/${x}"
|
||||
COPYONLY
|
||||
)
|
||||
endforeach()
|
||||
|
||||
try_compile(
|
||||
_IPO_LANGUAGE_CHECK_RESULT
|
||||
"${bindir}"
|
||||
"${srcdir}"
|
||||
"${TRY_COMPILE_PROJECT_NAME}"
|
||||
CMAKE_FLAGS
|
||||
"-DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON"
|
||||
OUTPUT_VARIABLE output
|
||||
)
|
||||
set(_IPO_LANGUAGE_CHECK_RESULT "${_IPO_LANGUAGE_CHECK_RESULT}")
|
||||
unset(_IPO_LANGUAGE_CHECK_RESULT CACHE)
|
||||
|
||||
if(NOT _IPO_LANGUAGE_CHECK_RESULT)
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"${language} compiler IPO check failed with the following output:\n"
|
||||
"${output}\n")
|
||||
_ipo_not_supported("check failed to compile")
|
||||
if(X_OUTPUT)
|
||||
set("${X_OUTPUT}" "${output}" PARENT_SCOPE)
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(check_ipo_supported)
|
||||
cmake_policy(GET CMP0069 x)
|
||||
|
||||
string(COMPARE EQUAL "${x}" "" not_set)
|
||||
if(not_set)
|
||||
message(FATAL_ERROR "Policy CMP0069 is not set")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${x}" "OLD" is_old)
|
||||
if(is_old)
|
||||
message(FATAL_ERROR "Policy CMP0069 set to OLD")
|
||||
endif()
|
||||
|
||||
set(optional)
|
||||
set(one RESULT OUTPUT)
|
||||
set(multiple LANGUAGES)
|
||||
|
||||
# Introduce:
|
||||
# * X_RESULT
|
||||
# * X_OUTPUT
|
||||
# * X_LANGUAGES
|
||||
cmake_parse_arguments(X "${optional}" "${one}" "${multiple}" "${ARGV}")
|
||||
|
||||
string(COMPARE NOTEQUAL "${X_UNPARSED_ARGUMENTS}" "" has_unparsed)
|
||||
if(has_unparsed)
|
||||
message(FATAL_ERROR "Unparsed arguments: ${X_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${X_LANGUAGES}" "" no_languages)
|
||||
if(no_languages)
|
||||
# User did not set any languages, use defaults
|
||||
get_property(enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
string(COMPARE EQUAL "${enabled_languages}" "" no_languages)
|
||||
if(no_languages)
|
||||
_ipo_not_supported(
|
||||
"no languages found in ENABLED_LANGUAGES global property"
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(languages "")
|
||||
list(FIND enabled_languages "CXX" result)
|
||||
if(NOT result EQUAL -1)
|
||||
list(APPEND languages "CXX")
|
||||
endif()
|
||||
|
||||
list(FIND enabled_languages "C" result)
|
||||
if(NOT result EQUAL -1)
|
||||
list(APPEND languages "C")
|
||||
endif()
|
||||
|
||||
list(FIND enabled_languages "Fortran" result)
|
||||
if(NOT result EQUAL -1)
|
||||
list(APPEND languages "Fortran")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${languages}" "" no_languages)
|
||||
if(no_languages)
|
||||
_ipo_not_supported(
|
||||
"no C/CXX/Fortran languages found in ENABLED_LANGUAGES global property"
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
set(languages "${X_LANGUAGES}")
|
||||
|
||||
set(unsupported_languages "${languages}")
|
||||
list(REMOVE_ITEM unsupported_languages "C" "CXX" "Fortran")
|
||||
string(COMPARE NOTEQUAL "${unsupported_languages}" "" has_unsupported)
|
||||
if(has_unsupported)
|
||||
_ipo_not_supported(
|
||||
"language(s) '${unsupported_languages}' not supported"
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(lang ${languages})
|
||||
if(NOT _CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE)
|
||||
_ipo_not_supported("CMake doesn't support IPO for current ${lang} compiler")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT _CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER)
|
||||
_ipo_not_supported("${lang} compiler doesn't support IPO")
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES "^Visual Studio 9 ")
|
||||
_ipo_not_supported("CMake doesn't support IPO for current generator")
|
||||
return()
|
||||
endif()
|
||||
|
||||
foreach(x ${languages})
|
||||
_ipo_run_language_check(${x})
|
||||
endforeach()
|
||||
|
||||
set("${X_RESULT}" YES PARENT_SCOPE)
|
||||
endfunction()
|
@ -1,8 +0,0 @@
|
||||
cmake_minimum_required(VERSION "@CMAKE_VERSION@")
|
||||
project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES C)
|
||||
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
|
||||
add_library(foo foo.c)
|
||||
add_executable(boo main.c)
|
||||
target_link_libraries(boo PUBLIC foo)
|
@ -1,8 +0,0 @@
|
||||
cmake_minimum_required(VERSION "@CMAKE_VERSION@")
|
||||
project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES CXX)
|
||||
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
|
||||
add_library(foo foo.cpp)
|
||||
add_executable(boo main.cpp)
|
||||
target_link_libraries(boo PUBLIC foo)
|
@ -1,8 +0,0 @@
|
||||
cmake_minimum_required(VERSION "@CMAKE_VERSION@")
|
||||
project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES Fortran)
|
||||
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
|
||||
add_library(foo foo.f)
|
||||
add_executable(boo main.f)
|
||||
target_link_libraries(boo PUBLIC foo)
|
@ -1,4 +0,0 @@
|
||||
int foo()
|
||||
{
|
||||
return 0x42;
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
int foo()
|
||||
{
|
||||
return 0x42;
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
SUBROUTINE FOO
|
||||
END
|
@ -1,6 +0,0 @@
|
||||
int foo();
|
||||
|
||||
int main()
|
||||
{
|
||||
return foo();
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
int foo();
|
||||
|
||||
int main()
|
||||
{
|
||||
return foo();
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
PROGRAM BOO
|
||||
CALL FOO()
|
||||
END
|
@ -4,7 +4,7 @@ myx_add_executable
|
||||
|
||||
Вспомогательная функция для создания исполняемого файла::
|
||||
|
||||
myx_add_executable(NAME)
|
||||
myx_add_executable(TARGET_NAME)
|
||||
|
||||
Используется для совместимости с версиями CMake раньше 3.11,
|
||||
в которых было необходимо указать хотя бы один файл с исходными текстами.
|
||||
@ -13,10 +13,10 @@ myx_add_executable
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
function(myx_add_executable NAME)
|
||||
function(myx_add_executable TARGET_NAME)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
|
||||
add_executable(${NAME} ${ARGN} "")
|
||||
add_executable(${TARGET_NAME} ${ARGN} "")
|
||||
else()
|
||||
add_executable(${NAME} ${ARGN})
|
||||
add_executable(${TARGET_NAME} ${ARGN})
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -4,12 +4,12 @@ myx_add_library
|
||||
|
||||
Вспомогательная функция для создания библиотеки::
|
||||
|
||||
myx_add_library(NAME TYPE
|
||||
myx_add_library(TARGET_NAME TARGET_TYPE
|
||||
[ OUTPUT_NAME output_name ] |
|
||||
[ EXPORT_FILE_NAME file_name ] |
|
||||
[ EXPORT_BASE_NAME base_name ])
|
||||
|
||||
Обязательные параметры: `NAME` - имя библиотеки и `TYPE` - тип цели.
|
||||
Обязательные параметры: `TARGET_NAME` - имя библиотеки и `TARGET_TYPE` - тип цели.
|
||||
Параметр `OUTPUT_NAME` определяет базовое имя выходных файлов.
|
||||
Параметр `EXPORT_FILE_NAME` задаёт имя заголовочного файла экспортируемых
|
||||
переменных, а `EXPORT_BASE_NAME` - базовый суффикс для формирования имён переменных.
|
||||
@ -26,7 +26,7 @@ if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||||
set(MYX_CMAKE_LIB_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
|
||||
endif()
|
||||
|
||||
function(myx_add_library NAME TYPE)
|
||||
function(myx_add_library TARGET_NAME TARGET_TYPE)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DIR_BACKPORT})
|
||||
endif()
|
||||
@ -37,27 +37,28 @@ function(myx_add_library NAME TYPE)
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT ARG_OUTPUT_NAME)
|
||||
set(ARG_OUTPUT_NAME ${NAME})
|
||||
set(ARG_OUTPUT_NAME ${TARGET_NAME})
|
||||
endif()
|
||||
|
||||
# Вызов стандартной функции `add_library()`
|
||||
add_library(${NAME} ${TYPE} ${ARG_UNPARSED_ARGUMENTS})
|
||||
add_library(${TARGET_NAME} ${TARGET_TYPE} ${ARG_UNPARSED_ARGUMENTS})
|
||||
|
||||
if(TYPE STREQUAL "INTERFACE")
|
||||
if(TARGET_TYPE STREQUAL "INTERFACE")
|
||||
# Библиотека, состоящая только из заголовочных файлов не требует сборки.
|
||||
# Стандартные пути к заголовочным файлам
|
||||
target_include_directories(${NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
||||
target_include_directories(${TARGET_NAME} INTERFACE
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
||||
else()
|
||||
string(TOUPPER ${NAME} PROJECT_NAME_UPPER)
|
||||
string(TOUPPER ${TARGET_NAME} __project_name_upper)
|
||||
# Опция для разрешения сборки динамической библиотеки
|
||||
cmake_dependent_option(${PROJECT_NAME_UPPER}_BUILD_SHARED
|
||||
"Build shared library for ${NAME}" ON "BUILD_SHARED_LIBS" OFF)
|
||||
cmake_dependent_option(${__project_name_upper}_BUILD_SHARED
|
||||
"Build shared library for ${TARGET_NAME}" ON "BUILD_SHARED_LIBS" OFF)
|
||||
# Опция для разрешения сборки статической библиотеки
|
||||
cmake_dependent_option(${PROJECT_NAME_UPPER}_BUILD_STATIC
|
||||
"Build static library for ${NAME}" ON "NOT BUILD_SHARED_LIBS" OFF)
|
||||
cmake_dependent_option(${__project_name_upper}_BUILD_STATIC
|
||||
"Build static library for ${TARGET_NAME}" ON "NOT BUILD_SHARED_LIBS" OFF)
|
||||
|
||||
# Стандартные пути к заголовочным файлам
|
||||
target_include_directories(${NAME}
|
||||
target_include_directories(${TARGET_NAME}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
PRIVATE
|
||||
@ -67,17 +68,18 @@ function(myx_add_library NAME TYPE)
|
||||
|
||||
# Сборка позиционно-независимых объектных файлов нужна
|
||||
# для создания динамической библиотеки
|
||||
set_target_properties(${NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
if(NOT EXPORT_BASE_NAME)
|
||||
string(TOUPPER ${NAME} ARG_EXPORT_BASE_NAME)
|
||||
set(ARG_EXPORT_BASE_NAME ${__project_name_upper})
|
||||
endif()
|
||||
|
||||
if(NOT ARG_EXPORT_FILE_NAME)
|
||||
set(ARG_EXPORT_FILE_NAME "${PROJECT_SOURCE_DIR}/include/${NAME}/${NAME}_export.hpp")
|
||||
set(ARG_EXPORT_FILE_NAME
|
||||
"${PROJECT_SOURCE_DIR}/include/${TARGET_NAME}/${TARGET_NAME}_export.hpp")
|
||||
endif()
|
||||
|
||||
generate_export_header(${NAME}
|
||||
generate_export_header(${TARGET_NAME}
|
||||
BASE_NAME ${ARG_EXPORT_BASE_NAME}
|
||||
EXPORT_MACRO_NAME "EXPORT_${ARG_EXPORT_BASE_NAME}"
|
||||
DEPRECATED_MACRO_NAME "DEPRECATED_${ARG_EXPORT_BASE_NAME}"
|
||||
@ -87,45 +89,45 @@ function(myx_add_library NAME TYPE)
|
||||
EXPORT_FILE_NAME ${ARG_EXPORT_FILE_NAME}
|
||||
DEFINE_NO_DEPRECATED
|
||||
)
|
||||
set_property(TARGET ${NAME} APPEND PROPERTY INTERFACE_HEADER_FILES "${ARG_EXPORT_FILE_NAME}")
|
||||
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY
|
||||
INTERFACE_HEADER_FILES "${ARG_EXPORT_FILE_NAME}")
|
||||
|
||||
# Цель для создания динамической библиотеки из объектных файлов
|
||||
if(${PROJECT_NAME_UPPER}_BUILD_SHARED)
|
||||
# Для создания динамической библиотеки используются объектные файлы цели ${NAME}
|
||||
add_library(${NAME}_shared SHARED $<TARGET_OBJECTS:${NAME}>)
|
||||
# Установка дополнительных свойств для цели ${NAME}_shared
|
||||
if(${__project_name_upper}_BUILD_SHARED)
|
||||
# Для создания динамической библиотеки используются объектные файлы цели ${TARGET_NAME}
|
||||
add_library(${TARGET_NAME}_shared SHARED $<TARGET_OBJECTS:${TARGET_NAME}>)
|
||||
# Установка дополнительных свойств для цели ${TARGET_NAME}_shared
|
||||
# VERSION: версия библиотеки
|
||||
# SOVERSION: мажорная версия библиотеки
|
||||
# LIBRARY_OUTPUT_DIRECTORY: каталог для записи результатов сборки
|
||||
# OUTPUT_NAME: базовое имя выходного файла (без учёта расширения)
|
||||
set_target_properties(${NAME}_shared
|
||||
PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
||||
OUTPUT_NAME ${ARG_OUTPUT_NAME})
|
||||
set_target_properties(${TARGET_NAME}_shared PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
||||
OUTPUT_NAME ${ARG_OUTPUT_NAME})
|
||||
endif()
|
||||
|
||||
# Цель для создания статической библиотеки из объектных файлов
|
||||
if(${PROJECT_NAME_UPPER}_BUILD_STATIC)
|
||||
# Для создания статической библиотеки используются объектные файлы цели ${NAME}
|
||||
add_library(${NAME}_static STATIC $<TARGET_OBJECTS:${NAME}>)
|
||||
# Установка дополнительных свойств для цели ${NAME}_static
|
||||
if(${__project_name_upper}_BUILD_STATIC)
|
||||
# Для создания статической библиотеки используются
|
||||
# объектные файлы цели ${TARGET_NAME}
|
||||
add_library(${TARGET_NAME}_static STATIC $<TARGET_OBJECTS:${TARGET_NAME}>)
|
||||
# Установка дополнительных свойств для цели ${TARGET_NAME}_static
|
||||
# ARCHIVE_OUTPUT_DIRECTORY: каталог для записи результатов сборки
|
||||
# OUTPUT_NAME: базовое имя выходного файла (без учёта расширения)
|
||||
set_target_properties(${NAME}_static
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
||||
OUTPUT_NAME ${ARG_OUTPUT_NAME})
|
||||
set_target_properties(${TARGET_NAME}_static PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
|
||||
OUTPUT_NAME ${ARG_OUTPUT_NAME})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Если вызов был выполнен не из проекта верхнего уровня,
|
||||
# то созданная цель исключается из цели `all`.
|
||||
# При этом сама цель `${NAME}` может участвовать в сборке,
|
||||
# При этом сама цель `${TARGET_NAME}` может участвовать в сборке,
|
||||
# если окажется в перечне зависимостей.
|
||||
if(NOT PROJECT_IS_TOP_LEVEL)
|
||||
set_target_properties(${NAME} PROPERTIES EXCLUDE_FROM_ALL True)
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES EXCLUDE_FROM_ALL True)
|
||||
return()
|
||||
endif()
|
||||
|
||||
@ -133,91 +135,91 @@ function(myx_add_library NAME TYPE)
|
||||
# Если вызов был выполнен не из проекта верхнего уровня,
|
||||
# то эти правила не обрабатываются.
|
||||
write_basic_package_version_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${NAME}ConfigVersion.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}ConfigVersion.cmake
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
configure_package_config_file(
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/library-config.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${NAME}Config.cmake
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}Config.cmake
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
|
||||
NO_SET_AND_CHECK_MACRO
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO
|
||||
)
|
||||
|
||||
install(EXPORT ${NAME}Targets
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||
install(EXPORT ${TARGET_NAME}Targets
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
|
||||
COMPONENT DEV
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${PROJECT_BINARY_DIR}/${NAME}ConfigVersion.cmake
|
||||
${PROJECT_BINARY_DIR}/${NAME}Config.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||
${PROJECT_BINARY_DIR}/${TARGET_NAME}ConfigVersion.cmake
|
||||
${PROJECT_BINARY_DIR}/${TARGET_NAME}Config.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TARGET_NAME}
|
||||
COMPONENT DEV
|
||||
)
|
||||
|
||||
# Формирование файла для pkg-config
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/${TARGET_NAME}.pc"
|
||||
"prefix=${CMAKE_INSTALL_PREFIX}\n"
|
||||
"exec_prefix=${CMAKE_INSTALL_PREFIX}\n"
|
||||
"includedir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n")
|
||||
|
||||
if(NOT TYPE STREQUAL "INTERFACE")
|
||||
file(APPEND "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||
if(NOT TARGET_TYPE STREQUAL "INTERFACE")
|
||||
file(APPEND "${PROJECT_BINARY_DIR}/${TARGET_NAME}.pc"
|
||||
"libdir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\n")
|
||||
endif()
|
||||
|
||||
file(APPEND "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||
file(APPEND "${PROJECT_BINARY_DIR}/${TARGET_NAME}.pc"
|
||||
"\n"
|
||||
"Name: ${NAME}\n"
|
||||
"Description: ${NAME} library\n"
|
||||
"Name: ${TARGET_NAME}\n"
|
||||
"Description: ${TARGET_NAME} library\n"
|
||||
"Version: ${PROJECT_VERSION}\n"
|
||||
"\n"
|
||||
"Requires:\n"
|
||||
"Cflags: -I${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n")
|
||||
|
||||
if(NOT TYPE STREQUAL "INTERFACE")
|
||||
file(APPEND "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||
"Libs: -L${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} -l${NAME}\n")
|
||||
if(NOT TARGET_TYPE STREQUAL "INTERFACE")
|
||||
file(APPEND "${PROJECT_BINARY_DIR}/${TARGET_NAME}.pc"
|
||||
"Libs: -L${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} -l${TARGET_NAME}\n")
|
||||
endif()
|
||||
|
||||
# Установка файла для pkg-config
|
||||
install(
|
||||
FILES "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||
FILES "${PROJECT_BINARY_DIR}/${TARGET_NAME}.pc"
|
||||
COMPONENT DEV
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
|
||||
if(TYPE STREQUAL "OBJECT")
|
||||
if(TARGET_TYPE STREQUAL "OBJECT")
|
||||
# Установка динамической библиотеки
|
||||
if(TARGET ${NAME}_shared)
|
||||
if(TARGET ${TARGET_NAME}_shared)
|
||||
install(
|
||||
TARGETS ${NAME}_shared
|
||||
EXPORT ${NAME}Targets
|
||||
TARGETS ${TARGET_NAME}_shared
|
||||
EXPORT ${TARGET_NAME}Targets
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT LIB
|
||||
)
|
||||
endif()
|
||||
|
||||
if(TARGET ${NAME}_static)
|
||||
if(TARGET ${TARGET_NAME}_static)
|
||||
# Установка статической библиотеки
|
||||
install(
|
||||
TARGETS ${NAME}_static
|
||||
EXPORT ${NAME}Targets
|
||||
TARGETS ${TARGET_NAME}_static
|
||||
EXPORT ${TARGET_NAME}Targets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT STATIC
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TYPE STREQUAL "INTERFACE")
|
||||
if(TARGET_TYPE STREQUAL "INTERFACE")
|
||||
# Установка библиотеки из заголовочных файлов
|
||||
target_include_directories(${NAME} SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
target_include_directories(${TARGET_NAME} SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
install(
|
||||
TARGETS ${NAME}
|
||||
EXPORT ${NAME}Targets
|
||||
TARGETS ${TARGET_NAME}
|
||||
EXPORT ${TARGET_NAME}Targets
|
||||
COMPONENT LIB
|
||||
)
|
||||
endif()
|
||||
|
@ -17,7 +17,7 @@ function(myx_create_packages NAME)
|
||||
endif()
|
||||
|
||||
if(NOT ${PROJECT_NAME}_CONTACT)
|
||||
set(CPACK_PACKAGE_CONTACT "unknown maintainer")
|
||||
set(CPACK_PACKAGE_CONTACT "unknown maintainer <nonexistent@mailbox")
|
||||
myx_message_warning("\${PROJECT_NAME}_CONTACT variable is required for packaging but unset")
|
||||
else()
|
||||
set(CPACK_PACKAGE_CONTACT ${${PROJECT_NAME}_CONTACT})
|
||||
|
@ -11,13 +11,13 @@ function(myx_uncrustify NAME)
|
||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT})
|
||||
endif()
|
||||
|
||||
myx_skip_external_target(${NAME})
|
||||
|
||||
set(options)
|
||||
set(oneValueArgs CONFIG)
|
||||
set(multiValueArgs)
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
myx_skip_external_target(${NAME})
|
||||
|
||||
if(NOT ARG_CONFIG)
|
||||
set(ARG_CONFIG "${PROJECT_SOURCE_DIR}/.uncrustify.cfg")
|
||||
if(NOT EXISTS ${ARG_CONFIG})
|
||||
|
@ -20,11 +20,11 @@ if(ENV{MYX_CMAKE_DIR})
|
||||
set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR})
|
||||
endif()
|
||||
if(MYX_CMAKE_DIR)
|
||||
find_package(MyxCMake 2.0.17 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH)
|
||||
find_package(MyxCMake 2.0.19 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH)
|
||||
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
||||
else()
|
||||
if(MYX_CMAKE_USE_SYSTEM)
|
||||
find_package(MyxCMake 2.0.17 REQUIRED)
|
||||
find_package(MyxCMake 2.0.19 REQUIRED)
|
||||
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
||||
else()
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
|
||||
|
Loading…
Reference in New Issue
Block a user