Чистка кода

This commit is contained in:
Andrei Astafev 2021-12-09 14:41:26 +03:00
parent 17daab8623
commit 02b4763525
12 changed files with 92 additions and 69 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.deb
MyxCMake/MyxCMakeConfigVersion.cmake

View File

@ -1,6 +1,18 @@
cmake_minimum_required(VERSION 3.0)
project(myx-cmake VERSION 0.1.2)
project(myx-cmake VERSION 0.2.0 LANGUAGES)
include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake
"set(MYX_CMAKE_PACKAGE_VERSION \"${PROJECT_VERSION}\")\n"
"if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)\n"
" set(PACKAGE_VERSION_COMPATIBLE FALSE)\n"
"else()\n"
" set(PACKAGE_VERSION_COMPATIBLE TRUE)\n"
" if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)\n"
" set(PACKAGE_VERSION_EXACT TRUE)\n"
" endif()\n"
"endif()\n"
)
install(DIRECTORY MyxCMake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake")

View File

@ -10,8 +10,8 @@ function(myx_cmake_generate_git_info_header)
if(NOT TARGET myx-cmake-git-info-header)
add_custom_target(myx-cmake-git-info-header ALL
${CMAKE_COMMAND} -DMYX_CMAKE_PROJECT_NAME_UPPER=${MYX_CMAKE_PROJECT_NAME_UPPER}
-DMYX_CMAKE_MODULE_DIR=${MYX_CMAKE_MODULE_DIR}
-DMYX_CMAKE_GIT_INFO_FILE=${output_file} -P ${CMAKE_CURRENT_LIST_DIR}/MyxCMakeGitInfo.cmake
-DMYX_CMAKE_FUNCTIONS_DIR=${MYX_CMAKE_FUNCTIONS_DIR}
-DMYX_CMAKE_GIT_INFO_FILE=${output_file} -P ${MYX_CMAKE_FUNCTIONS_DIR}/MyxCMakeGitInfo.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
# cmake-format: on

View File

@ -1,14 +1,14 @@
function(myx_cmake_generate_private_config_header)
include(${CMAKE_CURRENT_LIST_DIR}/MyxCMakeLargeFiles.cmake)
include(MyxCMakeLargeFiles)
myx_cmake_test_large_files(HAVE_LARGEFILES)
set(output_file ${CMAKE_BINARY_DIR}/include/myx_cmake_private_config.hpp)
if(MYX_CMAKE_GENERATED_HEADERS_PATH)
set(output_file ${CMLIB_GENERATED_HEADERS_PATH}/myx_cmake_private_config.hpp)
set(output_file ${MYX_CMAKE_GENERATED_HEADERS_PATH}/myx_cmake_private_config.hpp)
elseif(ARGV0)
set(output_file ${ARGV0})
endif()
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
configure_file(${CMAKE_CURRENT_LIST_DIR}/hpp/myx_cmake_private_config.hpp.in ${output_file})
configure_file(${MYX_CMAKE_FUNCTIONS_DIR}/hpp/myx_cmake_private_config.hpp.in ${output_file})
endfunction()

View File

@ -22,4 +22,4 @@ if(GIT_EXECUTABLE)
endif()
endif()
configure_file(${CMAKE_CURRENT_LIST_DIR}/hpp/mux_cmake_git_info.hpp.in ${MYX_CMAKE_GIT_VERSION_FILE})
configure_file(${MYX_CMAKE_FUNCTIONS_DIR}/hpp/myx_cmake_git_info.hpp.in ${MYX_CMAKE_GIT_INFO_FILE})

View File

@ -61,14 +61,14 @@ macro(myx_cmake_test_large_files VARIABLE)
message(STATUS "Checking for 64-bit off_t")
# First check without any special flags
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_LIST_DIR}/largefiles/TestFileOffsetBits.c")
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestFileOffsetBits.c")
if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present")
endif()
if(NOT FILE64_OK)
# Test with _FILE_OFFSET_BITS=64
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_LIST_DIR}/largefiles/TestFileOffsetBits.c"
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestFileOffsetBits.c"
COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64")
@ -78,7 +78,7 @@ macro(myx_cmake_test_large_files VARIABLE)
if(NOT FILE64_OK)
# Test with _LARGE_FILES
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_LIST_DIR}/largefiles/TestFileOffsetBits.c"
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestFileOffsetBits.c"
COMPILE_DEFINITIONS "-D_LARGE_FILES")
if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES")
@ -88,7 +88,7 @@ macro(myx_cmake_test_large_files VARIABLE)
if(NOT FILE64_OK)
# Test with _LARGEFILE_SOURCE
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_LIST_DIR}/largefiles/TestFileOffsetBits.c"
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestFileOffsetBits.c"
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE")
if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE")
@ -102,7 +102,7 @@ macro(myx_cmake_test_large_files VARIABLE)
# 64-bit off_t found. Now check that ftello/fseeko is available.
# Set the flags we might have determined to be required above
configure_file("${CMAKE_CURRENT_LIST_DIR}/largefiles/TestLargeFiles.c.in"
configure_file("${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestLargeFiles.c.in"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
message(STATUS "Checking for fseeko/ftello")
@ -132,7 +132,7 @@ macro(myx_cmake_test_large_files VARIABLE)
# cmake-lint: disable=C0103
if(NOT FILE64_OK)
# now check for Windows stuff
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_LIST_DIR}/largefiles/TestWindowsFSeek.c")
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestWindowsFSeek.c")
if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _fseeki64")
set(HAVE__FSEEKI64 1 CACHE INTERNAL "64-bit off_t requires _fseeki64")

View File

@ -36,14 +36,13 @@ function(myx_cmake_qt5_translation outfiles)
${CMAKE_BINARY_DIR}/${_qm} DEPENDS ${_ts} ${_sources})
endforeach()
# configure_file(${CMLIB_MODULE_DIR}/qrc/l10n.qrc.in ${CMAKE_BINARY_DIR}/${_base_name}_l10n.qrc)
file(WRITE ${CMAKE_BINARY_DIR}/${_base_name}_l10n.qrc
"<RCC>\n"
" <qresource prefix="/qm">\n"
" <qresource prefix=\"/qm\">\n"
" ${L10N_QRC_BODY}\n"
" </qresource>\n"
"</RCC>\n"
)
)
qt5_add_resources(${outfiles} ${CMAKE_BINARY_DIR}/${_base_name}_l10n.qrc)
add_custom_target(${_base_name}_qrc DEPENDS ${_qrc})
add_custom_target(${_base_name}_l10n DEPENDS ${_l10n_names_list})

