From dd2a4fdb7dc2e762f53fc985beee30fe80fcf6c6 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Fri, 6 May 2022 12:49:46 +0300 Subject: [PATCH] =?UTF-8?q?0.7.0=20(=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 4 +- MyxCMake/MyxCMakeConfig.cmake | 9 - .../MyxCMakeGenerateGitInfoHeader.cmake | 19 - .../MyxCMakeGeneratePrivateConfigHeader.cmake | 14 - MyxCMake/functions/MyxCMakeGitInfo.cmake | 25 -- MyxCMake/functions/doc/Doxyfile.in | 383 ------------------ .../functions/hpp/myx_cmake_git_info.hpp.in | 31 -- .../hpp/myx_cmake_private_config.hpp.in | 94 ----- .../functions/largefiles/TestFileOffsetBits.c | 11 - .../functions/largefiles/TestLargeFiles.c.in | 24 -- .../functions/largefiles/TestWindowsFSeek.c | 11 - .../modules/MyxCMakeAddSharedLibrary.cmake | 3 + .../modules/MyxCMakeAddStaticLibrary.cmake | 3 + MyxCMake/modules/MyxCMakeBuildTypes.cmake | 3 + MyxCMake/modules/MyxCMakeCPack.cmake | 3 + ...MyxCMakeCodeAnalyzeApplyReplacements.cmake | 3 + .../MyxCMakeCodeAnalyzeClangCheck.cmake | 3 + .../MyxCMakeCodeAnalyzeClangTidy.cmake | 3 + .../modules/MyxCMakeCodeAnalyzeClazy.cmake | 3 + .../MyxCMakeCodeAnalyzePvsStudio.cmake | 3 + MyxCMake/modules/MyxCMakeCodeCoverage.cmake | 3 + .../modules/MyxCMakeColoredMessages.cmake | 4 + MyxCMake/modules/MyxCMakeCommon.cmake | 42 +- MyxCMake/modules/MyxCMakeCommonPaths.cmake | 4 + .../MyxCMakeCommonTargetProperties.cmake | 5 + ...xCMakePaths.cmake => MyxCMakeCompat.cmake} | 2 +- .../modules/MyxCMakeCompatIncludeGuard.cmake | 13 + MyxCMake/modules/MyxCMakeCompiler.cmake | 19 +- MyxCMake/modules/MyxCMakeCompilerFlags.cmake | 62 ++- ...eDates.cmake => MyxCMakeCurrentDate.cmake} | 3 +- .../modules/MyxCMakeDebugOutputOptions.cmake | 7 +- ....cmake => MyxCMakeDirectoriesGuards.cmake} | 13 +- MyxCMake/modules/MyxCMakeDistCC.cmake | 2 + .../MyxCMakeDocBreathe.cmake | 3 + .../MyxCMakeDocDoxygen.cmake | 50 ++- .../modules/MyxCMakeExternalProject.cmake | 3 + MyxCMake/modules/MyxCMakeFormatSources.cmake | 3 + .../MyxCMakeGenerateGitInfoHeader.cmake | 85 ++++ .../MyxCMakeGeneratePrivateConfigHeader.cmake | 116 ++++++ .../modules/MyxCMakeGlobalFunctions.cmake | 18 +- .../modules/MyxCMakeGlobalVariables.cmake | 10 +- .../MyxCMakeHighPrecisionMath.cmake | 3 + .../MyxCMakeIncludeSystemModules.cmake | 3 + MyxCMake/modules/MyxCMakeLSBInfo.cmake | 26 +- .../MyxCMakeLargeFiles.cmake | 82 +++- .../MyxCMakeNinjaGeneratorHelper.cmake | 3 + MyxCMake/modules/MyxCMakePkgConfig.cmake | 3 + .../modules/MyxCMakePrecompiledHeaders.cmake | 3 + MyxCMake/modules/MyxCMakeProjectVersion.cmake | 2 + .../MyxCMakeQtTranslation.cmake | 3 + .../MyxCMakeRemoveFlag.cmake | 3 + .../modules/MyxCMakeRequiredVariables.cmake | 26 +- MyxCMake/modules/MyxCMakeUninstall.cmake | 3 + MyxCMake/modules/MyxCMakeUnityBuild.cmake | 2 + ...MyxCMakeWriteCompilerDetectionHeader.cmake | 3 + .../doc/breathe-conf.py.in | 0 56 files changed, 526 insertions(+), 758 deletions(-) delete mode 100644 MyxCMake/functions/MyxCMakeGenerateGitInfoHeader.cmake delete mode 100644 MyxCMake/functions/MyxCMakeGeneratePrivateConfigHeader.cmake delete mode 100644 MyxCMake/functions/MyxCMakeGitInfo.cmake delete mode 100644 MyxCMake/functions/doc/Doxyfile.in delete mode 100644 MyxCMake/functions/hpp/myx_cmake_git_info.hpp.in delete mode 100644 MyxCMake/functions/hpp/myx_cmake_private_config.hpp.in delete mode 100644 MyxCMake/functions/largefiles/TestFileOffsetBits.c delete mode 100644 MyxCMake/functions/largefiles/TestLargeFiles.c.in delete mode 100644 MyxCMake/functions/largefiles/TestWindowsFSeek.c create mode 100644 MyxCMake/modules/MyxCMakeCommonPaths.cmake rename MyxCMake/modules/{MyxCMakePaths.cmake => MyxCMakeCompat.cmake} (84%) create mode 100644 MyxCMake/modules/MyxCMakeCompatIncludeGuard.cmake rename MyxCMake/modules/{MyxCMakeDates.cmake => MyxCMakeCurrentDate.cmake} (96%) rename MyxCMake/modules/{MyxCMakeCheckPaths.cmake => MyxCMakeDirectoriesGuards.cmake} (54%) rename MyxCMake/{functions => modules}/MyxCMakeDocBreathe.cmake (99%) rename MyxCMake/{functions => modules}/MyxCMakeDocDoxygen.cmake (54%) create mode 100644 MyxCMake/modules/MyxCMakeGenerateGitInfoHeader.cmake create mode 100644 MyxCMake/modules/MyxCMakeGeneratePrivateConfigHeader.cmake rename MyxCMake/{functions => modules}/MyxCMakeHighPrecisionMath.cmake (93%) create mode 100644 MyxCMake/modules/MyxCMakeIncludeSystemModules.cmake rename MyxCMake/{functions => modules}/MyxCMakeLargeFiles.cmake (68%) rename MyxCMake/{functions => modules}/MyxCMakeQtTranslation.cmake (98%) rename MyxCMake/{functions => modules}/MyxCMakeRemoveFlag.cmake (99%) rename MyxCMake/{functions => modules}/MyxCMakeWriteCompilerDetectionHeader.cmake (96%) rename MyxCMake/{functions => modules}/doc/breathe-conf.py.in (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 17c382d..52dd225 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.0) -project(myx-cmake VERSION 0.6.0 LANGUAGES) +cmake_minimum_required(VERSION 3.6) +project(myx-cmake VERSION 0.7.0 LANGUAGES) include(GNUInstallDirs) file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake diff --git a/MyxCMake/MyxCMakeConfig.cmake b/MyxCMake/MyxCMakeConfig.cmake index 48d5f02..27b5a96 100644 --- a/MyxCMake/MyxCMakeConfig.cmake +++ b/MyxCMake/MyxCMakeConfig.cmake @@ -3,15 +3,6 @@ cmake_policy(SET CMP0057 NEW) # IN_LIST operator get_filename_component(MYX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -set(MYX_CMAKE_FUNCTIONS_DIR "${MYX_CMAKE_DIR}/functions") -if(NOT IS_DIRECTORY "${MYX_CMAKE_FUNCTIONS_DIR}") - myx_cmake_message_warning("MyxCMake: Functions directory is not found.") -else() - if(NOT ${MYX_CMAKE_FUNCTIONS_DIR} IN_LIST CMAKE_MODULE_PATH) - list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_FUNCTIONS_DIR}") - endif() -endif() - set(MYX_CMAKE_THIRDPARTY_DIR "${MYX_CMAKE_DIR}/thirdparty") if(NOT IS_DIRECTORY "${MYX_CMAKE_THIRDPARTY_DIR}") myx_cmake_message_warning("MyxCMake: Thirdparty submodule is not found.") diff --git a/MyxCMake/functions/MyxCMakeGenerateGitInfoHeader.cmake b/MyxCMake/functions/MyxCMakeGenerateGitInfoHeader.cmake deleted file mode 100644 index 7df7bf6..0000000 --- a/MyxCMake/functions/MyxCMakeGenerateGitInfoHeader.cmake +++ /dev/null @@ -1,19 +0,0 @@ -function(myx_cmake_generate_git_info_header) - set(output_file ${CMAKE_BINARY_DIR}/include/myx_cmake_git_info_p.hpp) - if(MYX_CMAKE_GENERATED_HEADERS_PATH) - set(output_file ${MYX_CMAKE_GENERATED_HEADERS_PATH}/myx_cmake_git_info_p.hpp) - elseif(ARGV0) - set(output_file ${ARGV0}) - endif() - -# cmake-format: off - 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_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 -endfunction() - diff --git a/MyxCMake/functions/MyxCMakeGeneratePrivateConfigHeader.cmake b/MyxCMake/functions/MyxCMakeGeneratePrivateConfigHeader.cmake deleted file mode 100644 index cd1bdd0..0000000 --- a/MyxCMake/functions/MyxCMakeGeneratePrivateConfigHeader.cmake +++ /dev/null @@ -1,14 +0,0 @@ -function(myx_cmake_generate_private_config_header) - include(MyxCMakeLargeFiles) - myx_cmake_test_large_files(HAVE_LARGEFILES) - - set(output_file ${CMAKE_BINARY_DIR}/include/myx_cmake_private_config_p.hpp) - if(MYX_CMAKE_GENERATED_HEADERS_PATH) - set(output_file ${MYX_CMAKE_GENERATED_HEADERS_PATH}/myx_cmake_private_config_p.hpp) - elseif(ARGV0) - set(output_file ${ARGV0}) - endif() - - get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT) - configure_file(${MYX_CMAKE_FUNCTIONS_DIR}/hpp/myx_cmake_private_config.hpp.in ${output_file}) -endfunction() diff --git a/MyxCMake/functions/MyxCMakeGitInfo.cmake b/MyxCMake/functions/MyxCMakeGitInfo.cmake deleted file mode 100644 index e7961bf..0000000 --- a/MyxCMake/functions/MyxCMakeGitInfo.cmake +++ /dev/null @@ -1,25 +0,0 @@ -set(MYX_CMAKE_GIT_REV "N/A") -set(MYX_CMAKE_GIT_DIFF "") -set(MYX_CMAKE_GIT_TAG "N/A") -set(MYX_CMAKE_GIT_BRANCH "N/A") - -find_program(GIT_EXECUTABLE git) -if(GIT_EXECUTABLE) - execute_process(COMMAND git log --pretty=format:'%h' -n 1 OUTPUT_VARIABLE MYX_CMAKE_GIT_REV ERROR_QUIET) - - # Check whether we got any revision (which isn't always the case, - # e.g. when someone downloaded a zip file from Github instead of a checkout) - if(NOT "${MYX_CMAKE_GIT_REV}" STREQUAL "") - execute_process(COMMAND bash -c "git diff --quiet --exit-code || echo +" OUTPUT_VARIABLE MYX_CMAKE_GIT_DIFF) - execute_process(COMMAND git describe --exact-match --tags OUTPUT_VARIABLE MYX_CMAKE_GIT_TAG ERROR_QUIET) - execute_process(COMMAND git rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE MYX_CMAKE_GIT_BRANCH) - - string(STRIP "${MYX_CMAKE_GIT_REV}" MYX_CMAKE_GIT_REV) - string(SUBSTRING "${MYX_CMAKE_GIT_REV}" 1 7 MYX_CMAKE_GIT_REV) - string(STRIP "${MYX_CMAKE_GIT_DIFF}" MYX_CMAKE_GIT_DIFF) - string(STRIP "${MYX_CMAKE_GIT_TAG}" MYX_CMAKE_GIT_TAG) - string(STRIP "${MYX_CMAKE_GIT_BRANCH}" MYX_CMAKE_GIT_BRANCH) - endif() -endif() - -configure_file(${MYX_CMAKE_FUNCTIONS_DIR}/hpp/myx_cmake_git_info.hpp.in ${MYX_CMAKE_GIT_INFO_FILE}) diff --git a/MyxCMake/functions/doc/Doxyfile.in b/MyxCMake/functions/doc/Doxyfile.in deleted file mode 100644 index 216efcd..0000000 --- a/MyxCMake/functions/doc/Doxyfile.in +++ /dev/null @@ -1,383 +0,0 @@ -# Doxyfile 1.8.16 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = "@DOXYGEN_PROJECT_TITLE@" -PROJECT_NUMBER = -PROJECT_BRIEF = -PROJECT_LOGO = -OUTPUT_DIRECTORY = "@OUTPUT_DIRECTORY@" -CREATE_SUBDIRS = NO -ALLOW_UNICODE_NAMES = NO -OUTPUT_LANGUAGE = Russian -OUTPUT_TEXT_DIRECTION = None -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = YES -STRIP_FROM_PATH = "@CMAKE_HOME_DIRECTORY@/src" -STRIP_FROM_INC_PATH = "@CMAKE_HOME_DIRECTORY@/src" -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -JAVADOC_BANNER = NO -QT_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 4 -ALIASES = -TCL_SUBST = -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -OPTIMIZE_FOR_FORTRAN = NO -OPTIMIZE_OUTPUT_VHDL = NO -OPTIMIZE_OUTPUT_SLICE = NO -EXTENSION_MAPPING = -MARKDOWN_SUPPORT = YES -TOC_INCLUDE_HEADINGS = 5 -AUTOLINK_SUPPORT = YES -BUILTIN_STL_SUPPORT = NO -CPP_CLI_SUPPORT = NO -SIP_SUPPORT = NO -IDL_PROPERTY_SUPPORT = YES -DISTRIBUTE_GROUP_DOC = NO -GROUP_NESTED_COMPOUNDS = NO -SUBGROUPING = YES -INLINE_GROUPED_CLASSES = NO -INLINE_SIMPLE_STRUCTS = NO -TYPEDEF_HIDES_STRUCT = NO -LOOKUP_CACHE_SIZE = 0 -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_PRIV_VIRTUAL = NO -EXTRACT_PACKAGE = NO -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = YES -EXTRACT_ANON_NSPACES = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = NO -HIDE_SCOPE_NAMES = NO -HIDE_COMPOUND_REFERENCE= NO -SHOW_INCLUDE_FILES = YES -SHOW_GROUPED_MEMB_INC = NO -FORCE_LOCAL_INCLUDES = NO -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_MEMBERS_CTORS_1ST = NO -SORT_GROUP_NAMES = NO -SORT_BY_SCOPE_NAME = NO -STRICT_PROTO_MATCHING = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -SHOW_FILES = YES -SHOW_NAMESPACES = YES -FILE_VERSION_FILTER = -LAYOUT_FILE = -CITE_BIB_FILES = -#--------------------------------------------------------------------------- -# Configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_NO_PARAMDOC = NO -WARN_AS_ERROR = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# Configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = "@CMAKE_HOME_DIRECTORY@/src" \ - "@CMAKE_HOME_DIRECTORY@/doc/doxygen" -INPUT_ENCODING = UTF-8 -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.idl \ - *.ddl \ - *.odl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.cs \ - *.d \ - *.php \ - *.php4 \ - *.php5 \ - *.phtml \ - *.inc \ - *.m \ - *.markdown \ - *.md \ - *.mm \ - *.dox \ - *.py \ - *.pyw \ - *.f90 \ - *.f95 \ - *.f03 \ - *.f08 \ - *.f \ - *.for \ - *.tcl \ - *.vhd \ - *.vhdl \ - *.ucf \ - *.qsf -RECURSIVE = YES -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -FILTER_SOURCE_PATTERNS = -USE_MDFILE_AS_MAINPAGE = -#--------------------------------------------------------------------------- -# Configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = NO -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = NO -REFERENCES_RELATION = NO -REFERENCES_LINK_SOURCE = YES -SOURCE_TOOLTIPS = YES -USE_HTAGS = NO -VERBATIM_HEADERS = YES -CLANG_ASSISTED_PARSING = NO -CLANG_OPTIONS = -CLANG_DATABASE_PATH = -#--------------------------------------------------------------------------- -# Configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = @GENERATE_HTML@ -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_EXTRA_STYLESHEET = -HTML_EXTRA_FILES = -HTML_COLORSTYLE_HUE = 220 -HTML_COLORSTYLE_SAT = 100 -HTML_COLORSTYLE_GAMMA = 80 -HTML_TIMESTAMP = NO -HTML_DYNAMIC_MENUS = YES -HTML_DYNAMIC_SECTIONS = NO -HTML_INDEX_NUM_ENTRIES = 100 -GENERATE_DOCSET = NO -DOCSET_FEEDNAME = "Doxygen generated docs" -DOCSET_BUNDLE_ID = org.doxygen.Project -DOCSET_PUBLISHER_ID = org.doxygen.Publisher -DOCSET_PUBLISHER_NAME = Publisher -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -CHM_INDEX_ENCODING = -BINARY_TOC = NO -TOC_EXPAND = NO -GENERATE_QHP = NO -QCH_FILE = -QHP_NAMESPACE = org.doxygen.Project -QHP_VIRTUAL_FOLDER = doc -QHP_CUST_FILTER_NAME = -QHP_CUST_FILTER_ATTRS = -QHP_SECT_FILTER_ATTRS = -QHG_LOCATION = -GENERATE_ECLIPSEHELP = NO -ECLIPSE_DOC_ID = org.doxygen.Project -DISABLE_INDEX = NO -GENERATE_TREEVIEW = YES -ENUM_VALUES_PER_LINE = 4 -TREEVIEW_WIDTH = 250 -EXT_LINKS_IN_WINDOW = NO -FORMULA_FONTSIZE = 10 -FORMULA_TRANSPARENT = YES -USE_MATHJAX = NO -MATHJAX_FORMAT = HTML-CSS -MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2 -MATHJAX_EXTENSIONS = -MATHJAX_CODEFILE = -SEARCHENGINE = YES -SERVER_BASED_SEARCH = NO -EXTERNAL_SEARCH = NO -SEARCHENGINE_URL = -SEARCHDATA_FILE = searchdata.xml -EXTERNAL_SEARCH_ID = -EXTRA_SEARCH_MAPPINGS = -#--------------------------------------------------------------------------- -# Configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = @GENERATE_LATEX@ -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -LATEX_MAKEINDEX_CMD = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4 -EXTRA_PACKAGES = -LATEX_HEADER = -LATEX_FOOTER = -LATEX_EXTRA_STYLESHEET = -LATEX_EXTRA_FILES = -PDF_HYPERLINKS = YES -USE_PDFLATEX = YES -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -LATEX_SOURCE_CODE = NO -LATEX_BIB_STYLE = plain -LATEX_TIMESTAMP = NO -LATEX_EMOJI_DIRECTORY = -#--------------------------------------------------------------------------- -# Configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -RTF_SOURCE_CODE = NO -#--------------------------------------------------------------------------- -# Configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_SUBDIR = -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# Configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = @GENERATE_XML@ -XML_OUTPUT = xml -XML_PROGRAMLISTING = YES -XML_NS_MEMB_FILE_SCOPE = NO -#--------------------------------------------------------------------------- -# Configuration options related to the DOCBOOK output -#--------------------------------------------------------------------------- -GENERATE_DOCBOOK = NO -DOCBOOK_OUTPUT = docbook -DOCBOOK_PROGRAMLISTING = NO -#--------------------------------------------------------------------------- -# Configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# Configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration options related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -EXTERNAL_PAGES = YES -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -DIA_PATH = -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -DOT_NUM_THREADS = 0 -DOT_FONTNAME = Helvetica -DOT_FONTSIZE = 10 -DOT_FONTPATH = -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = YES -UML_LOOK = YES -UML_LIMIT_NUM_FIELDS = 10 -TEMPLATE_RELATIONS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = YES -CALLER_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = png -INTERACTIVE_SVG = YES -DOT_PATH = @DOXYGEN_DOT_PATH@ -DOTFILE_DIRS = -MSCFILE_DIRS = -DIAFILE_DIRS = -PLANTUML_JAR_PATH = -PLANTUML_CFG_FILE = -PLANTUML_INCLUDE_PATH = -DOT_GRAPH_MAX_NODES = 50 -MAX_DOT_GRAPH_DEPTH = 0 -DOT_TRANSPARENT = NO -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES - diff --git a/MyxCMake/functions/hpp/myx_cmake_git_info.hpp.in b/MyxCMake/functions/hpp/myx_cmake_git_info.hpp.in deleted file mode 100644 index 873791c..0000000 --- a/MyxCMake/functions/hpp/myx_cmake_git_info.hpp.in +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_GIT_INFO_HPP_ -#define @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_GIT_INFO_HPP_ - -#pragma once - -#if defined (@MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_REV) -#error "Duplicate definition of macros @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_REV" -#else -#define @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_REV "@MYX_CMAKE_GIT_REV@" -#endif - -#if defined (@MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_DIFF) -#error "Duplicate definition of macros @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_DIFF" -#else -#define @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_DIFF "@MYX_CMAKE_GIT_DIFF@" -#endif - -#if defined (@MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_BRANCH) -#error "Duplicate definition of macros @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_BRANCH" -#else -#define @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_BRANCH "@MYX_CMAKE_GIT_BRANCH@" -#endif - -#if defined (@MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_TAG) -#error "Duplicate definition of macros @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_TAG" -#else -#define @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_TAG "@MYX_CMAKE_GIT_TAG@" -#endif - -#endif /* @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_GIT_INFO_HPP_ */ - diff --git a/MyxCMake/functions/hpp/myx_cmake_private_config.hpp.in b/MyxCMake/functions/hpp/myx_cmake_private_config.hpp.in deleted file mode 100644 index 39c24d6..0000000 --- a/MyxCMake/functions/hpp/myx_cmake_private_config.hpp.in +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_ -#define @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_ - -#pragma once - -#define @MYX_CMAKE_PROJECT_NAME_UPPER@_VERSION_STR "@PROJECT_VERSION@" -#define @MYX_CMAKE_PROJECT_NAME_UPPER@_VERSION_INT @PROJECT_VERSION_INT@ - -#if defined (MYX_CMAKE_ORGANIZATION_NAME) -#error "Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME" -#else -#define MYX_CMAKE_ORGANIZATION_NAME "@MYX_CMAKE_ORGANIZATION_NAME@" -#endif - -#if defined (MYX_CMAKE_ORGANIZATION_NAME_LOWER) -#error "Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME_LOWER" -#else -#define MYX_CMAKE_ORGANIZATION_NAME_LOWER "@MYX_CMAKE_ORGANIZATION_NAME_LOWER@" -#endif - -#if defined (MYX_CMAKE_ORGANIZATION_NAME_UPPER) -#error "Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME_UPPER" -#else -#define MYX_CMAKE_ORGANIZATION_NAME_UPPER "@MYX_CMAKE_ORGANIZATION_NAME_UPPER@" -#endif - -#if defined (MYX_CMAKE_PROJECT_NAME) -#error "Duplicate definition of macros MYX_CMAKE_PROJECT_NAME" -#else -#define MYX_CMAKE_PROJECT_NAME "@CMAKE_PROJECT_NAME@" -#endif - -#if defined (MYX_CMAKE_PROJECT_NAME_LOWER) -#error "Duplicate definition of macros MYX_CMAKE_PROJECT_NAME_LOWER" -#else -#define MYX_CMAKE_PROJECT_NAME_LOWER "@MYX_CMAKE_PROJECT_NAME_LOWER@" -#endif - -#if defined (MYX_CMAKE_PROJECT_NAME_UPPER) -#error "Duplicate definition of macros MYX_CMAKE_PROJECT_NAME_UPPER" -#else -#define MYX_CMAKE_PROJECT_NAME_UPPER "@MYX_CMAKE_PROJECT_NAME_UPPER@" -#endif - -#if defined (MYX_CMAKE_THEME_NAME) -#error "Duplicate definition of macros MYX_CMAKE_THEME_NAME" -#else -#define MYX_CMAKE_THEME_NAME "@MYX_CMAKE_THEME_NAME@" -#endif - -#if defined (MYX_CMAKE_THEME_NAME_LOWER) -#error "Duplicate definition of macros MYX_CMAKE_THEME_NAME_LOWER" -#else -#define MYX_CMAKE_THEME_NAME_LOWER "@MYX_CMAKE_THEME_NAME_LOWER@" -#endif - -#if defined (MYX_CMAKE_THEME_NAME_UPPER) -#error "Duplicate definition of macros MYX_CMAKE_THEME_NAME_UPPER" -#else -#define MYX_CMAKE_THEME_NAME_UPPER "@MYX_CMAKE_THEME_NAME_UPPER@" -#endif - -#if defined (MYX_CMAKE_AUTHOR_NAME) -#error "Duplicate definition of macros MYX_CMAKE_AUTHOR_NAME" -#else -#define MYX_CMAKE_AUTHOR_NAME "@MYX_CMAKE_AUTHOR_NAME@" -#endif - -#if defined (MYX_CMAKE_AUTHOR_EMAIL) -#error "Duplicate definition of macros MYX_CMAKE_AUTHOR_EMAIL" -#else -#define MYX_CMAKE_AUTHOR_EMAIL "@MYX_CMAKE_AUTHOR_EMAIL@" -#endif - -#if defined (MYX_CMAKE_DESCRIPTION) -#error "Duplicate definition of macros MYX_CMAKE_DESCRIPTION" -#else -#define MYX_CMAKE_DESCRIPTION "@MYX_CMAKE_DESCRIPTION@" -#endif - -#if defined (MYX_CMAKE_BUILD_TYPE) -#error "Duplicate definition of macros MYX_CMAKE_BUILD_TYPE" -#else -#define MYX_CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@" -#endif - -#if defined (MYX_CMAKE_BUILD_DATE) -#error "Duplicate definition of macros MYX_CMAKE_BUILD_DATE" -#else -#define MYX_CMAKE_BUILD_DATE "@TODAY@" -#endif - -#endif /* @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_ */ - diff --git a/MyxCMake/functions/largefiles/TestFileOffsetBits.c b/MyxCMake/functions/largefiles/TestFileOffsetBits.c deleted file mode 100644 index cd679c1..0000000 --- a/MyxCMake/functions/largefiles/TestFileOffsetBits.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -/* Cause a compile-time error if off_t is smaller than 64 bits */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) -int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ]; - -int main(int argc, char **argv) -{ - return 0; -} - diff --git a/MyxCMake/functions/largefiles/TestLargeFiles.c.in b/MyxCMake/functions/largefiles/TestLargeFiles.c.in deleted file mode 100644 index 3c8baa0..0000000 --- a/MyxCMake/functions/largefiles/TestLargeFiles.c.in +++ /dev/null @@ -1,24 +0,0 @@ -#cmakedefine _LARGEFILE_SOURCE -#cmakedefine _LARGEFILE64_SOURCE -#cmakedefine _LARGE_FILES -#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@ - -#include -#include -#include - -int main(int argc, char **argv) -{ - /* Cause a compile-time error if off_t is smaller than 64 bits, - * and make sure we have ftello / fseeko. - */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ]; - FILE *fp = fopen(argv[0],"r"); - off_t offset = ftello( fp ); - - fseeko( fp, offset, SEEK_CUR ); - fclose(fp); - return off_t_is_large[0] || argc; -} - diff --git a/MyxCMake/functions/largefiles/TestWindowsFSeek.c b/MyxCMake/functions/largefiles/TestWindowsFSeek.c deleted file mode 100644 index ad9f0be..0000000 --- a/MyxCMake/functions/largefiles/TestWindowsFSeek.c +++ /dev/null @@ -1,11 +0,0 @@ - -#include - -int main() -{ - __int64 off=0; - - _fseeki64(NULL, off, SEEK_SET); - - return 0; -} diff --git a/MyxCMake/modules/MyxCMakeAddSharedLibrary.cmake b/MyxCMake/modules/MyxCMakeAddSharedLibrary.cmake index 58dbbcc..c3f0e5f 100644 --- a/MyxCMake/modules/MyxCMakeAddSharedLibrary.cmake +++ b/MyxCMake/modules/MyxCMakeAddSharedLibrary.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + # Создание динамической библиотеки из объектной библиотеки function(myx_cmake_add_shared_library target) myx_cmake_canonical_string(${target} _ctarget) diff --git a/MyxCMake/modules/MyxCMakeAddStaticLibrary.cmake b/MyxCMake/modules/MyxCMakeAddStaticLibrary.cmake index 95478f0..2ddca4d 100644 --- a/MyxCMake/modules/MyxCMakeAddStaticLibrary.cmake +++ b/MyxCMake/modules/MyxCMakeAddStaticLibrary.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + # Создание статической библиотеки из объектной библиотеки function(myx_cmake_add_static_library target) myx_cmake_canonical_string(${target} _ctarget) diff --git a/MyxCMake/modules/MyxCMakeBuildTypes.cmake b/MyxCMake/modules/MyxCMakeBuildTypes.cmake index 7191e18..a691ba2 100644 --- a/MyxCMake/modules/MyxCMakeBuildTypes.cmake +++ b/MyxCMake/modules/MyxCMakeBuildTypes.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # IN_LIST operator diff --git a/MyxCMake/modules/MyxCMakeCPack.cmake b/MyxCMake/modules/MyxCMakeCPack.cmake index dc9925c..a1248e6 100644 --- a/MyxCMake/modules/MyxCMakeCPack.cmake +++ b/MyxCMake/modules/MyxCMakeCPack.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + # Общие настройки для пакета: организация, автор, версия set(CPACK_PACKAGE_VENDOR ${MYX_CMAKE_ORGANIZATION_NAME_LOWER} CACHE STRING "") set(CPACK_PACKAGE_NAME ${MYX_CMAKE_PROJECT_NAME_LOWER} CACHE STRING "") diff --git a/MyxCMake/modules/MyxCMakeCodeAnalyzeApplyReplacements.cmake b/MyxCMake/modules/MyxCMakeCodeAnalyzeApplyReplacements.cmake index f07fd14..51d8ac4 100644 --- a/MyxCMake/modules/MyxCMakeCodeAnalyzeApplyReplacements.cmake +++ b/MyxCMake/modules/MyxCMakeCodeAnalyzeApplyReplacements.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + set(CLANG_APPLY_REPLACEMENTS_NAMES clang-apply-replacements) foreach(V RANGE 9 15) list(INSERT CLANG_APPLY_REPLACEMENTS_NAMES 0 "clang-apply-replacements-${V}") diff --git a/MyxCMake/modules/MyxCMakeCodeAnalyzeClangCheck.cmake b/MyxCMake/modules/MyxCMakeCodeAnalyzeClangCheck.cmake index 1006ef3..703b1c6 100644 --- a/MyxCMake/modules/MyxCMakeCodeAnalyzeClangCheck.cmake +++ b/MyxCMake/modules/MyxCMakeCodeAnalyzeClangCheck.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + set(CLANG_CHECK_NAMES clang-check) foreach(V RANGE 9 15) list(INSERT CLANG_CHECK_NAMES 0 "clang-check-${V}") diff --git a/MyxCMake/modules/MyxCMakeCodeAnalyzeClangTidy.cmake b/MyxCMake/modules/MyxCMakeCodeAnalyzeClangTidy.cmake index c1885fe..30a738c 100644 --- a/MyxCMake/modules/MyxCMakeCodeAnalyzeClangTidy.cmake +++ b/MyxCMake/modules/MyxCMakeCodeAnalyzeClangTidy.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + set(CLANG_TIDY_NAMES clang-tidy) foreach(V RANGE 9 15) list(INSERT CLANG_TIDY_NAMES 0 "clang-tidy-${V}") diff --git a/MyxCMake/modules/MyxCMakeCodeAnalyzeClazy.cmake b/MyxCMake/modules/MyxCMakeCodeAnalyzeClazy.cmake index 72f5d8f..f3dd550 100644 --- a/MyxCMake/modules/MyxCMakeCodeAnalyzeClazy.cmake +++ b/MyxCMake/modules/MyxCMakeCodeAnalyzeClazy.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + find_program(CLAZY_EXE NAMES clazy-standalone) if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE) diff --git a/MyxCMake/modules/MyxCMakeCodeAnalyzePvsStudio.cmake b/MyxCMake/modules/MyxCMakeCodeAnalyzePvsStudio.cmake index 963c689..ef5496f 100644 --- a/MyxCMake/modules/MyxCMakeCodeAnalyzePvsStudio.cmake +++ b/MyxCMake/modules/MyxCMakeCodeAnalyzePvsStudio.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + if(CMAKE_EXPORT_COMPILE_COMMANDS) include(PVS-Studio) find_program(PVS_STUDIO_ANALYZER_EXE pvs-studio-analyzer) diff --git a/MyxCMake/modules/MyxCMakeCodeCoverage.cmake b/MyxCMake/modules/MyxCMakeCodeCoverage.cmake index e9f1ae1..9143c51 100644 --- a/MyxCMake/modules/MyxCMakeCodeCoverage.cmake +++ b/MyxCMake/modules/MyxCMakeCodeCoverage.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + option(MYX_CMAKE_CODE_COVERAGE "MyxCMake: enable code coverage" OFF) if(MYX_CMAKE_CODE_COVERAGE) diff --git a/MyxCMake/modules/MyxCMakeColoredMessages.cmake b/MyxCMake/modules/MyxCMakeColoredMessages.cmake index 248877b..fc79042 100644 --- a/MyxCMake/modules/MyxCMakeColoredMessages.cmake +++ b/MyxCMake/modules/MyxCMakeColoredMessages.cmake @@ -1,3 +1,7 @@ +# Обёртки для функций вывода сообщений + +include_guard(GLOBAL) + if(DEFINED ENV{TERM} AND UNIX) string(ASCII 27 Esc) set(MyxCMakeColorReset "${Esc}[m") diff --git a/MyxCMake/modules/MyxCMakeCommon.cmake b/MyxCMake/modules/MyxCMakeCommon.cmake index 00d6120..b7d6c1c 100644 --- a/MyxCMake/modules/MyxCMakeCommon.cmake +++ b/MyxCMake/modules/MyxCMakeCommon.cmake @@ -1,20 +1,26 @@ -cmake_minimum_required(VERSION 3.3 FATAL_ERROR) +cmake_minimum_required(VERSION 3.6 FATAL_ERROR) -include(GNUInstallDirs) +include(MyxCMakeCompatIncludeGuard) +include(MyxCMakeLSBInfo) +include(MyxCMakeCompat) + +# Additional functions +include(MyxCMakeHighPrecisionMath) +include(MyxCMakeQtTranslation) +include(MyxCMakeRemoveFlag) +include(MyxCMakeWriteCompilerDetectionHeader) + +include(MyxCMakeIncludeSystemModules) +include(MyxCMakeCurrentDate) include(MyxCMakeColoredMessages) -include(MyxCMakeCheckPaths) - -link_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) -set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS};tpp;tcc) -set_property(GLOBAL PROPERTY USE_FOLDERS ON) - +include(MyxCMakeDirectoriesGuards) +include(MyxCMakeGlobalFunctions) include(MyxCMakeProjectVersion) include(MyxCMakeRequiredVariables) -include(MyxCMakeGlobalFunctions) include(MyxCMakeGlobalVariables) -include(MyxCMakeDates) -include(MyxCMakeLSBInfo) -include(MyxCMakePaths) +include(MyxCMakeLargeFiles) +include(MyxCMakeGeneratePrivateConfigHeader) +include(MyxCMakeGenerateGitInfoHeader) include(MyxCMakeCompiler) include(MyxCMakeCompilerFlags) include(MyxCMakeDistCC) @@ -28,8 +34,10 @@ include(MyxCMakeCodeAnalyzeClangCheck) include(MyxCMakeCodeAnalyzeClangTidy) include(MyxCMakeCodeAnalyzeClazy) include(MyxCMakeCodeAnalyzePvsStudio) + include(MyxCMakeCodeCoverage) include(MyxCMakeFormatSources) +include(MyxCMakeCommonPaths) include(MyxCMakeCommonTargetProperties) include(MyxCMakeAddSharedLibrary) include(MyxCMakeAddStaticLibrary) @@ -40,13 +48,3 @@ include(MyxCMakeDocBreathe) include(MyxCMakeExternalProject) include(MyxCMakeCPack) include(MyxCMakeUninstall) - -# Additional functions -include(MyxCMakeGenerateGitInfoHeader) -include(MyxCMakeGeneratePrivateConfigHeader) -include(MyxCMakeHighPrecisionMath) -include(MyxCMakeLargeFiles) -include(MyxCMakeQtTranslation) -include(MyxCMakeRemoveFlag) -include(MyxCMakeWriteCompilerDetectionHeader) - diff --git a/MyxCMake/modules/MyxCMakeCommonPaths.cmake b/MyxCMake/modules/MyxCMakeCommonPaths.cmake new file mode 100644 index 0000000..1b54e35 --- /dev/null +++ b/MyxCMake/modules/MyxCMakeCommonPaths.cmake @@ -0,0 +1,4 @@ +include_guard(GLOBAL) + + +link_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) diff --git a/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake b/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake index 2e561f1..4c16ab9 100644 --- a/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake +++ b/MyxCMake/modules/MyxCMakeCommonTargetProperties.cmake @@ -1,9 +1,14 @@ +include_guard(GLOBAL) + + function(myx_cmake_common_target_properties target) if(NOT TARGET ${target}) myx_cmake_message_error("MyxCMake: Target ${target} does not exists.") endif() get_target_property(_target_type ${target} TYPE) + set_target_properties(${target} PROPERTIES USE_FOLDERS ON) + set(__visibility PUBLIC) if(_target_type STREQUAL INTERFACE_LIBRARY) set(__visibility INTERFACE) diff --git a/MyxCMake/modules/MyxCMakePaths.cmake b/MyxCMake/modules/MyxCMakeCompat.cmake similarity index 84% rename from MyxCMake/modules/MyxCMakePaths.cmake rename to MyxCMake/modules/MyxCMakeCompat.cmake index 33419a0..bc2722b 100644 --- a/MyxCMake/modules/MyxCMakePaths.cmake +++ b/MyxCMake/modules/MyxCMakeCompat.cmake @@ -1,5 +1,5 @@ if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" OR - MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxCE") + MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxCE") set(CMAKE_37_MODULES_DIR "/usr/share/cmake-3.7/Modules") if(IS_DIRECTORY ${CMAKE_37_MODULES_DIR}) if(NOT ${CMAKE_37_MODULES_DIR} IN_LIST CMAKE_MODULE_PATH) diff --git a/MyxCMake/modules/MyxCMakeCompatIncludeGuard.cmake b/MyxCMake/modules/MyxCMakeCompatIncludeGuard.cmake new file mode 100644 index 0000000..037aad6 --- /dev/null +++ b/MyxCMake/modules/MyxCMakeCompatIncludeGuard.cmake @@ -0,0 +1,13 @@ +# Защита для однократного включения файла *.cmake +# Функция include_guard() реализована в версии 3.10 +# Макрос реализован для обратной совместимости + +if(${CMAKE_VERSION} VERSION_LESS "3.10.0") + macro(include_guard) + if (MYX_CMAKE_INCLUDED_${CMAKE_CURRENT_LIST_FILE}) + return() + endif() + set(MYX_CMAKE_INCLUDED_${CMAKE_CURRENT_LIST_FILE} TRUE) + endmacro() +endif() + diff --git a/MyxCMake/modules/MyxCMakeCompiler.cmake b/MyxCMake/modules/MyxCMakeCompiler.cmake index a0171d1..c2c79c1 100644 --- a/MyxCMake/modules/MyxCMakeCompiler.cmake +++ b/MyxCMake/modules/MyxCMakeCompiler.cmake @@ -1,3 +1,5 @@ +include_guard(GLOBAL) + # C compiler name if(CMAKE_C_COMPILER_ID STREQUAL "Intel") set(CMAKE_C_COMPILER_IS_INTEL ON) @@ -24,26 +26,25 @@ endif() # Предпочтительные пути к утилитам для компоновки if(CMAKE_CXX_COMPILER_IS_GCC) +# cmake-format: off # Astra Linux Smolensk 1.5 - if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND - MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk" AND - MYX_CMAKE_LSB_RELEASE STREQUAL "1.5") + if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND + MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk" AND + MYX_CMAKE_LSB_RELEASE_VERSION STREQUAL "1.5") find_program(CMAKE_GCC_AR NAMES "/usr/bin/x86_64-linux-gnu-gcc-ar-4.7") find_program(CMAKE_GCC_NM NAMES "/usr/bin/x86_64-linux-gnu-gcc-nm-4.7") find_program(CMAKE_GCC_RANLIB NAMES "/usr/bin/x86_64-linux-gnu-gcc-ranlib-4.7") # Elbrus E2K elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k") - find_program(CMAKE_GCC_AR - NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ar") - find_program(CMAKE_GCC_NM - NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/nm") - find_program(CMAKE_GCC_RANLIB - NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ranlib") + find_program(CMAKE_GCC_AR NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ar") + find_program(CMAKE_GCC_NM NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/nm") + find_program(CMAKE_GCC_RANLIB NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ranlib") else() find_program(CMAKE_GCC_AR NAMES "gcc-ar" "ar") find_program(CMAKE_GCC_NM NAMES "gcc-nm" "nm") find_program(CMAKE_GCC_RANLIB NAMES "gcc-ranlib" "ranlib") endif() +# cmake-format: on if(CMAKE_GCC_AR) set(CMAKE_AR ${CMAKE_GCC_AR} CACHE STRING "" FORCE) diff --git a/MyxCMake/modules/MyxCMakeCompilerFlags.cmake b/MyxCMake/modules/MyxCMakeCompilerFlags.cmake index 6e4459d..73f714a 100644 --- a/MyxCMake/modules/MyxCMakeCompilerFlags.cmake +++ b/MyxCMake/modules/MyxCMakeCompilerFlags.cmake @@ -1,3 +1,5 @@ +include_guard(GLOBAL) + # based on https://github.com/bluescarni/yacma include(CheckCXXCompilerFlag) @@ -7,13 +9,14 @@ macro(CHECK_ENABLE_CXX_FLAG flag) check_cxx_compiler_flag("${flag}" CHECK_CXX_FLAG) unset(CMAKE_REQUIRED_QUIET) +# cmake-format: off if(CHECK_CXX_FLAG) myx_cmake_message_notice("'${flag}': flag is supported.") - string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS - "${_MYX_CMAKE_DETECTED_CXX_FLAGS} ${flag}") + string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS "${_MYX_CMAKE_DETECTED_CXX_FLAGS} ${flag}") else() myx_cmake_message_status("'${flag}': flag is NOT supported.") endif() +# cmake-format: on # NOTE: check_cxx_compiler stores variables in the cache. unset(CHECK_CXX_FLAG CACHE) endmacro() @@ -24,40 +27,32 @@ macro(CHECK_ENABLE_DEBUG_CXX_FLAG flag) check_cxx_compiler_flag("${flag}" CHECK_CXX_FLAG_DEBUG) unset(CMAKE_REQUIRED_QUIET) +# cmake-format: off if(CHECK_CXX_FLAG_DEBUG) myx_cmake_message_notice("'${flag}': debug flag is supported.") - string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG - "${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG} ${flag}") + string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG "${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG} ${flag}") else() myx_cmake_message_status("'${flag}': debug flag is NOT supported.") endif() +# cmake-format: on # NOTE: check_cxx_compiler stores variables in the cache. unset(CHECK_CXX_FLAG_DEBUG CACHE) endif() endmacro() function(myx_cmake_set_cxx_standard version) +# cmake-format: off # Выбор стандарта по умолчанию (можно переопределить в проекте) - set(CMAKE_CXX_STANDARD_REQUIRED - YES - PARENT_SCOPE) + set(CMAKE_CXX_STANDARD_REQUIRED YES PARENT_SCOPE) if(version EQUAL 11) - set(CMAKE_CXX_STANDARD - 11 - PARENT_SCOPE) - set(CMAKE_CXX_EXTENSIONS - YES - PARENT_SCOPE) + set(CMAKE_CXX_STANDARD 11 PARENT_SCOPE) + set(CMAKE_CXX_EXTENSIONS YES PARENT_SCOPE) endif() if(version EQUAL 14) - set(CMAKE_CXX_STANDARD - 14 - PARENT_SCOPE) - set(CMAKE_CXX_EXTENSIONS - YES - PARENT_SCOPE) + set(CMAKE_CXX_STANDARD 14 PARENT_SCOPE) + set(CMAKE_CXX_EXTENSIONS YES PARENT_SCOPE) endif() if(version EQUAL 17) @@ -82,14 +77,11 @@ function(myx_cmake_set_cxx_standard version) endif() endif() else() - set(CMAKE_CXX_STANDARD - 17 - PARENT_SCOPE) - set(CMAKE_CXX_EXTENSIONS - YES - PARENT_SCOPE) + set(CMAKE_CXX_STANDARD 17 PARENT_SCOPE) + set(CMAKE_CXX_EXTENSIONS YES PARENT_SCOPE) endif() endif() +# cmake-format: on endfunction() if(NOT MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE) @@ -210,9 +202,9 @@ if(NOT MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE) endif() # cmake-format: off - if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND - MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk" AND - MYX_CMAKE_LSB_RELEASE STREQUAL "1.5") + if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND + MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk" AND + MYX_CMAKE_LSB_RELEASE_VERSION STREQUAL "1.5") # cmake-format: on myx_cmake_set_cxx_standard(11) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k") @@ -227,14 +219,10 @@ if(NOT MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE) endif() endif() +# cmake-format: off # Set the cache variables. - set(MYX_CMAKE_DETECTED_CXX_FLAGS - "${_MYX_CMAKE_DETECTED_CXX_FLAGS}" - CACHE INTERNAL "") - set(MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG - "${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG}" - CACHE INTERNAL "") - set(MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE - YES - CACHE INTERNAL "") + set(MYX_CMAKE_DETECTED_CXX_FLAGS "${_MYX_CMAKE_DETECTED_CXX_FLAGS}" CACHE INTERNAL "") + set(MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG "${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG}" CACHE INTERNAL "") + set(MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE YES CACHE INTERNAL "") +# cmake-format: on endif() diff --git a/MyxCMake/modules/MyxCMakeDates.cmake b/MyxCMake/modules/MyxCMakeCurrentDate.cmake similarity index 96% rename from MyxCMake/modules/MyxCMakeDates.cmake rename to MyxCMake/modules/MyxCMakeCurrentDate.cmake index c086c43..4fab21b 100644 --- a/MyxCMake/modules/MyxCMakeDates.cmake +++ b/MyxCMake/modules/MyxCMakeCurrentDate.cmake @@ -1,3 +1,5 @@ +include_guard(GLOBAL) + if(NOT MYX_CMAKE_TODAY) if(WIN32) execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_CMAKE_TODAY) @@ -15,4 +17,3 @@ if(NOT MYX_CMAKE_YEAR) endif() string(REGEX REPLACE "(..)/(..)/(....).*" "\\3" MYX_CMAKE_YEAR ${MYX_CMAKE_YEAR}) endif() - diff --git a/MyxCMake/modules/MyxCMakeDebugOutputOptions.cmake b/MyxCMake/modules/MyxCMakeDebugOutputOptions.cmake index 675c92d..4f57b20 100644 --- a/MyxCMake/modules/MyxCMakeDebugOutputOptions.cmake +++ b/MyxCMake/modules/MyxCMakeDebugOutputOptions.cmake @@ -1,10 +1,13 @@ +include_guard(GLOBAL) + + # По умолчанию отключена отладочная печать (если не включена явно программистом) option(MYX_CMAKE_DEBUG_OUTPUT "Enable debug output" OFF) option(MYX_CMAKE_INFO_OUTPUT "Enable info output" OFF) option(MYX_CMAKE_WARNING_OUTPUT "Enable warning output" OFF) -# Если сборка производится в режиме для отладки, то включаются флаги для -# разрешения отладочной печати +# Если сборка производится в режиме для отладки, +# то включаются флаги для разрешения отладочной печати if(CMAKE_BUILD_TYPE STREQUAL Debug) set(MYX_CMAKE_DEBUG_OUTPUT ON CACHE BOOL "" FORCE) set(MYX_CMAKE_INFO_OUTPUT ON CACHE BOOL "" FORCE) diff --git a/MyxCMake/modules/MyxCMakeCheckPaths.cmake b/MyxCMake/modules/MyxCMakeDirectoriesGuards.cmake similarity index 54% rename from MyxCMake/modules/MyxCMakeCheckPaths.cmake rename to MyxCMake/modules/MyxCMakeDirectoriesGuards.cmake index e176fe0..f12acb2 100644 --- a/MyxCMake/modules/MyxCMakeCheckPaths.cmake +++ b/MyxCMake/modules/MyxCMakeDirectoriesGuards.cmake @@ -1,9 +1,10 @@ -# Запись результатов сборки проекта внутрь иерархии каталогов с исходными -# текстами приводит к засорению файлами формируемыми на этапе сборки, которые -# затрудняют разработку, поиск в оригинальных файлах и мешают ориентироваться в -# проекте. При работе с несколькими типами сборки, например, отладка и выпуск, -# появляется необходимость корректного полного удаления результатов предыдущего -# варианта. +# Запись результатов сборки проекта внутрь иерархии каталогов с исходными текстами +# приводит к засорению файлами формируемыми на этапе сборки, которые затрудняют +# разработку, поиск в оригинальных файлах и мешают ориентироваться в проекте. +# При работе с несколькими типами сборки, например, отладка и выпуск, появляется +# необходимость корректного полного удаления результатов предыдущего варианта. + +include_guard(GLOBAL) get_filename_component(_source_realpath "${CMAKE_SOURCE_DIR}" REALPATH) get_filename_component(_binary_realpath "${CMAKE_BINARY_DIR}" REALPATH) diff --git a/MyxCMake/modules/MyxCMakeDistCC.cmake b/MyxCMake/modules/MyxCMakeDistCC.cmake index f7879fb..1f973ee 100644 --- a/MyxCMake/modules/MyxCMakeDistCC.cmake +++ b/MyxCMake/modules/MyxCMakeDistCC.cmake @@ -1,3 +1,5 @@ +include_guard(GLOBAL) + find_program(DISTCC_EXECUTABLE distcc) mark_as_advanced(DISTCC_EXECUTABLE) if(DISTCC_EXECUTABLE) diff --git a/MyxCMake/functions/MyxCMakeDocBreathe.cmake b/MyxCMake/modules/MyxCMakeDocBreathe.cmake similarity index 99% rename from MyxCMake/functions/MyxCMakeDocBreathe.cmake rename to MyxCMake/modules/MyxCMakeDocBreathe.cmake index 3aa8db1..8fdefd7 100644 --- a/MyxCMake/functions/MyxCMakeDocBreathe.cmake +++ b/MyxCMake/modules/MyxCMakeDocBreathe.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + function(myx_cmake_doc_breathe) set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator") set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO) diff --git a/MyxCMake/functions/MyxCMakeDocDoxygen.cmake b/MyxCMake/modules/MyxCMakeDocDoxygen.cmake similarity index 54% rename from MyxCMake/functions/MyxCMakeDocDoxygen.cmake rename to MyxCMake/modules/MyxCMakeDocDoxygen.cmake index a59b4d4..4fa8fac 100644 --- a/MyxCMake/functions/MyxCMakeDocDoxygen.cmake +++ b/MyxCMake/modules/MyxCMakeDocDoxygen.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + function(myx_cmake_doc_doxygen) set(DOXYGEN_FOUND AUTO CACHE STRING "Enable Doxygen documentation generator") set_property(CACHE DOXYGEN_FOUND PROPERTY STRINGS ON OFF AUTO) @@ -18,30 +21,67 @@ function(myx_cmake_doc_doxygen) if(NOT TARGET ${_target}) set(options) - set(oneValueArgs SQLITE LATEX HTML) + set(oneValueArgs SQLITE LATEX HTML LANGUAGE) set(multiValueArgs) cmake_parse_arguments(_arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(GENERATE_XML YES) set(GENERATE_HTML NO) set(GENERATE_LATEX NO) + set(DOXYGEN_OUTPUT_LANGUAGE Russian) if(_arg_HTML) set(GENERATE_HTML YES) endif() if(_arg_LATEX) set(GENERATE_LATEX YES) endif() - if(_arg_SQLITE) - set(GENERATE_SQLITE YES) + if(_arg_LANGUAGE) + set(DOXYGEN_OUTPUT_LANGUAGE ${_arg_LANGUAGE}) endif() + set(_myx_cmake_doxygen_in +" +PROJECT_NAME = \"${DOXYGEN_PROJECT_TITLE}\" +OUTPUT_DIRECTORY = \"${DOXYGEN_OUTPUT_DIRECTORY}\" +OUTPUT_LANGUAGE = \"${DOXYGEN_OUTPUT_LANGUAGE}\" +STRIP_FROM_PATH = \"${CMAKE_HOME_DIRECTORY}/src}\" +STRIP_FROM_INC_PATH = \"${CMAKE_HOME_DIRECTORY}/src}\" + +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_METHODS = YES + +INPUT = \"${CMAKE_HOME_DIRECTORY}/src\" \"${CMAKE_HOME_DIRECTORY}/doc/doxygen\" +RECURSIVE = YES + +CLANG_ASSISTED_PARSING = YES +CLANG_DATABASE_PATH = \"${CMAKE_BINARY_DIR}\" + +GENERATE_HTML = ${GENERATE_HTML} +GENERATE_TREEVIEW = YES + +GENERATE_LATEX = ${GENERATE_LATEX} +LATEX_CMD_NAME = xelatex +COMPACT_LATEX = YES + +GENERATE_XML = YES + +UML_LOOK = YES +TEMPLATE_RELATIONS = YES +CALL_GRAPH = YES +CALLER_GRAPH = YES +INTERACTIVE_SVG = YES +") + + set(_myx_cmake_doxygen_in_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Doxygen.in) + file(WRITE ${_myx_cmake_doxygen_in_path} ${_myx_cmake_doxygen_in}) set(work_dir ${CMAKE_BINARY_DIR}/doc/doxygen) - configure_file(${MYX_CMAKE_FUNCTIONS_DIR}/doc/Doxyfile.in ${work_dir}/Doxyfile @ONLY) + configure_file(${_myx_cmake_doxygen_in_path} ${work_dir}/Doxyfile @ONLY) add_custom_target(${_target} VERBATIM WORKING_DIRECTORY ${work_dir} - COMMAND "${CMAKE_COMMAND}" -E remove -f "${work_dir}/doxygen_sqlite3.db" COMMAND ${DOXYGEN_EXECUTABLE} ${work_dir}/Doxyfile COMMENT "Generating API documentation with Doxygen") if(_arg_HTML) diff --git a/MyxCMake/modules/MyxCMakeExternalProject.cmake b/MyxCMake/modules/MyxCMakeExternalProject.cmake index aa6dc07..388b4d6 100644 --- a/MyxCMake/modules/MyxCMakeExternalProject.cmake +++ b/MyxCMake/modules/MyxCMakeExternalProject.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + include(ExternalProject) if(CMAKE_BUILD_TYPE) diff --git a/MyxCMake/modules/MyxCMakeFormatSources.cmake b/MyxCMake/modules/MyxCMakeFormatSources.cmake index a5a6165..ea94a1f 100644 --- a/MyxCMake/modules/MyxCMakeFormatSources.cmake +++ b/MyxCMake/modules/MyxCMakeFormatSources.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + find_program(UNCRUSTIFY_EXE NAMES uncrustify) if(UNCRUSTIFY_EXE) diff --git a/MyxCMake/modules/MyxCMakeGenerateGitInfoHeader.cmake b/MyxCMake/modules/MyxCMakeGenerateGitInfoHeader.cmake new file mode 100644 index 0000000..9b2a69d --- /dev/null +++ b/MyxCMake/modules/MyxCMakeGenerateGitInfoHeader.cmake @@ -0,0 +1,85 @@ +include_guard(GLOBAL) + + +function(myx_cmake_generate_git_info_header) + set(_filename ${CMAKE_BINARY_DIR}/${CMAKE_INCLUDE_DIR}/${MYX_CMAKE_PROJECT_NAME_LOWER}/myx_cmake_git_info_p.hpp) + if(MYX_CMAKE_GENERATED_HEADERS_PATH) + set(_filename ${MYX_CMAKE_GENERATED_HEADERS_PATH}/${MYX_CMAKE_PROJECT_NAME_LOWER}/myx_cmake_git_info_p.hpp) + elseif(ARGV0) + set(_filename ${ARGV0}) + endif() + + set(_git_info_hpp_in +"#ifndef @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_GIT_INFO_HPP_ +#define @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_GIT_INFO_HPP_ + +#pragma once + +#if defined (@MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_REV) +#error \"Duplicate definition of macros @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_REV\" +#else +#define @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_REV \"@MYX_CMAKE_GIT_REV@\" +#endif + +#if defined (@MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_DIFF) +#error \"Duplicate definition of macros @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_DIFF\" +#else +#define @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_DIFF \"@MYX_CMAKE_GIT_DIFF@\" +#endif + +#if defined (@MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_BRANCH) +#error \"Duplicate definition of macros @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_BRANCH\" +#else +#define @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_BRANCH \"@MYX_CMAKE_GIT_BRANCH@\" +#endif + +#if defined (@MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_TAG) +#error \"Duplicate definition of macros @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_TAG\" +#else +#define @MYX_CMAKE_PROJECT_NAME_UPPER@_GIT_TAG \"@MYX_CMAKE_GIT_TAG@\" +#endif + +#endif /* @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_GIT_INFO_HPP_ */ +") + set(_git_info_hpp_in_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/myx_cmake_git_info_p.hpp.in) + file(WRITE ${_git_info_hpp_in_path} ${_git_info_hpp_in}) + + set(_git_info_cmake_in +"set(MYX_CMAKE_GIT_REV \"N/A\") +set(MYX_CMAKE_GIT_DIFF \"\") +set(MYX_CMAKE_GIT_TAG \"N/A\") +set(MYX_CMAKE_GIT_BRANCH \"N/A\") + +find_program(GIT_EXECUTABLE git) +if(GIT_EXECUTABLE) + execute_process(COMMAND git log --pretty=format:'%h' -n 1 OUTPUT_VARIABLE MYX_CMAKE_GIT_REV ERROR_QUIET) + + # Check whether we got any revision (which isn't always the case, + # e.g. when someone downloaded a zip file from Github instead of a checkout) + if(NOT ${MYX_CMAKE_GIT_REV} STREQUAL \"\") + execute_process(COMMAND bash -c \"git diff --quiet --exit-code || echo +\" OUTPUT_VARIABLE MYX_CMAKE_GIT_DIFF) + execute_process(COMMAND git describe --exact-match --tags OUTPUT_VARIABLE MYX_CMAKE_GIT_TAG ERROR_QUIET) + execute_process(COMMAND git rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE MYX_CMAKE_GIT_BRANCH) + + string(STRIP \"${MYX_CMAKE_GIT_REV}\" MYX_CMAKE_GIT_REV) + string(SUBSTRING \"${MYX_CMAKE_GIT_REV}\" 1 7 MYX_CMAKE_GIT_REV) + string(STRIP \"${MYX_CMAKE_GIT_DIFF}\" MYX_CMAKE_GIT_DIFF) + string(STRIP \"${MYX_CMAKE_GIT_TAG}\" MYX_CMAKE_GIT_TAG) + string(STRIP \"${MYX_CMAKE_GIT_BRANCH}\" MYX_CMAKE_GIT_BRANCH) + endif() +endif() + +configure_file(${_git_info_hpp_in_path} ${MYX_CMAKE_GIT_INFO_FILE}) +") + set(_git_info_cmake_in_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/MyxCMakeGitInfo.cmake.in) + file(WRITE ${_git_info_cmake_in_path} ${_git_info_cmake_in}) + +# cmake-format: off + if(NOT TARGET myx-cmake-git-info-header-${MYX_CMAKE_PROJECT_NAME_LOWER}) + add_custom_target(myx-cmake-git-info-header-${MYX_CMAKE_PROJECT_NAME_LOWER} ALL + ${CMAKE_COMMAND} -DMYX_CMAKE_PROJECT_NAME_UPPER=${MYX_CMAKE_PROJECT_NAME_UPPER} + -DMYX_CMAKE_GIT_INFO_FILE=${_filename} -P ${_git_info_cmake_in_path} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + endif() +# cmake-format: on +endfunction() diff --git a/MyxCMake/modules/MyxCMakeGeneratePrivateConfigHeader.cmake b/MyxCMake/modules/MyxCMakeGeneratePrivateConfigHeader.cmake new file mode 100644 index 0000000..ef68a30 --- /dev/null +++ b/MyxCMake/modules/MyxCMakeGeneratePrivateConfigHeader.cmake @@ -0,0 +1,116 @@ +include_guard(GLOBAL) + + +function(myx_cmake_generate_private_config_header) + include(MyxCMakeLargeFiles) + myx_cmake_test_large_files(HAVE_LARGEFILES) + + set(_filename ${CMAKE_BINARY_DIR}/${CMAKE_INCLUDE_DIR}/${MYX_CMAKE_PROJECT_NAME_LOWER}/myx_cmake_private_config_p.hpp) + if(MYX_CMAKE_GENERATED_HEADERS_PATH) + set(_filename ${MYX_CMAKE_GENERATED_HEADERS_PATH}/${MYX_CMAKE_PROJECT_NAME_LOWER}/myx_cmake_private_config_p.hpp) + elseif(ARGV0) + set(_filename ${ARGV0}) + endif() + + get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT) + + set(_myx_cmake_private_config_hpp_in +"#ifndef @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_ +#define @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_ + +#pragma once + +#define @MYX_CMAKE_PROJECT_NAME_UPPER@_VERSION_STR \"@PROJECT_VERSION@\" +#define @MYX_CMAKE_PROJECT_NAME_UPPER@_VERSION_INT @PROJECT_VERSION_INT@ + +#if defined (MYX_CMAKE_ORGANIZATION_NAME) +#error \"Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME\" +#else +#define MYX_CMAKE_ORGANIZATION_NAME \"@MYX_CMAKE_ORGANIZATION_NAME@\" +#endif + +#if defined (MYX_CMAKE_ORGANIZATION_NAME_LOWER) +#error \"Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME_LOWER\" +#else +#define MYX_CMAKE_ORGANIZATION_NAME_LOWER \"@MYX_CMAKE_ORGANIZATION_NAME_LOWER@\" +#endif + +#if defined (MYX_CMAKE_ORGANIZATION_NAME_UPPER) +#error \"Duplicate definition of macros MYX_CMAKE_ORGANIZATION_NAME_UPPER\" +#else +#define MYX_CMAKE_ORGANIZATION_NAME_UPPER \"@MYX_CMAKE_ORGANIZATION_NAME_UPPER@\" +#endif + +#if defined (MYX_CMAKE_PROJECT_NAME) +#error \"Duplicate definition of macros MYX_CMAKE_PROJECT_NAME\" +#else +#define MYX_CMAKE_PROJECT_NAME \"@CMAKE_PROJECT_NAME@\" +#endif + +#if defined (MYX_CMAKE_PROJECT_NAME_LOWER) +#error \"Duplicate definition of macros MYX_CMAKE_PROJECT_NAME_LOWER\" +#else +#define MYX_CMAKE_PROJECT_NAME_LOWER \"@MYX_CMAKE_PROJECT_NAME_LOWER@\" +#endif + +#if defined (MYX_CMAKE_PROJECT_NAME_UPPER) +#error \"Duplicate definition of macros MYX_CMAKE_PROJECT_NAME_UPPER\" +#else +#define MYX_CMAKE_PROJECT_NAME_UPPER \"@MYX_CMAKE_PROJECT_NAME_UPPER@\" +#endif + +#if defined (MYX_CMAKE_THEME_NAME) +#error \"Duplicate definition of macros MYX_CMAKE_THEME_NAME\" +#else +#define MYX_CMAKE_THEME_NAME \"@MYX_CMAKE_THEME_NAME@\" +#endif + +#if defined (MYX_CMAKE_THEME_NAME_LOWER) +#error \"Duplicate definition of macros MYX_CMAKE_THEME_NAME_LOWER\" +#else +#define MYX_CMAKE_THEME_NAME_LOWER \"@MYX_CMAKE_THEME_NAME_LOWER@\" +#endif + +#if defined (MYX_CMAKE_THEME_NAME_UPPER) +#error \"Duplicate definition of macros MYX_CMAKE_THEME_NAME_UPPER\" +#else +#define MYX_CMAKE_THEME_NAME_UPPER \"@MYX_CMAKE_THEME_NAME_UPPER@\" +#endif + +#if defined (MYX_CMAKE_AUTHOR_NAME) +#error \"Duplicate definition of macros MYX_CMAKE_AUTHOR_NAME\" +#else +#define MYX_CMAKE_AUTHOR_NAME \"@MYX_CMAKE_AUTHOR_NAME@\" +#endif + +#if defined (MYX_CMAKE_AUTHOR_EMAIL) +#error \"Duplicate definition of macros MYX_CMAKE_AUTHOR_EMAIL\" +#else +#define MYX_CMAKE_AUTHOR_EMAIL \"@MYX_CMAKE_AUTHOR_EMAIL@\" +#endif + +#if defined (MYX_CMAKE_DESCRIPTION) +#error \"Duplicate definition of macros MYX_CMAKE_DESCRIPTION\" +#else +#define MYX_CMAKE_DESCRIPTION \"@MYX_CMAKE_DESCRIPTION@\" +#endif + +#if defined (MYX_CMAKE_BUILD_TYPE) +#error \"Duplicate definition of macros MYX_CMAKE_BUILD_TYPE\" +#else +#define MYX_CMAKE_BUILD_TYPE \"@CMAKE_BUILD_TYPE@\" +#endif + +#if defined (MYX_CMAKE_BUILD_DATE) +#error \"Duplicate definition of macros MYX_CMAKE_BUILD_DATE\" +#else +#define MYX_CMAKE_BUILD_DATE \"@TODAY@\" +#endif + +#endif /* @MYX_CMAKE_PROJECT_NAME_UPPER@_MYX_CMAKE_CONFIG_HPP_ */ +") +set(_myx_cmake_private_config_hpp_in_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/myx_cmake_private_config_p.hpp) +file(WRITE ${_myx_cmake_private_config_hpp_in_path} ${_myx_cmake_private_config_hpp_in}) + + configure_file(${_myx_cmake_private_config_hpp_in_path} ${_filename}) +endfunction() diff --git a/MyxCMake/modules/MyxCMakeGlobalFunctions.cmake b/MyxCMake/modules/MyxCMakeGlobalFunctions.cmake index 7bf8611..ae867ca 100644 --- a/MyxCMake/modules/MyxCMakeGlobalFunctions.cmake +++ b/MyxCMake/modules/MyxCMakeGlobalFunctions.cmake @@ -1,15 +1,17 @@ +include_guard(GLOBAL) + # Формирование строки, состоящей из заглавных символов, цифр и подчёркиваний function(myx_cmake_canonical_string in_string out_string) - string(TOUPPER ${in_string} _arg_uppercase) - string(REGEX REPLACE "[ -]" "_" _arg_fixed ${_arg_uppercase}) - set(${out_string} ${_arg_fixed} PARENT_SCOPE) + string(TOUPPER ${in_string} _uppercase) + string(REGEX REPLACE "[ -]" "_" _fixed ${_uppercase}) + set(${out_string} ${_fixed} PARENT_SCOPE) endfunction() # Добавление общего префикса ко всем переменным в списке -function(myx_cmake_list_transform_prepend var prefix) - set(temp "") - foreach(filename ${${var}}) - list(APPEND temp "${prefix}${filename}") +function(myx_cmake_list_transform_prepend values prefix) + set(_list "") + foreach(_val ${${values}}) + list(APPEND _list "${prefix}${_val}") endforeach() - set(${var} ${temp} PARENT_SCOPE) + set(${values} ${_list} PARENT_SCOPE) endfunction() diff --git a/MyxCMake/modules/MyxCMakeGlobalVariables.cmake b/MyxCMake/modules/MyxCMakeGlobalVariables.cmake index c7adaf0..fba00ae 100644 --- a/MyxCMake/modules/MyxCMakeGlobalVariables.cmake +++ b/MyxCMake/modules/MyxCMakeGlobalVariables.cmake @@ -1,5 +1,7 @@ +include_guard(GLOBAL) + if(NOT MYX_CMAKE_THEME_NAME) - set(MYX_CMAKE_THEME_NAME "default") + set(MYX_CMAKE_THEME_NAME "default" CACHE STRING "") endif() # cmake-format: off @@ -15,10 +17,10 @@ string(TOUPPER ${MYX_CMAKE_ORGANIZATION_NAME_CANONICAL} MYX_CMAKE_ORGANIZATION_N string(TOUPPER ${MYX_CMAKE_PROJECT_NAME_CANONICAL} MYX_CMAKE_PROJECT_NAME_UPPER) string(TOUPPER ${MYX_CMAKE_THEME_NAME_CANONICAL} MYX_CMAKE_THEME_NAME_UPPER) -option(MYX_CMAKE_ADD_THEME_PREFIX "Append theme name to install prefix" OFF) -if(MYX_CMAKE_ADD_THEME_PREFIX AND NOT MYX_CMAKE_THEME_PREFIX_APPENDED) +option(MYX_CMAKE_ADD_THEME_TO_INSTALL_PREFIX "Append theme name to install prefix" OFF) +if(MYX_CMAKE_ADD_THEME_TO_INSTALL_PREFIX AND NOT MYX_CMAKE_THEME_INSTALL_PREFIX_APPENDED) if(NOT MYX_CMAKE_THEME_NAME_LOWER STREQUAL "default") - set(MYX_CMAKE_THEME_PREFIX_APPENDED ON CACHE BOOL "" FORCE) + set(MYX_CMAKE_THEME_INSTALL_PREFIX_APPENDED ON CACHE BOOL "" FORCE) set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${MYX_CMAKE_THEME_NAME}" CACHE PATH "" FORCE) endif() endif() diff --git a/MyxCMake/functions/MyxCMakeHighPrecisionMath.cmake b/MyxCMake/modules/MyxCMakeHighPrecisionMath.cmake similarity index 93% rename from MyxCMake/functions/MyxCMakeHighPrecisionMath.cmake rename to MyxCMake/modules/MyxCMakeHighPrecisionMath.cmake index b9dee33..79f707f 100644 --- a/MyxCMake/functions/MyxCMakeHighPrecisionMath.cmake +++ b/MyxCMake/modules/MyxCMakeHighPrecisionMath.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + function(myx_cmake_enable_high_precision_math) find_package(Quadmath) if(QUADMATH_FOUND) diff --git a/MyxCMake/modules/MyxCMakeIncludeSystemModules.cmake b/MyxCMake/modules/MyxCMakeIncludeSystemModules.cmake new file mode 100644 index 0000000..171cfb7 --- /dev/null +++ b/MyxCMake/modules/MyxCMakeIncludeSystemModules.cmake @@ -0,0 +1,3 @@ +include_guard(GLOBAL) + +include(GNUInstallDirs) diff --git a/MyxCMake/modules/MyxCMakeLSBInfo.cmake b/MyxCMake/modules/MyxCMakeLSBInfo.cmake index 3785321..2d7c004 100644 --- a/MyxCMake/modules/MyxCMakeLSBInfo.cmake +++ b/MyxCMake/modules/MyxCMakeLSBInfo.cmake @@ -1,29 +1,27 @@ -if(CMAKE_CROSSCOMPILING) - return() -endif() - -if(MYX_CMAKE_LSB_RELEASE) - return() -endif() +include_guard(GLOBAL) set(MYX_CMAKE_LSB_DISTRIBUTOR_ID "unknown") set(MYX_CMAKE_LSB_CODENAME "unknown") -set(MYX_CMAKE_LSB_RELEASE "unknown") +set(MYX_CMAKE_LSB_RELEASE_VERSION "unknown") + +if(CMAKE_CROSSCOMPILING) + return() +endif() if(EXISTS /etc/mcst_version) set(MYX_CMAKE_LSB_DISTRIBUTOR_ID "ElbrusD") set(MYX_CMAKE_LSB_CODENAME "Jessie") execute_process( COMMAND cat /etc/mcst_version - OUTPUT_VARIABLE MYX_CMAKE_LSB_RELEASE + OUTPUT_VARIABLE MYX_CMAKE_LSB_RELEASE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) else() - find_program(_lsb_release_executable lsb_release) + find_program(_lsb_release_exe lsb_release) # cmake-format: off - if(_lsb_release_executable) - execute_process(COMMAND ${_lsb_release_executable} -si OUTPUT_VARIABLE MYX_CMAKE_LSB_DISTRIBUTOR_ID OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${_lsb_release_executable} -sc OUTPUT_VARIABLE MYX_CMAKE_LSB_CODENAME OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND ${_lsb_release_executable} -sr OUTPUT_VARIABLE MYX_CMAKE_LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE) + if(_lsb_release_exe) + execute_process(COMMAND ${_lsb_release_exe} -si OUTPUT_VARIABLE MYX_CMAKE_LSB_DISTRIBUTOR_ID OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${_lsb_release_exe} -sc OUTPUT_VARIABLE MYX_CMAKE_LSB_CODENAME OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${_lsb_release_exe} -sr OUTPUT_VARIABLE MYX_CMAKE_LSB_RELEASE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) endif() # cmake-format: on endif() diff --git a/MyxCMake/functions/MyxCMakeLargeFiles.cmake b/MyxCMake/modules/MyxCMakeLargeFiles.cmake similarity index 68% rename from MyxCMake/functions/MyxCMakeLargeFiles.cmake rename to MyxCMake/modules/MyxCMakeLargeFiles.cmake index 55f501c..31d2b11 100644 --- a/MyxCMake/functions/MyxCMakeLargeFiles.cmake +++ b/MyxCMake/modules/MyxCMakeLargeFiles.cmake @@ -49,8 +49,63 @@ # However, it is YOUR job to make sure these defines are set in a cmakedefine so they # end up in a config.h file that is included in your source if necessary! +include_guard(GLOBAL) include(CheckTypeSize) + +set(_test_file_offset_bits_c +" +#include +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ]; +int main(int argc, char **argv) { return 0; } +") +set(_test_file_offset_bits_c_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/test_file_offset_bits.c) +file(WRITE ${_test_file_offset_bits_c_path} ${_test_file_offset_bits_c}) + + +set(_test_large_file_c_in +" +#cmakedefine _LARGEFILE_SOURCE +#cmakedefine _LARGEFILE64_SOURCE +#cmakedefine _LARGE_FILES +#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@ + +#include +#include +#include + +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + +int main(int argc, char **argv) +{ + int off_t_is_large[ (LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1 ]; + FILE *fp = fopen(argv[0],\"r\"); + off_t offset = ftello( fp ); + fseeko( fp, offset, SEEK_CUR ); + fclose(fp); + return off_t_is_large[0] || argc; +} +") +set(_test_large_file_c_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/test_large_file.c) +set(_test_large_file_c_in_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/test_large_file.c.in) +file(WRITE ${_test_large_file_c_in_path} ${_test_large_file_c_in}) + + +set(_test_windows_fseek_c +" +#include +int main() +{ + __int64 off=0; + _fseeki64(NULL, off, SEEK_SET); + return 0; +} +") +set(_test_windows_fseek_c_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/test_windows_fseek.c) +file(WRITE ${_test_windows_fseek_c_path} ${_test_windows_fseek_c}) + + macro(myx_cmake_test_large_files VARIABLE) if(NOT DEFINED ${VARIABLE}) @@ -61,14 +116,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}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestFileOffsetBits.c") + try_compile(FILE64_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_file_offset_bits_c_path}) 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}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestFileOffsetBits.c" + try_compile(FILE64_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_file_offset_bits_c_path} 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 +133,7 @@ macro(myx_cmake_test_large_files VARIABLE) if(NOT FILE64_OK) # Test with _LARGE_FILES - try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestFileOffsetBits.c" + try_compile(FILE64_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_file_offset_bits_c_path} COMPILE_DEFINITIONS "-D_LARGE_FILES") if(FILE64_OK) message(STATUS "Checking for 64-bit off_t - present with _LARGE_FILES") @@ -88,7 +143,7 @@ macro(myx_cmake_test_large_files VARIABLE) if(NOT FILE64_OK) # Test with _LARGEFILE_SOURCE - try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestFileOffsetBits.c" + try_compile(FILE64_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_file_offset_bits_c_path} COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE") if(FILE64_OK) message(STATUS "Checking for 64-bit off_t - present with _LARGEFILE_SOURCE") @@ -102,23 +157,19 @@ 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("${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestLargeFiles.c.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c") + configure_file(${_test_large_file_c_in_path} ${_test_large_file_c_path}) message(STATUS "Checking for fseeko/ftello") # Test if ftello/fseeko are available - try_compile(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c") + try_compile(FSEEKO_COMPILE_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_large_file_c_path}) if(FSEEKO_COMPILE_OK) message(STATUS "Checking for fseeko/ftello - present") endif() if(NOT FSEEKO_COMPILE_OK) # glibc 2.2 neds _LARGEFILE_SOURCE for fseeko (but not 64-bit off_t...) - try_compile( - FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c" - COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE") + try_compile(FSEEKO_COMPILE_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_large_file_c_path} + COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE") if(FSEEKO_COMPILE_OK) message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE") set(_LARGEFILE_SOURCE 1 CACHE INTERNAL "64-bit fseeko requires _LARGEFILE_SOURCE") @@ -132,7 +183,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}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestWindowsFSeek.c") + try_compile(FILE64_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_windows_fseek_c_path}) 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") @@ -141,7 +192,7 @@ macro(myx_cmake_test_large_files VARIABLE) if(FSEEKO_COMPILE_OK) set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) - set(HAVE_FSEEKO 1 CACHE INTERNAL "64bit fseeko is available" FORCE) + set(HAVE_FSEEKO 1 CACHE INTERNAL "64-bit fseeko is available" FORCE) elseif(HAVE__FSEEKI64) set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) set(HAVE__FSEEKI64 1 CACHE INTERNAL "Windows 64-bit fseek" FORCE) @@ -150,9 +201,8 @@ macro(myx_cmake_test_large_files VARIABLE) if(SIZEOF_LONG_INT EQUAL 8) #standard fseek is OK for 64bit set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) else() - message(FATAL_ERROR "Checking for 64bit file support failed.") + message(FATAL_ERROR "Checking for 64-bit file support failed.") endif() endif() - endif() endmacro(myx_cmake_test_large_files VARIABLE) diff --git a/MyxCMake/modules/MyxCMakeNinjaGeneratorHelper.cmake b/MyxCMake/modules/MyxCMakeNinjaGeneratorHelper.cmake index 64935d4..299d9ba 100644 --- a/MyxCMake/modules/MyxCMakeNinjaGeneratorHelper.cmake +++ b/MyxCMake/modules/MyxCMakeNinjaGeneratorHelper.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + # Если выбран генератор Ninja, то в основном сборочном каталоге создаётся файл # Makefile, который обрабатывается командой make и передаёт исполнение системе # сборки ninja. Таким образом можно выполнять команду make, даже если правила diff --git a/MyxCMake/modules/MyxCMakePkgConfig.cmake b/MyxCMake/modules/MyxCMakePkgConfig.cmake index 80351b7..2527f87 100644 --- a/MyxCMake/modules/MyxCMakePkgConfig.cmake +++ b/MyxCMake/modules/MyxCMakePkgConfig.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + function(myx_cmake_generate_pkgconfig target) set(options) set(oneVA COMPONENT BASENAME) diff --git a/MyxCMake/modules/MyxCMakePrecompiledHeaders.cmake b/MyxCMake/modules/MyxCMakePrecompiledHeaders.cmake index e021f69..555cd3c 100644 --- a/MyxCMake/modules/MyxCMakePrecompiledHeaders.cmake +++ b/MyxCMake/modules/MyxCMakePrecompiledHeaders.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + # cmake-format: off if(${CMAKE_VERSION} VERSION_LESS "3.16.0") include(cotire OPTIONAL) diff --git a/MyxCMake/modules/MyxCMakeProjectVersion.cmake b/MyxCMake/modules/MyxCMakeProjectVersion.cmake index bd89b2d..cd1556a 100644 --- a/MyxCMake/modules/MyxCMakeProjectVersion.cmake +++ b/MyxCMake/modules/MyxCMakeProjectVersion.cmake @@ -1,3 +1,5 @@ +include_guard(GLOBAL) + function(myx_cmake_check_project_version) if(NOT ${PROJECT_VERSION_PATCH} MATCHES "([0-9]+)") myx_cmake_message_error("MyxCMake: Please set project version in X.Y.Z format") diff --git a/MyxCMake/functions/MyxCMakeQtTranslation.cmake b/MyxCMake/modules/MyxCMakeQtTranslation.cmake similarity index 98% rename from MyxCMake/functions/MyxCMakeQtTranslation.cmake rename to MyxCMake/modules/MyxCMakeQtTranslation.cmake index 831e012..0e83fae 100644 --- a/MyxCMake/functions/MyxCMakeQtTranslation.cmake +++ b/MyxCMake/modules/MyxCMakeQtTranslation.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + function(myx_cmake_qt5_translation outfiles) find_package(Qt5 COMPONENTS LinguistTools REQUIRED) diff --git a/MyxCMake/functions/MyxCMakeRemoveFlag.cmake b/MyxCMake/modules/MyxCMakeRemoveFlag.cmake similarity index 99% rename from MyxCMake/functions/MyxCMakeRemoveFlag.cmake rename to MyxCMake/modules/MyxCMakeRemoveFlag.cmake index a614017..9706343 100644 --- a/MyxCMake/functions/MyxCMakeRemoveFlag.cmake +++ b/MyxCMake/modules/MyxCMakeRemoveFlag.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + # https://stackoverflow.com/a/49216539 # # Removes the specified compile flag from the specified target. diff --git a/MyxCMake/modules/MyxCMakeRequiredVariables.cmake b/MyxCMake/modules/MyxCMakeRequiredVariables.cmake index ad31501..2fa67e7 100644 --- a/MyxCMake/modules/MyxCMakeRequiredVariables.cmake +++ b/MyxCMake/modules/MyxCMakeRequiredVariables.cmake @@ -1,27 +1,33 @@ -# -# Обязательные переменные, значения которым необходимо присвоить в файле -# CMakeLists.txt до подключения MyxCMake, либо передать из командной строки -# через ключ -D -# +# Обязательные переменные, значения которым необходимо присвоить +# в файле CMakeLists.txt до подключения MyxCMake, либо передать через ключ -D + +include_guard(GLOBAL) # cmake-format: off if(NOT MYX_CMAKE_ORGANIZATION_NAME) - myx_cmake_message_error("MyxCMake: Required variable MYX_CMAKE_ORGANIZATION_NAME is not defined") + myx_cmake_message_warning("MyxCMake: Required variable MYX_CMAKE_ORGANIZATION_NAME is not defined") +else() + set(MYX_CMAKE_ORGANIZATION_NAME "ORG NAME" CACHE STRING "") endif() if(NOT MYX_CMAKE_AUTHOR_NAME) - myx_cmake_message_error("MyxCMake: Required variable MYX_CMAKE_AUTHOR_NAME is not defined") + myx_cmake_message_warning("MyxCMake: Required variable MYX_CMAKE_AUTHOR_NAME is not defined") +else() + set(MYX_CMAKE_AUTHOR_NAME "AUTHOR NAME" CACHE STRING "") endif() if(NOT MYX_CMAKE_AUTHOR_EMAIL) - myx_cmake_message_error("MyxCMake: Required variable MYX_CMAKE_AUTHOR_EMAIL is not defined") + myx_cmake_message_warning("MyxCMake: Required variable MYX_CMAKE_AUTHOR_EMAIL is not defined") +else() + set(MYX_CMAKE_AUTHOR_EMAIL "AUTHOR@EMAIL" CACHE STRING "") endif() if(NOT MYX_CMAKE_DESCRIPTION) - myx_cmake_message_error("MyxCMake: Required variable MYX_CMAKE_DESCRIPTION is not defined") + myx_cmake_message_warning("MyxCMake: Required variable MYX_CMAKE_DESCRIPTION is not defined") +else() + set(MYX_CMAKE_DESCRIPTION "PROJECT DESCRIPTION" CACHE STRING "") endif() set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${MYX_CMAKE_DESCRIPTION} CACHE STRING "") set(CPACK_PACKAGE_CONTACT "${MYX_CMAKE_AUTHOR_NAME} <${MYX_CMAKE_AUTHOR_EMAIL}>" CACHE STRING "") # cmake-format: on - diff --git a/MyxCMake/modules/MyxCMakeUninstall.cmake b/MyxCMake/modules/MyxCMakeUninstall.cmake index 8cd120e..192d754 100644 --- a/MyxCMake/modules/MyxCMakeUninstall.cmake +++ b/MyxCMake/modules/MyxCMakeUninstall.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + if(NOT TARGET uninstall) configure_file("${CMAKE_CURRENT_LIST_DIR}/MyxCMakeUninstall.cmake.in" "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) diff --git a/MyxCMake/modules/MyxCMakeUnityBuild.cmake b/MyxCMake/modules/MyxCMakeUnityBuild.cmake index 64e83df..d45d960 100644 --- a/MyxCMake/modules/MyxCMakeUnityBuild.cmake +++ b/MyxCMake/modules/MyxCMakeUnityBuild.cmake @@ -1,3 +1,5 @@ +include_guard(GLOBAL) + if(${CMAKE_VERSION} VERSION_LESS "3.16.0") include(cotire OPTIONAL) if(COMMAND cotire) diff --git a/MyxCMake/functions/MyxCMakeWriteCompilerDetectionHeader.cmake b/MyxCMake/modules/MyxCMakeWriteCompilerDetectionHeader.cmake similarity index 96% rename from MyxCMake/functions/MyxCMakeWriteCompilerDetectionHeader.cmake rename to MyxCMake/modules/MyxCMakeWriteCompilerDetectionHeader.cmake index 12ecff7..8d4468a 100644 --- a/MyxCMake/functions/MyxCMakeWriteCompilerDetectionHeader.cmake +++ b/MyxCMake/modules/MyxCMakeWriteCompilerDetectionHeader.cmake @@ -1,3 +1,6 @@ +include_guard(GLOBAL) + + function(myx_cmake_write_compiler_detection_header) if(${CMAKE_VERSION} VERSION_LESS "3.6.0") diff --git a/MyxCMake/functions/doc/breathe-conf.py.in b/MyxCMake/modules/doc/breathe-conf.py.in similarity index 100% rename from MyxCMake/functions/doc/breathe-conf.py.in rename to MyxCMake/modules/doc/breathe-conf.py.in