myx update
This commit is contained in:
parent
217a95c016
commit
de032eea83
@ -16,6 +16,11 @@ set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib")
|
|||||||
|
|
||||||
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
|
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
|
||||||
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.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")
|
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
|
||||||
include(${MYX_CMAKE_BACKPORTS_DIR}/FetchContent.cmake)
|
include(${MYX_CMAKE_BACKPORTS_DIR}/FetchContent.cmake)
|
||||||
else()
|
else()
|
||||||
@ -25,6 +30,7 @@ endif()
|
|||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
|
include(${MYX_CMAKE_LIB_DIR}/macro/SkipExternalTarget.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/macro/CreateSymlink.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/macro/CreateSymlink.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/macro/FindPackages.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/macro/FindPackages.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/macro/InstallRelative.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/macro/InstallRelative.cmake)
|
||||||
@ -53,6 +59,7 @@ include(${MYX_CMAKE_LIB_DIR}/doc/Doxygen.cmake)
|
|||||||
include(${MYX_CMAKE_LIB_DIR}/generators/PrivateConfigHeader.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/generators/PrivateConfigHeader.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/generators/GitInfoHeader.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/generators/GitInfoHeader.cmake)
|
||||||
|
|
||||||
|
include(${MYX_CMAKE_LIB_DIR}/CreatePackages.cmake)
|
||||||
include(${MYX_CMAKE_LIB_DIR}/Uninstall.cmake)
|
include(${MYX_CMAKE_LIB_DIR}/Uninstall.cmake)
|
||||||
|
|
||||||
unset(MYX_CMAKE_SOURCE_DIR)
|
unset(MYX_CMAKE_SOURCE_DIR)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
set(MYX_CMAKE_PACKAGE_VERSION "2.0.6")
|
set(MYX_CMAKE_PACKAGE_VERSION "2.0.17")
|
||||||
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
else()
|
else()
|
||||||
|
186
cmake/myx/backports/CheckIPOSupported.cmake
Normal file
186
cmake/myx/backports/CheckIPOSupported.cmake
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
# 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()
|
@ -0,0 +1,8 @@
|
|||||||
|
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)
|
@ -0,0 +1,8 @@
|
|||||||
|
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)
|
@ -0,0 +1,8 @@
|
|||||||
|
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)
|
4
cmake/myx/backports/CheckIPOSupported/foo.c
Normal file
4
cmake/myx/backports/CheckIPOSupported/foo.c
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
int foo()
|
||||||
|
{
|
||||||
|
return 0x42;
|
||||||
|
}
|
4
cmake/myx/backports/CheckIPOSupported/foo.cpp
Normal file
4
cmake/myx/backports/CheckIPOSupported/foo.cpp
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
int foo()
|
||||||
|
{
|
||||||
|
return 0x42;
|
||||||
|
}
|
2
cmake/myx/backports/CheckIPOSupported/foo.f
Normal file
2
cmake/myx/backports/CheckIPOSupported/foo.f
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
SUBROUTINE FOO
|
||||||
|
END
|
6
cmake/myx/backports/CheckIPOSupported/main.c
Normal file
6
cmake/myx/backports/CheckIPOSupported/main.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
int foo();
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return foo();
|
||||||
|
}
|
6
cmake/myx/backports/CheckIPOSupported/main.cpp
Normal file
6
cmake/myx/backports/CheckIPOSupported/main.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
int foo();
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return foo();
|
||||||
|
}
|
3
cmake/myx/backports/CheckIPOSupported/main.f
Normal file
3
cmake/myx/backports/CheckIPOSupported/main.f
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
PROGRAM BOO
|
||||||
|
CALL FOO()
|
||||||
|
END
|
@ -199,6 +199,8 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
SUBBUILD_DIR
|
SUBBUILD_DIR
|
||||||
SOURCE_DIR
|
SOURCE_DIR
|
||||||
BINARY_DIR
|
BINARY_DIR
|
||||||
|
# We need special processing if DOWNLOAD_NO_EXTRACT is true
|
||||||
|
DOWNLOAD_NO_EXTRACT
|
||||||
# Prevent the following from being passed through
|
# Prevent the following from being passed through
|
||||||
CONFIGURE_COMMAND
|
CONFIGURE_COMMAND
|
||||||
BUILD_COMMAND
|
BUILD_COMMAND
|
||||||
@ -249,6 +251,26 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
set(ARG_EXTRA "${ARG_EXTRA} \"${arg}\"")
|
set(ARG_EXTRA "${ARG_EXTRA} \"${arg}\"")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
if(ARG_DOWNLOAD_NO_EXTRACT)
|
||||||
|
set(ARG_EXTRA "${ARG_EXTRA} DOWNLOAD_NO_EXTRACT YES")
|
||||||
|
set(__FETCHCONTENT_COPY_FILE
|
||||||
|
"
|
||||||
|
ExternalProject_Get_Property(${contentName}-populate DOWNLOADED_FILE)
|
||||||
|
get_filename_component(dlFileName \"\${DOWNLOADED_FILE}\" NAME)
|
||||||
|
|
||||||
|
ExternalProject_Add_Step(${contentName}-populate copyfile
|
||||||
|
COMMAND \"${CMAKE_COMMAND}\" -E copy_if_different
|
||||||
|
\"<DOWNLOADED_FILE>\" \"${ARG_SOURCE_DIR}\"
|
||||||
|
DEPENDEES patch
|
||||||
|
DEPENDERS configure
|
||||||
|
BYPRODUCTS \"${ARG_SOURCE_DIR}/\${dlFileName}\"
|
||||||
|
COMMENT \"Copying file to SOURCE_DIR\"
|
||||||
|
)
|
||||||
|
")
|
||||||
|
else()
|
||||||
|
unset(__FETCHCONTENT_COPY_FILE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Hide output if requested, but save it to a variable in case there's an
|
# Hide output if requested, but save it to a variable in case there's an
|
||||||
# error so we can show the output upon failure. When not quiet, don't
|
# error so we can show the output upon failure. When not quiet, don't
|
||||||
# capture the output to a variable because the user may want to see the
|
# capture the output to a variable because the user may want to see the
|
||||||
@ -266,16 +288,16 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_GENERATOR)
|
if(CMAKE_GENERATOR)
|
||||||
set(generatorOpts "-G${CMAKE_GENERATOR}")
|
set(subCMakeOpts "-G${CMAKE_GENERATOR}")
|
||||||
if(CMAKE_GENERATOR_PLATFORM)
|
if(CMAKE_GENERATOR_PLATFORM)
|
||||||
list(APPEND generatorOpts "-A${CMAKE_GENERATOR_PLATFORM}")
|
list(APPEND subCMakeOpts "-A${CMAKE_GENERATOR_PLATFORM}")
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_GENERATOR_TOOLSET)
|
if(CMAKE_GENERATOR_TOOLSET)
|
||||||
list(APPEND generatorOpts "-T${CMAKE_GENERATOR_TOOLSET}")
|
list(APPEND subCMakeOpts "-T${CMAKE_GENERATOR_TOOLSET}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_MAKE_PROGRAM)
|
if(CMAKE_MAKE_PROGRAM)
|
||||||
list(APPEND generatorOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
|
list(APPEND subCMakeOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
@ -283,7 +305,7 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
# generator is set (and hence CMAKE_MAKE_PROGRAM could not be
|
# generator is set (and hence CMAKE_MAKE_PROGRAM could not be
|
||||||
# trusted even if provided). We will have to rely on being
|
# trusted even if provided). We will have to rely on being
|
||||||
# able to find the default generator and build tool.
|
# able to find the default generator and build tool.
|
||||||
unset(generatorOpts)
|
unset(subCMakeOpts)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create and build a separate CMake project to carry out the population.
|
# Create and build a separate CMake project to carry out the population.
|
||||||
@ -294,7 +316,7 @@ function(__FetchContent_directPopulate contentName)
|
|||||||
configure_file("${__FetchContent_privateDir}/CMakeLists.cmake.in"
|
configure_file("${__FetchContent_privateDir}/CMakeLists.cmake.in"
|
||||||
"${ARG_SUBBUILD_DIR}/CMakeLists.txt")
|
"${ARG_SUBBUILD_DIR}/CMakeLists.txt")
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND} ${generatorOpts} .
|
COMMAND ${CMAKE_COMMAND} ${subCMakeOpts} .
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
${outputOptions}
|
${outputOptions}
|
||||||
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
|
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
|
||||||
|
@ -46,11 +46,7 @@ function(myx_add_library NAME TYPE)
|
|||||||
if(TYPE STREQUAL "INTERFACE")
|
if(TYPE STREQUAL "INTERFACE")
|
||||||
# Библиотека, состоящая только из заголовочных файлов не требует сборки.
|
# Библиотека, состоящая только из заголовочных файлов не требует сборки.
|
||||||
# Стандартные пути к заголовочным файлам
|
# Стандартные пути к заголовочным файлам
|
||||||
target_include_directories(${NAME}
|
target_include_directories(${NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
||||||
INTERFACE
|
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
||||||
)
|
|
||||||
else()
|
else()
|
||||||
string(TOUPPER ${NAME} PROJECT_NAME_UPPER)
|
string(TOUPPER ${NAME} PROJECT_NAME_UPPER)
|
||||||
# Опция для разрешения сборки динамической библиотеки
|
# Опция для разрешения сборки динамической библиотеки
|
||||||
@ -152,7 +148,7 @@ function(myx_add_library NAME TYPE)
|
|||||||
|
|
||||||
install(EXPORT ${NAME}Targets
|
install(EXPORT ${NAME}Targets
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||||
COMPONENT dev
|
COMPONENT DEV
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
@ -160,7 +156,7 @@ function(myx_add_library NAME TYPE)
|
|||||||
${PROJECT_BINARY_DIR}/${NAME}ConfigVersion.cmake
|
${PROJECT_BINARY_DIR}/${NAME}ConfigVersion.cmake
|
||||||
${PROJECT_BINARY_DIR}/${NAME}Config.cmake
|
${PROJECT_BINARY_DIR}/${NAME}Config.cmake
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||||
COMPONENT dev
|
COMPONENT DEV
|
||||||
)
|
)
|
||||||
|
|
||||||
# Формирование файла для pkg-config
|
# Формирование файла для pkg-config
|
||||||
@ -191,7 +187,7 @@ function(myx_add_library NAME TYPE)
|
|||||||
# Установка файла для pkg-config
|
# Установка файла для pkg-config
|
||||||
install(
|
install(
|
||||||
FILES "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
FILES "${PROJECT_BINARY_DIR}/${NAME}.pc"
|
||||||
COMPONENT dev
|
COMPONENT DEV
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||||
|
|
||||||
if(TYPE STREQUAL "OBJECT")
|
if(TYPE STREQUAL "OBJECT")
|
||||||
@ -201,7 +197,7 @@ function(myx_add_library NAME TYPE)
|
|||||||
TARGETS ${NAME}_shared
|
TARGETS ${NAME}_shared
|
||||||
EXPORT ${NAME}Targets
|
EXPORT ${NAME}Targets
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
COMPONENT lib
|
COMPONENT LIB
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -211,17 +207,18 @@ function(myx_add_library NAME TYPE)
|
|||||||
TARGETS ${NAME}_static
|
TARGETS ${NAME}_static
|
||||||
EXPORT ${NAME}Targets
|
EXPORT ${NAME}Targets
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
COMPONENT static
|
COMPONENT STATIC
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TYPE STREQUAL "INTERFACE")
|
if(TYPE STREQUAL "INTERFACE")
|
||||||
# Установка библиотеки из заголовочных файлов
|
# Установка библиотеки из заголовочных файлов
|
||||||
|
target_include_directories(${NAME} SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||||
install(
|
install(
|
||||||
TARGETS ${NAME}
|
TARGETS ${NAME}
|
||||||
EXPORT ${NAME}Targets
|
EXPORT ${NAME}Targets
|
||||||
COMPONENT lib
|
COMPONENT LIB
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
180
cmake/myx/lib/CreatePackages.cmake
Normal file
180
cmake/myx/lib/CreatePackages.cmake
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
|
function(myx_create_packages NAME)
|
||||||
|
set(options)
|
||||||
|
set(oneValueArgs DEBIAN_PACKAGE_TYPE CPACK_DEBIAN_PACKAGE_SECTION CPACK_DEBIAN_PACKAGE_PRIORITY
|
||||||
|
CMAKE_INSTALL_DEFAULT_COMPONENT_NAME CPACK_PACKAGE_CONTACT)
|
||||||
|
set(multiValueArgs CPACK_SOURCE_GENERATOR CPACK_GENERATOR CPACK_SOURCE_IGNORE_FILES
|
||||||
|
CPACK_PACKAGING_INSTALL_PREFIX)
|
||||||
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
# Общие настройки для пакета: организация, автор, версия
|
||||||
|
if(NOT ${PROJECT_NAME}_VENDOR)
|
||||||
|
set(CPACK_PACKAGE_VENDOR "unknown vendor")
|
||||||
|
myx_message_warning("\${PROJECT_NAME}_VENDOR variable is required for packaging but unset")
|
||||||
|
else()
|
||||||
|
set(CPACK_PACKAGE_VENDOR ${${PROJECT_NAME}_VENDOR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ${PROJECT_NAME}_CONTACT)
|
||||||
|
set(CPACK_PACKAGE_CONTACT "unknown maintainer")
|
||||||
|
myx_message_warning("\${PROJECT_NAME}_CONTACT variable is required for packaging but unset")
|
||||||
|
else()
|
||||||
|
set(CPACK_PACKAGE_CONTACT ${${PROJECT_NAME}_CONTACT})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(TOLOWER ${PROJECT_NAME} PN)
|
||||||
|
set(CPACK_PACKAGE_NAME ${PN})
|
||||||
|
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||||
|
|
||||||
|
# Параметры для архива исходных текстов
|
||||||
|
if(NOT ARG_CPACK_SOURCE_GENERATOR)
|
||||||
|
set(CPACK_SOURCE_GENERATOR "TXZ")
|
||||||
|
else()
|
||||||
|
set(ARG_CPACK_SOURCE_GENERATOR ${CPACK_SOURCE_GENERATOR})
|
||||||
|
endif()
|
||||||
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PN}-${CPACK_PACKAGE_VERSION}")
|
||||||
|
|
||||||
|
# Типы генераторов для бинарных архивов
|
||||||
|
if(NOT ARG_CPACK_GENERATOR)
|
||||||
|
set(CPACK_GENERATOR "TXZ" "DEB")
|
||||||
|
else()
|
||||||
|
set(CPACK_GENERATOR ${ARG_CPACK_GENERATOR})
|
||||||
|
endif()
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||||
|
list(REMOVE_ITEM CPACK_GENERATOR "DEB")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Параметры для архива собранного проекта
|
||||||
|
set(CPACK_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
|
||||||
|
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||||
|
set(CPACK_TARGET_ARCH "amd64")
|
||||||
|
endif()
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME "${PN}_${CPACK_PACKAGE_VERSION}")
|
||||||
|
|
||||||
|
# Список масок для исключения из архива исходных текстов
|
||||||
|
set(CPACK_SOURCE_IGNORE_FILES
|
||||||
|
${ARG_CPACK_SOURCE_IGNORE_FILES}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
"^${CMAKE_SOURCE_DIR}/.?build.?/"
|
||||||
|
"^${CMAKE_SOURCE_DIR}/.?output.?/"
|
||||||
|
"^${CMAKE_SOURCE_DIR}/files/var"
|
||||||
|
"^${CMAKE_SOURCE_DIR}/files/log"
|
||||||
|
"CMakeLists.txt.user.*"
|
||||||
|
".*.autosave"
|
||||||
|
".*.status"
|
||||||
|
"~$"
|
||||||
|
"\\\\.swp$")
|
||||||
|
|
||||||
|
option(MYX_COMPACT_SOURCE_PACKAGE "Make compact source package" ON)
|
||||||
|
if(MYX_COMPACT_SOURCE_PACKAGE)
|
||||||
|
# Список масок для исключения из архива исходных текстов для более компактного архива
|
||||||
|
set(CPACK_SOURCE_IGNORE_FILES
|
||||||
|
${CPACK_SOURCE_IGNORE_FILES}
|
||||||
|
"\\\\.git"
|
||||||
|
"/\\\\.git/"
|
||||||
|
"/\\\\.gitlab-ci/"
|
||||||
|
"\\\\.clang-tidy$"
|
||||||
|
"\\\\.cmake-format$"
|
||||||
|
"\\\\.gitignore$"
|
||||||
|
"\\\\.gitattributes$"
|
||||||
|
"\\\\.gitmodules$"
|
||||||
|
"\\\\.gitlab-ci.yml$")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("TXZ" IN_LIST CPACK_GENERATOR)
|
||||||
|
set(CPACK_ARCHIVE_COMPONENT_INSTALL OFF)
|
||||||
|
set(CPACK_ARCHIVE_FILE_NAME "${PN}_${CPACK_TARGET_ARCH}_${CPACK_PACKAGE_VERSION}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("DEB" IN_LIST CPACK_GENERATOR)
|
||||||
|
set(CPACK_DEB_MONOLITHIC_INSTALL OFF)
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||||
|
|
||||||
|
# По умолчанию пакет собирается для дистрибутива unstable
|
||||||
|
if(NOT ARG_DEBIAN_PACKAGE_TYPE)
|
||||||
|
set(DEBIAN_PACKAGE_TYPE "unstable")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ARG_CPACK_DEBIAN_PACKAGE_SECTION)
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ARG_CPACK_DEBIAN_PACKAGE_PRIORITY)
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# По умолчанию пакет для Debian делится на компоненты
|
||||||
|
if(NOT ARG_CPACK_DEB_COMPONENT_INSTALL)
|
||||||
|
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Если имя компонента по умолчанию не определено, то устанавливается main
|
||||||
|
if(NOT CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
|
||||||
|
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME MAIN)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# В списке компонентов обязательно должны быть main, lib, dev, static и doc
|
||||||
|
#list(APPEND CPACK_COMPONENTS_ALL main lib dev static doc)
|
||||||
|
list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL)
|
||||||
|
|
||||||
|
set(deb_arch_suffix "${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb")
|
||||||
|
# Правило формирования имени пакета и файла для компонента main
|
||||||
|
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "${PN}")
|
||||||
|
set(CPACK_DEBIAN_MAIN_FILE_NAME ${CPACK_DEBIAN_MAIN_PACKAGE_NAME}_${deb_arch_suffix})
|
||||||
|
|
||||||
|
# Правило формирования имени пакета и файла для компонента lib
|
||||||
|
set(CPACK_DEBIAN_LIB_PACKAGE_NAME "lib${PN}${PROJECT_VERSION_MAJOR}")
|
||||||
|
set(CPACK_DEBIAN_LIB_FILE_NAME ${CPACK_DEBIAN_LIB_PACKAGE_NAME}_${deb_arch_suffix})
|
||||||
|
|
||||||
|
# Правило формирования имени пакета и файла для компонента dev
|
||||||
|
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "lib${PN}-dev")
|
||||||
|
set(CPACK_DEBIAN_DEV_FILE_NAME ${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${deb_arch_suffix})
|
||||||
|
|
||||||
|
# Правило формирования имени пакета и файла для компонента static
|
||||||
|
set(CPACK_DEBIAN_STATIC_PACKAGE_NAME "lib${PN}${PROJECT_VERSION_MAJOR}-static-dev")
|
||||||
|
set(CPACK_DEBIAN_STATIC_FILE_NAME ${CPACK_DEBIAN_STATIC_PACKAGE_NAME}_${deb_arch_suffix})
|
||||||
|
set(CPACK_DEBIAN_STATIC_PACKAGE_DEPENDS "lib${PN}-dev")
|
||||||
|
|
||||||
|
# Правило формирования имени пакета и файла для компонента doc
|
||||||
|
set(CPACK_DEBIAN_DOC_PACKAGE_NAME "${PN}-doc")
|
||||||
|
set(CPACK_DEBIAN_DOC_FILE_NAME ${PN}-doc_${CPACK_PACKAGE_VERSION}_all.deb)
|
||||||
|
|
||||||
|
foreach(iter ${CPACK_COMPONENTS_ALL})
|
||||||
|
string(TOLOWER ${iter} _cl)
|
||||||
|
string(TOUPPER ${iter} _cu)
|
||||||
|
# Правила формирования имени пакета и файла для остальных компонентов
|
||||||
|
if((NOT ${_cu} STREQUAL MAIN) AND
|
||||||
|
(NOT ${_cu} STREQUAL LIB) AND
|
||||||
|
(NOT ${_cu} STREQUAL DEV) AND
|
||||||
|
(NOT ${_cu} STREQUAL STATIC) AND
|
||||||
|
(NOT ${_cu} STREQUAL DOC))
|
||||||
|
set(CPACK_DEBIAN_${_cu}_PACKAGE_NAME "${PN}-${_cl}")
|
||||||
|
set(CPACK_DEBIAN_${_cu}_FILE_NAME "${CPACK_DEBIAN_${_cu}_PACKAGE_NAME}_${deb_arch_suffix}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Если в каталоге ${CMAKE_SOURCE_DIR}/cmake/deb/${_cl} находятся сценарии сопровождающего
|
||||||
|
# postinst, preinst, postrm и prerm, то они будут добавлены к пакету.
|
||||||
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/preinst")
|
||||||
|
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/preinst")
|
||||||
|
endif()
|
||||||
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postinst")
|
||||||
|
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postinst")
|
||||||
|
endif()
|
||||||
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/prerm")
|
||||||
|
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/prerm")
|
||||||
|
endif()
|
||||||
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postrm")
|
||||||
|
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postrm")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(UNIX AND NOT TARGET deb)
|
||||||
|
add_custom_target(deb WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND cpack -G DEB)
|
||||||
|
add_dependencies(deb ${NAME})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Подключение модуля, выполняющего сборку архивов и пакетов
|
||||||
|
include(CPack)
|
||||||
|
endfunction(myx_create_packages NAME)
|
@ -1,7 +1,7 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
if(NOT MYX_TODAY)
|
if(NOT MYX_TODAY)
|
||||||
if(WIN32)
|
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
|
||||||
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_TODAY)
|
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_TODAY)
|
||||||
else()
|
else()
|
||||||
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_TODAY)
|
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_TODAY)
|
||||||
@ -10,7 +10,7 @@ if(NOT MYX_TODAY)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT MYX_YEAR)
|
if(NOT MYX_YEAR)
|
||||||
if(WIN32)
|
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
|
||||||
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_YEAR)
|
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_YEAR)
|
||||||
else()
|
else()
|
||||||
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_YEAR)
|
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_YEAR)
|
||||||
|
@ -51,11 +51,6 @@ function(FetchContent_Add NAME)
|
|||||||
GIT_SHALLOW 1
|
GIT_SHALLOW 1
|
||||||
)
|
)
|
||||||
|
|
||||||
string(TOLOWER ${NAME} lower_name)
|
set(FETCHCONTENT_QUIET off)
|
||||||
FetchContent_GetProperties(${NAME})
|
FetchContent_MakeAvailable(${NAME})
|
||||||
if(NOT ${lower_name}_POPULATED)
|
|
||||||
FetchContent_Populate(${NAME})
|
|
||||||
add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -9,7 +9,7 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
|||||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include)
|
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include)
|
||||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
|
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
|
||||||
|
|
||||||
create_symlink("${CMAKE_SOURCE_DIR}/files/etc" "${CMAKE_BINARY_DIR}/etc")
|
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/etc" "${CMAKE_BINARY_DIR}/etc")
|
||||||
create_symlink("${CMAKE_SOURCE_DIR}/files/log" "${CMAKE_BINARY_DIR}/log")
|
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/log" "${CMAKE_BINARY_DIR}/log")
|
||||||
create_symlink("${CMAKE_SOURCE_DIR}/files/share" "${CMAKE_BINARY_DIR}/share")
|
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/share" "${CMAKE_BINARY_DIR}/share")
|
||||||
create_symlink("${CMAKE_SOURCE_DIR}/files/var" "${CMAKE_BINARY_DIR}/var")
|
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/var" "${CMAKE_BINARY_DIR}/var")
|
||||||
|
@ -58,7 +58,11 @@ function(myx_qt5_target_setup NAME)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Перечень файлов, подлежащих переводу
|
# Перечень файлов, подлежащих переводу
|
||||||
|
if(target_type STREQUAL "INTERFACE_LIBRARY")
|
||||||
|
get_target_property(tr ${NAME} INTERFACE_TR_FILES)
|
||||||
|
else()
|
||||||
get_target_property(tr ${NAME} TR_FILES)
|
get_target_property(tr ${NAME} TR_FILES)
|
||||||
|
endif()
|
||||||
# Формирование файла ресурсов с переводами
|
# Формирование файла ресурсов с переводами
|
||||||
if("LinguistTools" IN_LIST ARG_COMPONENTS AND tr)
|
if("LinguistTools" IN_LIST ARG_COMPONENTS AND tr)
|
||||||
# Заглавие файла ресурсов
|
# Заглавие файла ресурсов
|
||||||
@ -67,7 +71,9 @@ function(myx_qt5_target_setup NAME)
|
|||||||
foreach(iter ${ARG_LANGS})
|
foreach(iter ${ARG_LANGS})
|
||||||
# Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n
|
# Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n
|
||||||
# и его компиляция в каталог ${PROJECT_BINARY_DIR}
|
# и его компиляция в каталог ${PROJECT_BINARY_DIR}
|
||||||
qt5_create_translation(qm ${tr} "${PROJECT_SOURCE_DIR}/l10n/${NAME}_${iter}.ts")
|
qt5_create_translation(qm ${tr}
|
||||||
|
"${PROJECT_SOURCE_DIR}/l10n/${NAME}_${iter}.ts"
|
||||||
|
OPTIONS -I ${PROJECT_SOURCE_DIR}/include -I ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME})
|
||||||
# Добавление записи для скомпилированного файла переводов в ресурсный файл
|
# Добавление записи для скомпилированного файла переводов в ресурсный файл
|
||||||
file(APPEND ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc
|
file(APPEND ${PROJECT_BINARY_DIR}/${NAME}_l10n.qrc
|
||||||
"<file alias=\"${NAME}_${iter}\">${NAME}_${iter}.qm</file>\n")
|
"<file alias=\"${NAME}_${iter}\">${NAME}_${iter}.qm</file>\n")
|
||||||
@ -85,10 +91,10 @@ function(myx_qt5_target_setup NAME)
|
|||||||
|
|
||||||
# Установка публичных заголовочных файлов
|
# Установка публичных заголовочных файлов
|
||||||
if(PROJECT_IS_TOP_LEVEL)
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
install_relative(${PROJECT_SOURCE_DIR}
|
myx_install_relative(${PROJECT_SOURCE_DIR}
|
||||||
FILES ${ARG_PUBLIC_MOC}
|
FILES ${ARG_PUBLIC_MOC}
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
COMPONENT dev
|
COMPONENT DEV
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -5,7 +5,6 @@ function(myx_target_setup NAME)
|
|||||||
set(oneValueArgs PCH)
|
set(oneValueArgs PCH)
|
||||||
set(multiValueArgs COMPILE_DEFINITIONS PACKAGES LINK_LIBRARIES
|
set(multiValueArgs COMPILE_DEFINITIONS PACKAGES LINK_LIBRARIES
|
||||||
CPP INTERFACE_HEADERS PUBLIC_HEADERS PRIVATE_HEADERS)
|
CPP INTERFACE_HEADERS PUBLIC_HEADERS PRIVATE_HEADERS)
|
||||||
|
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
if(NOT TARGET ${NAME})
|
if(NOT TARGET ${NAME})
|
||||||
@ -59,6 +58,10 @@ function(myx_target_setup NAME)
|
|||||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
||||||
endif()
|
endif()
|
||||||
|
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}")
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}>)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_target_properties(${NAME} PROPERTIES
|
set_target_properties(${NAME} PROPERTIES
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
@ -67,13 +70,17 @@ function(myx_target_setup NAME)
|
|||||||
if(CMAKE_CXX_COMPILE_OPTIONS_PIE)
|
if(CMAKE_CXX_COMPILE_OPTIONS_PIE)
|
||||||
target_compile_options(${NAME} PUBLIC ${CMAKE_CXX_COMPILE_OPTIONS_PIE})
|
target_compile_options(${NAME} PUBLIC ${CMAKE_CXX_COMPILE_OPTIONS_PIE})
|
||||||
endif()
|
endif()
|
||||||
install(TARGETS ${NAME} COMPONENT main RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(TARGETS ${NAME} COMPONENT MAIN RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
|
||||||
|
target_sources(${NAME} INTERFACE $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
|
||||||
|
else()
|
||||||
target_sources(${NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
|
target_sources(${NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
|
||||||
target_sources(${NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
|
target_sources(${NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
|
||||||
target_sources(${NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
|
target_sources(${NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
|
||||||
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
|
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
|
||||||
|
endif()
|
||||||
|
|
||||||
# CMake до версии 3.12 не умеет извлекать из целей типа `OBJECT_LIBRARY`
|
# CMake до версии 3.12 не умеет извлекать из целей типа `OBJECT_LIBRARY`
|
||||||
# информацию о заголовочных файлах. Это обход.
|
# информацию о заголовочных файлах. Это обход.
|
||||||
@ -83,6 +90,8 @@ function(myx_target_setup NAME)
|
|||||||
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(${NAME} PRIVATE ${ARG_LINK_LIBRARIES})
|
target_link_libraries(${NAME} PRIVATE ${ARG_LINK_LIBRARIES})
|
||||||
|
elseif(${target_type} STREQUAL "INTERFACE")
|
||||||
|
target_link_libraries(${NAME} INTERFACE ${ARG_LINK_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
foreach(link_library ${ARG_LINK_LIBRARIES})
|
foreach(link_library ${ARG_LINK_LIBRARIES})
|
||||||
if(TARGET ${link_library})
|
if(TARGET ${link_library})
|
||||||
@ -111,10 +120,10 @@ function(myx_target_setup NAME)
|
|||||||
|
|
||||||
# Установка публичных заголовочных файлов
|
# Установка публичных заголовочных файлов
|
||||||
if(PROJECT_IS_TOP_LEVEL)
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
install_relative(${PROJECT_SOURCE_DIR}
|
myx_install_relative(${PROJECT_SOURCE_DIR}
|
||||||
FILES ${ARG_PUBLIC_HEADERS} ${ARG_INTERFACE_HEADERS}
|
FILES ${ARG_PUBLIC_HEADERS} ${ARG_INTERFACE_HEADERS}
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||||
COMPONENT dev
|
COMPONENT DEV
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -63,7 +63,7 @@ function(myx_doc_doxygen NAME)
|
|||||||
COMMENT "Generating API documentation with Doxygen")
|
COMMENT "Generating API documentation with Doxygen")
|
||||||
if(ARG_HTML)
|
if(ARG_HTML)
|
||||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/doxygen/html/
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/doxygen/html/
|
||||||
COMPONENT doc OPTIONAL
|
COMPONENT DOC OPTIONAL
|
||||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/doxygen)
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/doxygen)
|
||||||
endif()
|
endif()
|
||||||
if(NOT TARGET myx-doc-doxygen)
|
if(NOT TARGET myx-doc-doxygen)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
macro(create_symlink original linkname)
|
macro(myx_create_symlink original linkname)
|
||||||
if(NOT EXISTS ${linkname})
|
if(NOT EXISTS ${linkname})
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
|
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${original} ${linkname})
|
execute_process(COMMAND ${CMAKE_COMMAND} -E myx_create_symlink ${original} ${linkname})
|
||||||
else()
|
else()
|
||||||
file(CREATE_LINK ${original} ${linkname} SYMBOLIC)
|
file(CREATE_LINK ${original} ${linkname} SYMBOLIC)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endmacro(create_symlink original linkname)
|
endmacro(myx_create_symlink original linkname)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
include_guard(GLOBAL)
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
macro(myx_find_packages)
|
macro(myx_find_required_packages)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs)
|
set(oneValueArgs)
|
||||||
set(multiValueArgs PACKAGES Boost Qt5 Qt5Private)
|
set(multiValueArgs PACKAGES Boost Qt5 Qt5Private)
|
||||||
@ -31,4 +31,4 @@ macro(myx_find_packages)
|
|||||||
unset(multiValueArgs)
|
unset(multiValueArgs)
|
||||||
unset(oneValueArgs)
|
unset(oneValueArgs)
|
||||||
unset(options)
|
unset(options)
|
||||||
endmacro(myx_find_packages)
|
endmacro(myx_find_required_packages)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#[=======================================================================[.rst:
|
#[=======================================================================[.rst:
|
||||||
install_relative
|
myx_install_relative
|
||||||
----------------
|
--------------------
|
||||||
|
|
||||||
#]=======================================================================]
|
#]=======================================================================]
|
||||||
|
|
||||||
macro(install_relative STRIP_DIRECTORY)
|
macro(myx_install_relative STRIP_DIRECTORY)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs DESTINATION)
|
set(oneValueArgs DESTINATION)
|
||||||
set(multiValueArgs FILES)
|
set(multiValueArgs FILES)
|
||||||
@ -16,4 +16,4 @@ macro(install_relative STRIP_DIRECTORY)
|
|||||||
string(REPLACE ${STRIP_DIRECTORY} "" RELATIVE_DIR ${DIR})
|
string(REPLACE ${STRIP_DIRECTORY} "" RELATIVE_DIR ${DIR})
|
||||||
INSTALL(FILES ${FILE} DESTINATION ${ARG_DESTINATION}/${RELATIVE_DIR} ${ARG_UNPARSED_ARGUMENTS})
|
INSTALL(FILES ${FILE} DESTINATION ${ARG_DESTINATION}/${RELATIVE_DIR} ${ARG_UNPARSED_ARGUMENTS})
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro(install_relative STRIP_DIRECTORY)
|
endmacro(myx_install_relative STRIP_DIRECTORY)
|
||||||
|
33
cmake/myx/lib/macro/SkipExternalTarget.cmake
Normal file
33
cmake/myx/lib/macro/SkipExternalTarget.cmake
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
|
# Пропуск целей, которые создаются автоматически в `CMAKE_BINARY_DIR`
|
||||||
|
macro(myx_skip_external_target NAME)
|
||||||
|
get_target_property(__type ${NAME} TYPE)
|
||||||
|
if(__type STREQUAL "INTERFACE_LIBRARY")
|
||||||
|
get_target_property(__sources ${NAME} INTERFACE_SOURCES)
|
||||||
|
foreach(iter ${__sources})
|
||||||
|
string(FIND ${iter} ${CMAKE_BINARY_DIR} __pos)
|
||||||
|
if(__pos GREATER -1)
|
||||||
|
unset(__type)
|
||||||
|
unset(__pos)
|
||||||
|
unset(__sources)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
unset(__type)
|
||||||
|
unset(__pos)
|
||||||
|
unset(__sources)
|
||||||
|
else()
|
||||||
|
get_target_property(__source_dir ${NAME} SOURCE_DIR)
|
||||||
|
string(FIND ${__source_dir} ${CMAKE_BINARY_DIR} __pos)
|
||||||
|
if(__pos EQUAL 0)
|
||||||
|
unset(__type)
|
||||||
|
unset(__pos)
|
||||||
|
unset(__source_dir)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
unset(__pos)
|
||||||
|
unset(__source_dir)
|
||||||
|
endif()
|
||||||
|
unset(__type)
|
||||||
|
endmacro(myx_skip_external_target NAME)
|
@ -6,7 +6,7 @@ endif()
|
|||||||
|
|
||||||
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
|
||||||
|
|
||||||
function(myx_uncrustify target)
|
function(myx_uncrustify NAME)
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||||||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT})
|
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT})
|
||||||
endif()
|
endif()
|
||||||
@ -16,6 +16,8 @@ function(myx_uncrustify target)
|
|||||||
set(multiValueArgs)
|
set(multiValueArgs)
|
||||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
myx_skip_external_target(${NAME})
|
||||||
|
|
||||||
if(NOT ARG_CONFIG)
|
if(NOT ARG_CONFIG)
|
||||||
set(ARG_CONFIG "${PROJECT_SOURCE_DIR}/.uncrustify.cfg")
|
set(ARG_CONFIG "${PROJECT_SOURCE_DIR}/.uncrustify.cfg")
|
||||||
if(NOT EXISTS ${ARG_CONFIG})
|
if(NOT EXISTS ${ARG_CONFIG})
|
||||||
@ -33,8 +35,6 @@ function(myx_uncrustify target)
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(NOT TARGET myx-uncrustify)
|
if(NOT TARGET myx-uncrustify)
|
||||||
add_custom_target(myx-uncrustify)
|
add_custom_target(myx-uncrustify)
|
||||||
endif()
|
endif()
|
||||||
@ -46,30 +46,35 @@ function(myx_uncrustify target)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Динамически сгенерированные файлы исключаются
|
# Динамически сгенерированные файлы исключаются
|
||||||
get_target_property(s ${target} SOURCES)
|
get_target_property(target_type ${NAME} TYPE)
|
||||||
|
if(${target_type} STREQUAL "INTERFACE_LIBRARY")
|
||||||
|
get_target_property(s ${NAME} INTERFACE_SOURCES)
|
||||||
|
else()
|
||||||
|
get_target_property(s ${NAME} SOURCES)
|
||||||
|
endif()
|
||||||
foreach(iter ${s})
|
foreach(iter ${s})
|
||||||
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
|
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
|
||||||
if(pos EQUAL -1)
|
if(pos EQUAL -1)
|
||||||
list(APPEND src ${iter})
|
list(APPEND src ${iter})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||||
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
|
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
|
||||||
-c ${ARG_CONFIG}
|
-c ${ARG_CONFIG}
|
||||||
-o ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg)
|
-o ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg)
|
||||||
list(APPEND UNCRUSTIFY_OPTS -c ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg)
|
list(APPEND UNCRUSTIFY_OPTS -c ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg)
|
||||||
# cmake-format: off
|
# cmake-format: off
|
||||||
add_custom_target(${target}-uncrustify-check
|
add_custom_target(${NAME}-uncrustify-check
|
||||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${src})
|
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${src})
|
||||||
|
|
||||||
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup)
|
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup)
|
||||||
add_custom_target(${target}-uncrustify
|
add_custom_target(${NAME}-uncrustify
|
||||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${src})
|
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${src})
|
||||||
|
|
||||||
add_custom_target(${target}-uncrustify-append-comments
|
add_custom_target(${NAME}-uncrustify-append-comments
|
||||||
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${target}.cfg
|
DEPENDS ${PROJECT_BINARY_DIR}/uncrustify-${NAME}.cfg
|
||||||
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
|
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
|
||||||
--set cmt_insert_class_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/classheader.txt
|
--set cmt_insert_class_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/classheader.txt
|
||||||
--set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt
|
--set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt
|
||||||
@ -78,7 +83,7 @@ function(myx_uncrustify target)
|
|||||||
--set cmt_insert_before_ctor_dtor=true --mtime ${src})
|
--set cmt_insert_before_ctor_dtor=true --mtime ${src})
|
||||||
# cmake-format: on
|
# cmake-format: on
|
||||||
|
|
||||||
add_dependencies(myx-uncrustify ${target}-uncrustify)
|
add_dependencies(myx-uncrustify ${NAME}-uncrustify)
|
||||||
add_dependencies(myx-uncrustify-check ${target}-uncrustify-check)
|
add_dependencies(myx-uncrustify-check ${NAME}-uncrustify-check)
|
||||||
add_dependencies(myx-uncrustify-append-comments ${target}-uncrustify-append-comments)
|
add_dependencies(myx-uncrustify-append-comments ${NAME}-uncrustify-append-comments)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -20,11 +20,11 @@ if(ENV{MYX_CMAKE_DIR})
|
|||||||
set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR})
|
set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR})
|
||||||
endif()
|
endif()
|
||||||
if(MYX_CMAKE_DIR)
|
if(MYX_CMAKE_DIR)
|
||||||
find_package(MyxCMake 2.0.6 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH)
|
find_package(MyxCMake 2.0.17 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH)
|
||||||
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
||||||
else()
|
else()
|
||||||
if(MYX_CMAKE_USE_SYSTEM)
|
if(MYX_CMAKE_USE_SYSTEM)
|
||||||
find_package(MyxCMake 2.0.6 REQUIRED)
|
find_package(MyxCMake 2.0.17 REQUIRED)
|
||||||
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
myx_message_notice("=== MyxCMake directory: ${MyxCMake_CONFIG} ===")
|
||||||
else()
|
else()
|
||||||
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
|
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
|
||||||
|
Loading…
Reference in New Issue
Block a user