Чистка кода

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) cmake_minimum_required(VERSION 3.0)
project(myx-cmake VERSION 0.1.2) project(myx-cmake VERSION 0.2.0 LANGUAGES)
include(GNUInstallDirs) 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") 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) if(NOT TARGET myx-cmake-git-info-header)
add_custom_target(myx-cmake-git-info-header ALL add_custom_target(myx-cmake-git-info-header ALL
${CMAKE_COMMAND} -DMYX_CMAKE_PROJECT_NAME_UPPER=${MYX_CMAKE_PROJECT_NAME_UPPER} ${CMAKE_COMMAND} -DMYX_CMAKE_PROJECT_NAME_UPPER=${MYX_CMAKE_PROJECT_NAME_UPPER}
-DMYX_CMAKE_MODULE_DIR=${MYX_CMAKE_MODULE_DIR} -DMYX_CMAKE_FUNCTIONS_DIR=${MYX_CMAKE_FUNCTIONS_DIR}
-DMYX_CMAKE_GIT_INFO_FILE=${output_file} -P ${CMAKE_CURRENT_LIST_DIR}/MyxCMakeGitInfo.cmake -DMYX_CMAKE_GIT_INFO_FILE=${output_file} -P ${MYX_CMAKE_FUNCTIONS_DIR}/MyxCMakeGitInfo.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif() endif()
# cmake-format: on # cmake-format: on

View File

@ -1,14 +1,14 @@
function(myx_cmake_generate_private_config_header) function(myx_cmake_generate_private_config_header)
include(${CMAKE_CURRENT_LIST_DIR}/MyxCMakeLargeFiles.cmake) include(MyxCMakeLargeFiles)
myx_cmake_test_large_files(HAVE_LARGEFILES) myx_cmake_test_large_files(HAVE_LARGEFILES)
set(output_file ${CMAKE_BINARY_DIR}/include/myx_cmake_private_config.hpp) set(output_file ${CMAKE_BINARY_DIR}/include/myx_cmake_private_config.hpp)
if(MYX_CMAKE_GENERATED_HEADERS_PATH) 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) elseif(ARGV0)
set(output_file ${ARGV0}) set(output_file ${ARGV0})
endif() endif()
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT) 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() endfunction()

View File

@ -22,4 +22,4 @@ if(GIT_EXECUTABLE)
endif() endif()
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") message(STATUS "Checking for 64-bit off_t")
# First check without any special flags # 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) if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present") message(STATUS "Checking for 64-bit off_t - present")
endif() endif()
if(NOT FILE64_OK) if(NOT FILE64_OK)
# Test with _FILE_OFFSET_BITS=64 # 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") COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64")
if(FILE64_OK) if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _FILE_OFFSET_BITS=64") 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) if(NOT FILE64_OK)
# Test with _LARGE_FILES # 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") COMPILE_DEFINITIONS "-D_LARGE_FILES")
if(FILE64_OK) if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES") 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) if(NOT FILE64_OK)
# Test with _LARGEFILE_SOURCE # 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") COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE")
if(FILE64_OK) if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE") 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. # 64-bit off_t found. Now check that ftello/fseeko is available.
# Set the flags we might have determined to be required above # 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") "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
message(STATUS "Checking for fseeko/ftello") message(STATUS "Checking for fseeko/ftello")
@ -132,7 +132,7 @@ macro(myx_cmake_test_large_files VARIABLE)
# cmake-lint: disable=C0103 # cmake-lint: disable=C0103
if(NOT FILE64_OK) if(NOT FILE64_OK)
# now check for Windows stuff # 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) if(FILE64_OK)
message(STATUS "Checking for 64-bit off_t - present with _fseeki64") message(STATUS "Checking for 64-bit off_t - present with _fseeki64")
set(HAVE__FSEEKI64 1 CACHE INTERNAL "64-bit off_t requires _fseeki64") set(HAVE__FSEEKI64 1 CACHE INTERNAL "64-bit off_t requires _fseeki64")

View File