View File

@ -1,94 +1,94 @@
#ifndef @CMLIB_PROJECT_NAME_UPPER@_CMLIB_CONFIG_HPP_
#define @CMLIB_PROJECT_NAME_UPPER@_CMLIB_CONFIG_HPP_
#ifndef @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_
#define @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_
#pragma once
#define @CMLIB_PROJECT_NAME_UPPER@_VERSION_STR "@PROJECT_VERSION@"
#define @CMLIB_PROJECT_NAME_UPPER@_VERSION_INT @PROJECT_VERSION_INT@
#define @MYX_CMAKE_PROJECT_NAME_UPPER@_VERSION_STR "@PROJECT_VERSION@"
#define @MYX_CMAKE_PROJECT_NAME_UPPER@_VERSION_INT @PROJECT_VERSION_INT@
#if defined (CMLIB_ORGANIZATION_NAME)
#error "Duplicate definition of macros CMLIB_ORGANIZATION_NAME"
#if defined (MYX_CMAKE_ORGANIZATION_NAME)
#error "Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME"
#else
#define CMLIB_ORGANIZATION_NAME "@CMLIB_ORGANIZATION_NAME@"
#define MYX_CMAKE_ORGANIZATION_NAME "@MYX_CMAKE_ORGANIZATION_NAME@"
#endif
#if defined (CMLIB_ORGANIZATION_NAME_LOWER)
#error "Duplicate definition of macros CMLIB_ORGANIZATION_NAME_LOWER"
#if defined (MYX_CMAKE_ORGANIZATION_NAME_LOWER)
#error "Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME_LOWER"
#else
#define CMLIB_ORGANIZATION_NAME_LOWER "@CMLIB_ORGANIZATION_NAME_LOWER@"
#define MYX_CMAKE_ORGANIZATION_NAME_LOWER "@MYX_CMAKE_ORGANIZATION_NAME_LOWER@"
#endif
#if defined (CMLIB_ORGANIZATION_NAME_UPPER)
#error "Duplicate definition of macros CMLIB_ORGANIZATION_NAME_UPPER"
#if defined (MYX_CMAKE_ORGANIZATION_NAME_UPPER)
#error "Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME_UPPER"
#else
#define CMLIB_ORGANIZATION_NAME_UPPER "@CMLIB_ORGANIZATION_NAME_UPPER@"
#define MYX_CMAKE_ORGANIZATION_NAME_UPPER "@MYX_CMAKE_ORGANIZATION_NAME_UPPER@"
#endif
#if defined (CMLIB_PROJECT_NAME)
#error "Duplicate definition of macros CMLIB_PROJECT_NAME"
#if defined (MYX_CMAKE_PROJECT_NAME)
#error "Duplicate definition of macros MYX_CMAKE_PROJECT_NAME"
#else
#define CMLIB_PROJECT_NAME "@CMAKE_PROJECT_NAME@"
#define MYX_CMAKE_PROJECT_NAME "@CMAKE_PROJECT_NAME@"
#endif
#if defined (CMLIB_PROJECT_NAME_LOWER)
#error "Duplicate definition of macros CMLIB_PROJECT_NAME_LOWER"
#if defined (MYX_CMAKE_PROJECT_NAME_LOWER)
#error "Duplicate definition of macros MYX_CMAKE_PROJECT_NAME_LOWER"
#else
#define CMLIB_PROJECT_NAME_LOWER "@CMLIB_PROJECT_NAME_LOWER@"
#define MYX_CMAKE_PROJECT_NAME_LOWER "@MYX_CMAKE_PROJECT_NAME_LOWER@"
#endif
#if defined (CMLIB_PROJECT_NAME_UPPER)
#error "Duplicate definition of macros CMLIB_PROJECT_NAME_UPPER"
#if defined (MYX_CMAKE_PROJECT_NAME_UPPER)
#error "Duplicate definition of macros MYX_CMAKE_PROJECT_NAME_UPPER"
#else
#define CMLIB_PROJECT_NAME_UPPER "@CMLIB_PROJECT_NAME_UPPER@"
#define MYX_CMAKE_PROJECT_NAME_UPPER "@MYX_CMAKE_PROJECT_NAME_UPPER@"
#endif
#if defined (CMLIB_THEME_NAME)
#error "Duplicate definition of macros CMLIB_THEME_NAME"
#if defined (MYX_CMAKE_THEME_NAME)
#error "Duplicate definition of macros MYX_CMAKE_THEME_NAME"
#else
#define CMLIB_THEME_NAME "@CMLIB_THEME_NAME@"
#define MYX_CMAKE_THEME_NAME "@MYX_CMAKE_THEME_NAME@"
#endif
#if defined (CMLIB_THEME_NAME_LOWER)
#error "Duplicate definition of macros CMLIB_THEME_NAME_LOWER"
#if defined (MYX_CMAKE_THEME_NAME_LOWER)
#error "Duplicate definition of macros MYX_CMAKE_THEME_NAME_LOWER"
#else
#define CMLIB_THEME_NAME_LOWER "@CMLIB_THEME_NAME_LOWER@"
#define MYX_CMAKE_THEME_NAME_LOWER "@MYX_CMAKE_THEME_NAME_LOWER@"
#endif
#if defined (CMLIB_THEME_NAME_UPPER)
#error "Duplicate definition of macros CMLIB_THEME_NAME_UPPER"
#if defined (MYX_CMAKE_THEME_NAME_UPPER)
#error "Duplicate definition of macros MYX_CMAKE_THEME_NAME_UPPER"
#else
#define CMLIB_THEME_NAME_UPPER "@CMLIB_THEME_NAME_UPPER@"
#define MYX_CMAKE_THEME_NAME_UPPER "@MYX_CMAKE_THEME_NAME_UPPER@"
#endif
#if defined (CMLIB_AUTHOR_NAME)
#error "Duplicate definition of macros CMLIB_AUTHOR_NAME"
#if defined (MYX_CMAKE_AUTHOR_NAME)
#error "Duplicate definition of macros MYX_CMAKE_AUTHOR_NAME"
#else
#define CMLIB_AUTHOR_NAME "@CMLIB_AUTHOR_NAME@"
#define MYX_CMAKE_AUTHOR_NAME "@MYX_CMAKE_AUTHOR_NAME@"
#endif
#if defined (CMLIB_AUTHOR_EMAIL)
#error "Duplicate definition of macros CMLIB_AUTHOR_EMAIL"
#if defined (MYX_CMAKE_AUTHOR_EMAIL)
#error "Duplicate definition of macros MYX_CMAKE_AUTHOR_EMAIL"
#else
#define CMLIB_AUTHOR_EMAIL "@CMLIB_AUTHOR_EMAIL@"
#define MYX_CMAKE_AUTHOR_EMAIL "@MYX_CMAKE_AUTHOR_EMAIL@"
#endif
#if defined (CMLIB_DESCRIPTION)
#error "Duplicate definition of macros CMLIB_DESCRIPTION"
#if defined (MYX_CMAKE_DESCRIPTION)
#error "Duplicate definition of macros MYX_CMAKE_DESCRIPTION"
#else
#define CMLIB_DESCRIPTION "@CMLIB_DESCRIPTION@"
#define MYX_CMAKE_DESCRIPTION "@MYX_CMAKE_DESCRIPTION@"
#endif
#if defined (CMLIB_BUILD_TYPE)
#error "Duplicate definition of macros CMLIB_BUILD_TYPE"
#if defined (MYX_CMAKE_BUILD_TYPE)
#error "Duplicate definition of macros MYX_CMAKE_BUILD_TYPE"
#else
#define CMLIB_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
#define MYX_CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
#endif
#if defined (CMLIB_BUILD_DATE)
#error "Duplicate definition of macros CMLIB_BUILD_DATE"
#if defined (MYX_CMAKE_BUILD_DATE)
#error "Duplicate definition of macros MYX_CMAKE_BUILD_DATE"
#else
#define CMLIB_BUILD_DATE "@TODAY@"
#define MYX_CMAKE_BUILD_DATE "@TODAY@"
#endif
#endif /* @CMLIB_PROJECT_NAME_UPPER@_CMLIB_CONFIG_HPP_ */
#endif /* @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_ */

View File

@ -63,7 +63,7 @@ if(MYX_CMAKE_CPACK_DEFAULT_SCHEME)
endif()
# Правила для сборки пакетов для Debian
include(CMLibCPackDeb)
include(MyxCMakeCPackDeb)
# Подключение модуля, выполняющего сборку архивов и пакетов
include(CPack)

View File

@ -32,12 +32,20 @@ include(MyxCMakeAddSharedLibrary)
include(MyxCMakeAddStaticLibrary)
include(MyxCMakePkgConfig)
include(MyxCMakeNinjaGeneratorHelper)
include(CMLibGit)
# include(CMLibDocDoxygen) include(CMLibDocBreathe)
# include(CMLibExternalProject)
include(MyxCMakeCPack)
include(MyxCMakeUninstall)
# Additional functions
include(MyxCMakeGenerateGitInfoHeader)
include(MyxCMakeGeneratePrivateConfigHeader)
include(MyxCMakeHighPrecisionMath)
include(MyxCMakeLargeFiles)
include(MyxCMakeQtTranslation)
include(MyxCMakeRemoveFlag)
include(MyxCMakeWriteCompilerDetectionHeader)

View File

@ -1,5 +1,5 @@
if(NOT TARGET uninstall)
configure_file("${CMAKE_CURRENT_LIST_DIR}/CMLibUninstall.cmake.in"
configure_file("${CMAKE_CURRENT_LIST_DIR}/MyxCMakeUninstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)

View File

@ -2,7 +2,7 @@
set -e
V=$(grep -i "project.*VERSION" CMakeLists.txt | sed 's/.* \([0-9.]*\).*)/\1/')
V=$(grep -i "project.*VERSION.*LANGUAGES" CMakeLists.txt | sed 's/.*VERSION \([0-9.]*\) .*/\1/')
D=$(mktemp -d "/tmp/myx-cmake.XXXXXX")
mkdir -p "$D/myx-cmake-$V"
cp -ap CMakeLists.txt MyxCMake "$D/myx-cmake-$V"
@ -14,4 +14,5 @@ pushd "$D/myx-cmake-$V"
dch -D unstable -v "${V}-1" -m "New version."
debuild
popd
cp -f ${D}/myx*deb .