@ -36,10 +36,9 @@ function(myx_cmake_qt5_translation outfiles)
${CMAKE_BINARY_DIR}/${_qm} DEPENDS ${_ts} ${_sources}) ${CMAKE_BINARY_DIR}/${_qm} DEPENDS ${_ts} ${_sources})
endforeach() 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 file(WRITE ${CMAKE_BINARY_DIR}/${_base_name}_l10n.qrc
"<RCC>\n" "<RCC>\n"
" <qresource prefix="/qm">\n" " <qresource prefix=\"/qm\">\n"
" ${L10N_QRC_BODY}\n" " ${L10N_QRC_BODY}\n"
" </qresource>\n" " </qresource>\n"
"</RCC>\n" "</RCC>\n"

View File

@ -1,94 +1,94 @@
#ifndef @CMLIB_PROJECT_NAME_UPPER@_CMLIB_CONFIG_HPP_ #ifndef @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_
#define @CMLIB_PROJECT_NAME_UPPER@_CMLIB_CONFIG_HPP_ #define @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_
#pragma once #pragma once
#define @CMLIB_PROJECT_NAME_UPPER@_VERSION_STR "@PROJECT_VERSION@" #define @MYX_CMAKE_PROJECT_NAME_UPPER@_VERSION_STR "@PROJECT_VERSION@"
#define @CMLIB_PROJECT_NAME_UPPER@_VERSION_INT @PROJECT_VERSION_INT@ #define @MYX_CMAKE_PROJECT_NAME_UPPER@_VERSION_INT @PROJECT_VERSION_INT@
#if defined (CMLIB_ORGANIZATION_NAME) #if defined (MYX_CMAKE_ORGANIZATION_NAME)
#error "Duplicate definition of macros CMLIB_ORGANIZATION_NAME" #error "Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME"
#else #else
#define CMLIB_ORGANIZATION_NAME "@CMLIB_ORGANIZATION_NAME@" #define MYX_CMAKE_ORGANIZATION_NAME "@MYX_CMAKE_ORGANIZATION_NAME@"
#endif #endif
#if defined (CMLIB_ORGANIZATION_NAME_LOWER) #if defined (MYX_CMAKE_ORGANIZATION_NAME_LOWER)
#error "Duplicate definition of macros CMLIB_ORGANIZATION_NAME_LOWER" #error "Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME_LOWER"
#else #else
#define CMLIB_ORGANIZATION_NAME_LOWER "@CMLIB_ORGANIZATION_NAME_LOWER@" #define MYX_CMAKE_ORGANIZATION_NAME_LOWER "@MYX_CMAKE_ORGANIZATION_NAME_LOWER@"
#endif #endif
#if defined (CMLIB_ORGANIZATION_NAME_UPPER) #if defined (MYX_CMAKE_ORGANIZATION_NAME_UPPER)
#error "Duplicate definition of macros CMLIB_ORGANIZATION_NAME_UPPER" #error "Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME_UPPER"
#else #else
#define CMLIB_ORGANIZATION_NAME_UPPER "@CMLIB_ORGANIZATION_NAME_UPPER@" #define MYX_CMAKE_ORGANIZATION_NAME_UPPER "@MYX_CMAKE_ORGANIZATION_NAME_UPPER@"
#endif #endif
#if defined (CMLIB_PROJECT_NAME) #if defined (MYX_CMAKE_PROJECT_NAME)
#error "Duplicate definition of macros CMLIB_PROJECT_NAME" #error "Duplicate definition of macros MYX_CMAKE_PROJECT_NAME"
#else #else
#define CMLIB_PROJECT_NAME "@CMAKE_PROJECT_NAME@" #define MYX_CMAKE_PROJECT_NAME "@CMAKE_PROJECT_NAME@"
#endif #endif
#if defined (CMLIB_PROJECT_NAME_LOWER) #if defined (MYX_CMAKE_PROJECT_NAME_LOWER)
#error "Duplicate definition of macros CMLIB_PROJECT_NAME_LOWER" #error "Duplicate definition of macros MYX_CMAKE_PROJECT_NAME_LOWER"
#else #else
#define CMLIB_PROJECT_NAME_LOWER "@CMLIB_PROJECT_NAME_LOWER@" #define MYX_CMAKE_PROJECT_NAME_LOWER "@MYX_CMAKE_PROJECT_NAME_LOWER@"
#endif #endif
#if defined (CMLIB_PROJECT_NAME_UPPER) #if defined (MYX_CMAKE_PROJECT_NAME_UPPER)
#error "Duplicate definition of macros CMLIB_PROJECT_NAME_UPPER" #error "Duplicate definition of macros MYX_CMAKE_PROJECT_NAME_UPPER"
#else #else
#define CMLIB_PROJECT_NAME_UPPER "@CMLIB_PROJECT_NAME_UPPER@" #define MYX_CMAKE_PROJECT_NAME_UPPER "@MYX_CMAKE_PROJECT_NAME_UPPER@"
#endif #endif
#if defined (CMLIB_THEME_NAME) #if defined (MYX_CMAKE_THEME_NAME)
#error "Duplicate definition of macros CMLIB_THEME_NAME" #error "Duplicate definition of macros MYX_CMAKE_THEME_NAME"
#else #else
#define CMLIB_THEME_NAME "@CMLIB_THEME_NAME@" #define MYX_CMAKE_THEME_NAME "@MYX_CMAKE_THEME_NAME@"
#endif #endif
#if defined (CMLIB_THEME_NAME_LOWER) #if defined (MYX_CMAKE_THEME_NAME_LOWER)
#error "Duplicate definition of macros CMLIB_THEME_NAME_LOWER" #error "Duplicate definition of macros MYX_CMAKE_THEME_NAME_LOWER"
#else #else
#define CMLIB_THEME_NAME_LOWER "@CMLIB_THEME_NAME_LOWER@" #define MYX_CMAKE_THEME_NAME_LOWER "@MYX_CMAKE_THEME_NAME_LOWER@"
#endif #endif
#if defined (CMLIB_THEME_NAME_UPPER) #if defined (MYX_CMAKE_THEME_NAME_UPPER)
#error "Duplicate definition of macros CMLIB_THEME_NAME_UPPER" #error "Duplicate definition of macros MYX_CMAKE_THEME_NAME_UPPER"
#else #else
#define CMLIB_THEME_NAME_UPPER "@CMLIB_THEME_NAME_UPPER@" #define MYX_CMAKE_THEME_NAME_UPPER "@MYX_CMAKE_THEME_NAME_UPPER@"
#endif #endif
#if defined (CMLIB_AUTHOR_NAME) #if defined (MYX_CMAKE_AUTHOR_NAME)
#error "Duplicate definition of macros CMLIB_AUTHOR_NAME" #error "Duplicate definition of macros MYX_CMAKE_AUTHOR_NAME"
#else #else
#define CMLIB_AUTHOR_NAME "@CMLIB_AUTHOR_NAME@" #define MYX_CMAKE_AUTHOR_NAME "@MYX_CMAKE_AUTHOR_NAME@"
#endif #endif
#if defined (CMLIB_AUTHOR_EMAIL) #if defined (MYX_CMAKE_AUTHOR_EMAIL)
#error "Duplicate definition of macros CMLIB_AUTHOR_EMAIL" #error "Duplicate definition of macros MYX_CMAKE_AUTHOR_EMAIL"
#else #else
#define CMLIB_AUTHOR_EMAIL "@CMLIB_AUTHOR_EMAIL@" #define MYX_CMAKE_AUTHOR_EMAIL "@MYX_CMAKE_AUTHOR_EMAIL@"
#endif #endif
#if defined (CMLIB_DESCRIPTION) #if defined (MYX_CMAKE_DESCRIPTION)
#error "Duplicate definition of macros CMLIB_DESCRIPTION" #error "Duplicate definition of macros MYX_CMAKE_DESCRIPTION"
#else #else
#define CMLIB_DESCRIPTION "@CMLIB_DESCRIPTION@" #define MYX_CMAKE_DESCRIPTION "@MYX_CMAKE_DESCRIPTION@"
#endif #endif
#if defined (CMLIB_BUILD_TYPE) #if defined (MYX_CMAKE_BUILD_TYPE)
#error "Duplicate definition of macros CMLIB_BUILD_TYPE" #error "Duplicate definition of macros MYX_CMAKE_BUILD_TYPE"
#else #else
#define CMLIB_BUILD_TYPE "@CMAKE_BUILD_TYPE@" #define MYX_CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@"
#endif #endif
#if defined (CMLIB_BUILD_DATE) #if defined (MYX_CMAKE_BUILD_DATE)
#error "Duplicate definition of macros CMLIB_BUILD_DATE" #error "Duplicate definition of macros MYX_CMAKE_BUILD_DATE"
#else #else
#define CMLIB_BUILD_DATE "@TODAY@" #define MYX_CMAKE_BUILD_DATE "@TODAY@"
#endif #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() endif()
# Правила для сборки пакетов для Debian # Правила для сборки пакетов для Debian
include(CMLibCPackDeb) include(MyxCMakeCPackDeb)
# Подключение модуля, выполняющего сборку архивов и пакетов # Подключение модуля, выполняющего сборку архивов и пакетов
include(CPack) include(CPack)

View File

@ -32,12 +32,20 @@ include(MyxCMakeAddSharedLibrary)
include(MyxCMakeAddStaticLibrary) include(MyxCMakeAddStaticLibrary)
include(MyxCMakePkgConfig) include(MyxCMakePkgConfig)
include(MyxCMakeNinjaGeneratorHelper) include(MyxCMakeNinjaGeneratorHelper)
include(CMLibGit)
# include(CMLibDocDoxygen) include(CMLibDocBreathe) # include(CMLibDocDoxygen) include(CMLibDocBreathe)
# include(CMLibExternalProject) # include(CMLibExternalProject)
include(MyxCMakeCPack) include(MyxCMakeCPack)
include(MyxCMakeUninstall) 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) 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) "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)

View File

@ -2,7 +2,7 @@
set -e 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") D=$(mktemp -d "/tmp/myx-cmake.XXXXXX")
mkdir -p "$D/myx-cmake-$V" mkdir -p "$D/myx-cmake-$V"
cp -ap CMakeLists.txt MyxCMake "$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." dch -D unstable -v "${V}-1" -m "New version."
debuild debuild
popd popd
cp -f ${D}/myx*deb .