0.7.0 (рефакторинг)

This commit is contained in:
Andrei Astafev 2022-05-06 12:49:46 +03:00
parent 42b12b9f59
commit dd2a4fdb7d
56 changed files with 526 additions and 758 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.6)
project(myx-cmake VERSION 0.6.0 LANGUAGES) project(myx-cmake VERSION 0.7.0 LANGUAGES)
include(GNUInstallDirs) include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake

View File

@ -3,15 +3,6 @@ cmake_policy(SET CMP0057 NEW) # IN_LIST operator
get_filename_component(MYX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) 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") set(MYX_CMAKE_THIRDPARTY_DIR "${MYX_CMAKE_DIR}/thirdparty")
if(NOT IS_DIRECTORY "${MYX_CMAKE_THIRDPARTY_DIR}") if(NOT IS_DIRECTORY "${MYX_CMAKE_THIRDPARTY_DIR}")
myx_cmake_message_warning("MyxCMake: Thirdparty submodule is not found.") myx_cmake_message_warning("MyxCMake: Thirdparty submodule is not found.")

View File

@ -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()

View File

@ -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()

View File

@ -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})

View File

@ -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

View File

@ -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_ */

View File

@ -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_ */

View File

@ -1,11 +0,0 @@
#include <sys/types.h>
/* 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;
}

View File

@ -1,24 +0,0 @@
#cmakedefine _LARGEFILE_SOURCE
#cmakedefine _LARGEFILE64_SOURCE
#cmakedefine _LARGE_FILES
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
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;
}

View File

@ -1,11 +0,0 @@
#include <stdio.h>
int main()
{
__int64 off=0;
_fseeki64(NULL, off, SEEK_SET);
return 0;
}

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
# Создание динамической библиотеки из объектной библиотеки # Создание динамической библиотеки из объектной библиотеки
function(myx_cmake_add_shared_library target) function(myx_cmake_add_shared_library target)
myx_cmake_canonical_string(${target} _ctarget) myx_cmake_canonical_string(${target} _ctarget)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
# Создание статической библиотеки из объектной библиотеки # Создание статической библиотеки из объектной библиотеки
function(myx_cmake_add_static_library target) function(myx_cmake_add_static_library target)
myx_cmake_canonical_string(${target} _ctarget) myx_cmake_canonical_string(${target} _ctarget)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
cmake_policy(PUSH) cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # IN_LIST operator cmake_policy(SET CMP0057 NEW) # IN_LIST operator

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
# Общие настройки для пакета: организация, автор, версия # Общие настройки для пакета: организация, автор, версия
set(CPACK_PACKAGE_VENDOR ${MYX_CMAKE_ORGANIZATION_NAME_LOWER} CACHE STRING "") set(CPACK_PACKAGE_VENDOR ${MYX_CMAKE_ORGANIZATION_NAME_LOWER} CACHE STRING "")
set(CPACK_PACKAGE_NAME ${MYX_CMAKE_PROJECT_NAME_LOWER} CACHE STRING "") set(CPACK_PACKAGE_NAME ${MYX_CMAKE_PROJECT_NAME_LOWER} CACHE STRING "")

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
set(CLANG_APPLY_REPLACEMENTS_NAMES clang-apply-replacements) set(CLANG_APPLY_REPLACEMENTS_NAMES clang-apply-replacements)
foreach(V RANGE 9 15) foreach(V RANGE 9 15)
list(INSERT CLANG_APPLY_REPLACEMENTS_NAMES 0 "clang-apply-replacements-${V}") list(INSERT CLANG_APPLY_REPLACEMENTS_NAMES 0 "clang-apply-replacements-${V}")

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
set(CLANG_CHECK_NAMES clang-check) set(CLANG_CHECK_NAMES clang-check)
foreach(V RANGE 9 15) foreach(V RANGE 9 15)
list(INSERT CLANG_CHECK_NAMES 0 "clang-check-${V}") list(INSERT CLANG_CHECK_NAMES 0 "clang-check-${V}")

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
set(CLANG_TIDY_NAMES clang-tidy) set(CLANG_TIDY_NAMES clang-tidy)
foreach(V RANGE 9 15) foreach(V RANGE 9 15)
list(INSERT CLANG_TIDY_NAMES 0 "clang-tidy-${V}") list(INSERT CLANG_TIDY_NAMES 0 "clang-tidy-${V}")

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
find_program(CLAZY_EXE NAMES clazy-standalone) find_program(CLAZY_EXE NAMES clazy-standalone)
if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE) if(CLAZY_EXE AND CLANG_APPLY_REPLACEMENTS_EXE)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
if(CMAKE_EXPORT_COMPILE_COMMANDS) if(CMAKE_EXPORT_COMPILE_COMMANDS)
include(PVS-Studio) include(PVS-Studio)
find_program(PVS_STUDIO_ANALYZER_EXE pvs-studio-analyzer) find_program(PVS_STUDIO_ANALYZER_EXE pvs-studio-analyzer)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
option(MYX_CMAKE_CODE_COVERAGE "MyxCMake: enable code coverage" OFF) option(MYX_CMAKE_CODE_COVERAGE "MyxCMake: enable code coverage" OFF)
if(MYX_CMAKE_CODE_COVERAGE) if(MYX_CMAKE_CODE_COVERAGE)

View File

@ -1,3 +1,7 @@
# Обёртки для функций вывода сообщений
include_guard(GLOBAL)
if(DEFINED ENV{TERM} AND UNIX) if(DEFINED ENV{TERM} AND UNIX)
string(ASCII 27 Esc) string(ASCII 27 Esc)
set(MyxCMakeColorReset "${Esc}[m") set(MyxCMakeColorReset "${Esc}[m")

View File

@ -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(MyxCMakeColoredMessages)
include(MyxCMakeCheckPaths) include(MyxCMakeDirectoriesGuards)
include(MyxCMakeGlobalFunctions)
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(MyxCMakeProjectVersion) include(MyxCMakeProjectVersion)
include(MyxCMakeRequiredVariables) include(MyxCMakeRequiredVariables)
include(MyxCMakeGlobalFunctions)
include(MyxCMakeGlobalVariables) include(MyxCMakeGlobalVariables)
include(MyxCMakeDates) include(MyxCMakeLargeFiles)
include(MyxCMakeLSBInfo) include(MyxCMakeGeneratePrivateConfigHeader)
include(MyxCMakePaths) include(MyxCMakeGenerateGitInfoHeader)
include(MyxCMakeCompiler) include(MyxCMakeCompiler)
include(MyxCMakeCompilerFlags) include(MyxCMakeCompilerFlags)
include(MyxCMakeDistCC) include(MyxCMakeDistCC)
@ -28,8 +34,10 @@ include(MyxCMakeCodeAnalyzeClangCheck)
include(MyxCMakeCodeAnalyzeClangTidy) include(MyxCMakeCodeAnalyzeClangTidy)
include(MyxCMakeCodeAnalyzeClazy) include(MyxCMakeCodeAnalyzeClazy)
include(MyxCMakeCodeAnalyzePvsStudio) include(MyxCMakeCodeAnalyzePvsStudio)
include(MyxCMakeCodeCoverage) include(MyxCMakeCodeCoverage)
include(MyxCMakeFormatSources) include(MyxCMakeFormatSources)
include(MyxCMakeCommonPaths)
include(MyxCMakeCommonTargetProperties) include(MyxCMakeCommonTargetProperties)
include(MyxCMakeAddSharedLibrary) include(MyxCMakeAddSharedLibrary)
include(MyxCMakeAddStaticLibrary) include(MyxCMakeAddStaticLibrary)
@ -40,13 +48,3 @@ include(MyxCMakeDocBreathe)
include(MyxCMakeExternalProject) include(MyxCMakeExternalProject)
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

@ -0,0 +1,4 @@
include_guard(GLOBAL)
link_directories(${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})

View File

@ -1,9 +1,14 @@
include_guard(GLOBAL)
function(myx_cmake_common_target_properties target) function(myx_cmake_common_target_properties target)
if(NOT TARGET ${target}) if(NOT TARGET ${target})
myx_cmake_message_error("MyxCMake: Target ${target} does not exists.") myx_cmake_message_error("MyxCMake: Target ${target} does not exists.")
endif() endif()
get_target_property(_target_type ${target} TYPE) get_target_property(_target_type ${target} TYPE)
set_target_properties(${target} PROPERTIES USE_FOLDERS ON)
set(__visibility PUBLIC) set(__visibility PUBLIC)
if(_target_type STREQUAL INTERFACE_LIBRARY) if(_target_type STREQUAL INTERFACE_LIBRARY)
set(__visibility INTERFACE) set(__visibility INTERFACE)

View File

@ -1,5 +1,5 @@
if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" OR 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") set(CMAKE_37_MODULES_DIR "/usr/share/cmake-3.7/Modules")
if(IS_DIRECTORY ${CMAKE_37_MODULES_DIR}) if(IS_DIRECTORY ${CMAKE_37_MODULES_DIR})
if(NOT ${CMAKE_37_MODULES_DIR} IN_LIST CMAKE_MODULE_PATH) if(NOT ${CMAKE_37_MODULES_DIR} IN_LIST CMAKE_MODULE_PATH)

View File

@ -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()

View File

@ -1,3 +1,5 @@
include_guard(GLOBAL)
# C compiler name # C compiler name
if(CMAKE_C_COMPILER_ID STREQUAL "Intel") if(CMAKE_C_COMPILER_ID STREQUAL "Intel")
set(CMAKE_C_COMPILER_IS_INTEL ON) set(CMAKE_C_COMPILER_IS_INTEL ON)
@ -24,26 +26,25 @@ endif()
# Предпочтительные пути к утилитам для компоновки # Предпочтительные пути к утилитам для компоновки
if(CMAKE_CXX_COMPILER_IS_GCC) if(CMAKE_CXX_COMPILER_IS_GCC)
# cmake-format: off
# Astra Linux Smolensk 1.5 # Astra Linux Smolensk 1.5
if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND
MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk" AND MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk" AND
MYX_CMAKE_LSB_RELEASE STREQUAL "1.5") 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_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_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") find_program(CMAKE_GCC_RANLIB NAMES "/usr/bin/x86_64-linux-gnu-gcc-ranlib-4.7")
# Elbrus E2K # Elbrus E2K
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k") elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k")
find_program(CMAKE_GCC_AR find_program(CMAKE_GCC_AR NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/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_NM find_program(CMAKE_GCC_RANLIB NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ranlib")
NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/nm")
find_program(CMAKE_GCC_RANLIB
NAMES "/usr/${CMAKE_SYSTEM_PROCESSOR}-linux/bin/ranlib")
else() else()
find_program(CMAKE_GCC_AR NAMES "gcc-ar" "ar") find_program(CMAKE_GCC_AR NAMES "gcc-ar" "ar")
find_program(CMAKE_GCC_NM NAMES "gcc-nm" "nm") find_program(CMAKE_GCC_NM NAMES "gcc-nm" "nm")
find_program(CMAKE_GCC_RANLIB NAMES "gcc-ranlib" "ranlib") find_program(CMAKE_GCC_RANLIB NAMES "gcc-ranlib" "ranlib")
endif() endif()
# cmake-format: on
if(CMAKE_GCC_AR) if(CMAKE_GCC_AR)
set(CMAKE_AR ${CMAKE_GCC_AR} CACHE STRING "" FORCE) set(CMAKE_AR ${CMAKE_GCC_AR} CACHE STRING "" FORCE)

View File

@ -1,3 +1,5 @@
include_guard(GLOBAL)
# based on https://github.com/bluescarni/yacma # based on https://github.com/bluescarni/yacma
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
@ -7,13 +9,14 @@ macro(CHECK_ENABLE_CXX_FLAG flag)
check_cxx_compiler_flag("${flag}" CHECK_CXX_FLAG) check_cxx_compiler_flag("${flag}" CHECK_CXX_FLAG)
unset(CMAKE_REQUIRED_QUIET) unset(CMAKE_REQUIRED_QUIET)
# cmake-format: off
if(CHECK_CXX_FLAG) if(CHECK_CXX_FLAG)
myx_cmake_message_notice("'${flag}': flag is supported.") myx_cmake_message_notice("'${flag}': flag is supported.")
string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS "${_MYX_CMAKE_DETECTED_CXX_FLAGS} ${flag}")
"${_MYX_CMAKE_DETECTED_CXX_FLAGS} ${flag}")
else() else()
myx_cmake_message_status("'${flag}': flag is NOT supported.") myx_cmake_message_status("'${flag}': flag is NOT supported.")
endif() endif()
# cmake-format: on
# NOTE: check_cxx_compiler stores variables in the cache. # NOTE: check_cxx_compiler stores variables in the cache.
unset(CHECK_CXX_FLAG CACHE) unset(CHECK_CXX_FLAG CACHE)
endmacro() endmacro()
@ -24,40 +27,32 @@ macro(CHECK_ENABLE_DEBUG_CXX_FLAG flag)
check_cxx_compiler_flag("${flag}" CHECK_CXX_FLAG_DEBUG) check_cxx_compiler_flag("${flag}" CHECK_CXX_FLAG_DEBUG)
unset(CMAKE_REQUIRED_QUIET) unset(CMAKE_REQUIRED_QUIET)
# cmake-format: off
if(CHECK_CXX_FLAG_DEBUG) if(CHECK_CXX_FLAG_DEBUG)
myx_cmake_message_notice("'${flag}': debug flag is supported.") myx_cmake_message_notice("'${flag}': debug flag is supported.")
string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG string(CONCAT _MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG "${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG} ${flag}")
"${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG} ${flag}")
else() else()
myx_cmake_message_status("'${flag}': debug flag is NOT supported.") myx_cmake_message_status("'${flag}': debug flag is NOT supported.")
endif() endif()
# cmake-format: on
# NOTE: check_cxx_compiler stores variables in the cache. # NOTE: check_cxx_compiler stores variables in the cache.
unset(CHECK_CXX_FLAG_DEBUG CACHE) unset(CHECK_CXX_FLAG_DEBUG CACHE)
endif() endif()
endmacro() endmacro()
function(myx_cmake_set_cxx_standard version) function(myx_cmake_set_cxx_standard version)
# cmake-format: off
# Выбор стандарта по умолчанию (можно переопределить в проекте) # Выбор стандарта по умолчанию (можно переопределить в проекте)
set(CMAKE_CXX_STANDARD_REQUIRED set(CMAKE_CXX_STANDARD_REQUIRED YES PARENT_SCOPE)
YES
PARENT_SCOPE)
if(version EQUAL 11) if(version EQUAL 11)
set(CMAKE_CXX_STANDARD set(CMAKE_CXX_STANDARD 11 PARENT_SCOPE)
11 set(CMAKE_CXX_EXTENSIONS YES PARENT_SCOPE)
PARENT_SCOPE)
set(CMAKE_CXX_EXTENSIONS
YES
PARENT_SCOPE)
endif() endif()
if(version EQUAL 14) if(version EQUAL 14)
set(CMAKE_CXX_STANDARD set(CMAKE_CXX_STANDARD 14 PARENT_SCOPE)
14 set(CMAKE_CXX_EXTENSIONS YES PARENT_SCOPE)
PARENT_SCOPE)
set(CMAKE_CXX_EXTENSIONS
YES
PARENT_SCOPE)
endif() endif()
if(version EQUAL 17) if(version EQUAL 17)
@ -82,14 +77,11 @@ function(myx_cmake_set_cxx_standard version)
endif() endif()
endif() endif()
else() else()
set(CMAKE_CXX_STANDARD set(CMAKE_CXX_STANDARD 17 PARENT_SCOPE)
17 set(CMAKE_CXX_EXTENSIONS YES PARENT_SCOPE)
PARENT_SCOPE)
set(CMAKE_CXX_EXTENSIONS
YES
PARENT_SCOPE)
endif() endif()
endif() endif()
# cmake-format: on
endfunction() endfunction()
if(NOT MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE) if(NOT MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE)
@ -210,9 +202,9 @@ if(NOT MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE)
endif() endif()
# cmake-format: off # cmake-format: off
if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND if(MYX_CMAKE_LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND
MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk" AND MYX_CMAKE_LSB_CODENAME STREQUAL "smolensk" AND
MYX_CMAKE_LSB_RELEASE STREQUAL "1.5") MYX_CMAKE_LSB_RELEASE_VERSION STREQUAL "1.5")
# cmake-format: on # cmake-format: on
myx_cmake_set_cxx_standard(11) myx_cmake_set_cxx_standard(11)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k") elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k")
@ -227,14 +219,10 @@ if(NOT MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE)
endif() endif()
endif() endif()
# cmake-format: off
# Set the cache variables. # Set the cache variables.
set(MYX_CMAKE_DETECTED_CXX_FLAGS set(MYX_CMAKE_DETECTED_CXX_FLAGS "${_MYX_CMAKE_DETECTED_CXX_FLAGS}" CACHE INTERNAL "")
"${_MYX_CMAKE_DETECTED_CXX_FLAGS}" set(MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG "${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG}" CACHE INTERNAL "")
CACHE INTERNAL "") set(MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE YES CACHE INTERNAL "")
set(MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG # cmake-format: on
"${_MYX_CMAKE_DETECTED_CXX_FLAGS_DEBUG}"
CACHE INTERNAL "")
set(MYX_CMAKE_CXX_FLAGS_AUTODETECTION_DONE
YES
CACHE INTERNAL "")
endif() endif()

View File

@ -1,3 +1,5 @@
include_guard(GLOBAL)
if(NOT MYX_CMAKE_TODAY) if(NOT MYX_CMAKE_TODAY)
if(WIN32) if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_CMAKE_TODAY) execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_CMAKE_TODAY)
@ -15,4 +17,3 @@ if(NOT MYX_CMAKE_YEAR)
endif() endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3" MYX_CMAKE_YEAR ${MYX_CMAKE_YEAR}) string(REGEX REPLACE "(..)/(..)/(....).*" "\\3" MYX_CMAKE_YEAR ${MYX_CMAKE_YEAR})
endif() endif()

View File

@ -1,10 +1,13 @@
include_guard(GLOBAL)
# По умолчанию отключена отладочная печать (если не включена явно программистом) # По умолчанию отключена отладочная печать (если не включена явно программистом)
option(MYX_CMAKE_DEBUG_OUTPUT "Enable debug output" OFF) option(MYX_CMAKE_DEBUG_OUTPUT "Enable debug output" OFF)
option(MYX_CMAKE_INFO_OUTPUT "Enable info output" OFF) option(MYX_CMAKE_INFO_OUTPUT "Enable info output" OFF)
option(MYX_CMAKE_WARNING_OUTPUT "Enable warning output" OFF) option(MYX_CMAKE_WARNING_OUTPUT "Enable warning output" OFF)
# Если сборка производится в режиме для отладки, то включаются флаги для # Если сборка производится в режиме для отладки,
# разрешения отладочной печати # то включаются флаги для разрешения отладочной печати
if(CMAKE_BUILD_TYPE STREQUAL Debug) if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(MYX_CMAKE_DEBUG_OUTPUT ON CACHE BOOL "" FORCE) set(MYX_CMAKE_DEBUG_OUTPUT ON CACHE BOOL "" FORCE)
set(MYX_CMAKE_INFO_OUTPUT ON CACHE BOOL "" FORCE) set(MYX_CMAKE_INFO_OUTPUT ON CACHE BOOL "" FORCE)

View File

@ -1,9 +1,10 @@
# Запись результатов сборки проекта внутрь иерархии каталогов с исходными # Запись результатов сборки проекта внутрь иерархии каталогов с исходными текстами
# текстами приводит к засорению файлами формируемыми на этапе сборки, которые # приводит к засорению файлами формируемыми на этапе сборки, которые затрудняют
# затрудняют разработку, поиск в оригинальных файлах и мешают ориентироваться в # разработку, поиск в оригинальных файлах и мешают ориентироваться в проекте.
# проекте. При работе с несколькими типами сборки, например, отладка и выпуск, # При работе с несколькими типами сборки, например, отладка и выпуск, появляется
# появляется необходимость корректного полного удаления результатов предыдущего # необходимость корректного полного удаления результатов предыдущего варианта.
# варианта.
include_guard(GLOBAL)
get_filename_component(_source_realpath "${CMAKE_SOURCE_DIR}" REALPATH) get_filename_component(_source_realpath "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(_binary_realpath "${CMAKE_BINARY_DIR}" REALPATH) get_filename_component(_binary_realpath "${CMAKE_BINARY_DIR}" REALPATH)

View File

@ -1,3 +1,5 @@
include_guard(GLOBAL)
find_program(DISTCC_EXECUTABLE distcc) find_program(DISTCC_EXECUTABLE distcc)
mark_as_advanced(DISTCC_EXECUTABLE) mark_as_advanced(DISTCC_EXECUTABLE)
if(DISTCC_EXECUTABLE) if(DISTCC_EXECUTABLE)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
function(myx_cmake_doc_breathe) function(myx_cmake_doc_breathe)
set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator") set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator")
set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO) set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
function(myx_cmake_doc_doxygen) function(myx_cmake_doc_doxygen)
set(DOXYGEN_FOUND AUTO CACHE STRING "Enable Doxygen documentation generator") set(DOXYGEN_FOUND AUTO CACHE STRING "Enable Doxygen documentation generator")
set_property(CACHE DOXYGEN_FOUND PROPERTY STRINGS ON OFF AUTO) set_property(CACHE DOXYGEN_FOUND PROPERTY STRINGS ON OFF AUTO)
@ -18,30 +21,67 @@ function(myx_cmake_doc_doxygen)
if(NOT TARGET ${_target}) if(NOT TARGET ${_target})
set(options) set(options)
set(oneValueArgs SQLITE LATEX HTML) set(oneValueArgs SQLITE LATEX HTML LANGUAGE)
set(multiValueArgs) set(multiValueArgs)
cmake_parse_arguments(_arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(_arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(GENERATE_XML YES) set(GENERATE_XML YES)
set(GENERATE_HTML NO) set(GENERATE_HTML NO)
set(GENERATE_LATEX NO) set(GENERATE_LATEX NO)
set(DOXYGEN_OUTPUT_LANGUAGE Russian)
if(_arg_HTML) if(_arg_HTML)
set(GENERATE_HTML YES) set(GENERATE_HTML YES)
endif() endif()
if(_arg_LATEX) if(_arg_LATEX)
set(GENERATE_LATEX YES) set(GENERATE_LATEX YES)
endif() endif()
if(_arg_SQLITE) if(_arg_LANGUAGE)
set(GENERATE_SQLITE YES) set(DOXYGEN_OUTPUT_LANGUAGE ${_arg_LANGUAGE})
endif() 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) 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} add_custom_target(${_target}
VERBATIM VERBATIM
WORKING_DIRECTORY ${work_dir} WORKING_DIRECTORY ${work_dir}
COMMAND "${CMAKE_COMMAND}" -E remove -f "${work_dir}/doxygen_sqlite3.db"
COMMAND ${DOXYGEN_EXECUTABLE} ${work_dir}/Doxyfile COMMAND ${DOXYGEN_EXECUTABLE} ${work_dir}/Doxyfile
COMMENT "Generating API documentation with Doxygen") COMMENT "Generating API documentation with Doxygen")
if(_arg_HTML) if(_arg_HTML)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
include(ExternalProject) include(ExternalProject)
if(CMAKE_BUILD_TYPE) if(CMAKE_BUILD_TYPE)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
find_program(UNCRUSTIFY_EXE NAMES uncrustify) find_program(UNCRUSTIFY_EXE NAMES uncrustify)
if(UNCRUSTIFY_EXE) if(UNCRUSTIFY_EXE)

View File

@ -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()

View File

@ -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()

View File

@ -1,15 +1,17 @@
include_guard(GLOBAL)
# Формирование строки, состоящей из заглавных символов, цифр и подчёркиваний # Формирование строки, состоящей из заглавных символов, цифр и подчёркиваний
function(myx_cmake_canonical_string in_string out_string) function(myx_cmake_canonical_string in_string out_string)
string(TOUPPER ${in_string} _arg_uppercase) string(TOUPPER ${in_string} _uppercase)
string(REGEX REPLACE "[ -]" "_" _arg_fixed ${_arg_uppercase}) string(REGEX REPLACE "[ -]" "_" _fixed ${_uppercase})
set(${out_string} ${_arg_fixed} PARENT_SCOPE) set(${out_string} ${_fixed} PARENT_SCOPE)
endfunction() endfunction()
# Добавление общего префикса ко всем переменным в списке # Добавление общего префикса ко всем переменным в списке
function(myx_cmake_list_transform_prepend var prefix) function(myx_cmake_list_transform_prepend values prefix)
set(temp "") set(_list "")
foreach(filename ${${var}}) foreach(_val ${${values}})
list(APPEND temp "${prefix}${filename}") list(APPEND _list "${prefix}${_val}")
endforeach() endforeach()
set(${var} ${temp} PARENT_SCOPE) set(${values} ${_list} PARENT_SCOPE)
endfunction() endfunction()

View File

@ -1,5 +1,7 @@
include_guard(GLOBAL)
if(NOT MYX_CMAKE_THEME_NAME) if(NOT MYX_CMAKE_THEME_NAME)
set(MYX_CMAKE_THEME_NAME "default") set(MYX_CMAKE_THEME_NAME "default" CACHE STRING "")
endif() endif()
# cmake-format: off # 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_PROJECT_NAME_CANONICAL} MYX_CMAKE_PROJECT_NAME_UPPER)
string(TOUPPER ${MYX_CMAKE_THEME_NAME_CANONICAL} MYX_CMAKE_THEME_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) option(MYX_CMAKE_ADD_THEME_TO_INSTALL_PREFIX "Append theme name to install prefix" OFF)
if(MYX_CMAKE_ADD_THEME_PREFIX AND NOT MYX_CMAKE_THEME_PREFIX_APPENDED) 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") 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) set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${MYX_CMAKE_THEME_NAME}" CACHE PATH "" FORCE)
endif() endif()
endif() endif()

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
function(myx_cmake_enable_high_precision_math) function(myx_cmake_enable_high_precision_math)
find_package(Quadmath) find_package(Quadmath)
if(QUADMATH_FOUND) if(QUADMATH_FOUND)

View File

@ -0,0 +1,3 @@
include_guard(GLOBAL)
include(GNUInstallDirs)

View File

@ -1,29 +1,27 @@
if(CMAKE_CROSSCOMPILING) include_guard(GLOBAL)
return()
endif()
if(MYX_CMAKE_LSB_RELEASE)
return()
endif()
set(MYX_CMAKE_LSB_DISTRIBUTOR_ID "unknown") set(MYX_CMAKE_LSB_DISTRIBUTOR_ID "unknown")
set(MYX_CMAKE_LSB_CODENAME "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) if(EXISTS /etc/mcst_version)
set(MYX_CMAKE_LSB_DISTRIBUTOR_ID "ElbrusD") set(MYX_CMAKE_LSB_DISTRIBUTOR_ID "ElbrusD")
set(MYX_CMAKE_LSB_CODENAME "Jessie") set(MYX_CMAKE_LSB_CODENAME "Jessie")
execute_process( execute_process(
COMMAND cat /etc/mcst_version COMMAND cat /etc/mcst_version
OUTPUT_VARIABLE MYX_CMAKE_LSB_RELEASE OUTPUT_VARIABLE MYX_CMAKE_LSB_RELEASE_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
else() else()
find_program(_lsb_release_executable lsb_release) find_program(_lsb_release_exe lsb_release)
# cmake-format: off # cmake-format: off
if(_lsb_release_executable) if(_lsb_release_exe)
execute_process(COMMAND ${_lsb_release_executable} -si OUTPUT_VARIABLE MYX_CMAKE_LSB_DISTRIBUTOR_ID OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${_lsb_release_exe} -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_exe} -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) execute_process(COMMAND ${_lsb_release_exe} -sr OUTPUT_VARIABLE MYX_CMAKE_LSB_RELEASE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
endif() endif()
# cmake-format: on # cmake-format: on
endif() endif()

View File

@ -49,8 +49,63 @@
# However, it is YOUR job to make sure these defines are set in a cmakedefine so they # 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! # end up in a config.h file that is included in your source if necessary!
include_guard(GLOBAL)
include(CheckTypeSize) include(CheckTypeSize)
set(_test_file_offset_bits_c
"
#include <sys/types.h>
#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 <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#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 <stdio.h>
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) macro(myx_cmake_test_large_files VARIABLE)
if(NOT DEFINED ${VARIABLE}) if(NOT DEFINED ${VARIABLE})
@ -61,14 +116,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}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestFileOffsetBits.c") try_compile(FILE64_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_file_offset_bits_c_path})
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}" "${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") 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 +133,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}" "${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") 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 +143,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}" "${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") 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,23 +157,19 @@ 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("${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestLargeFiles.c.in" configure_file(${_test_large_file_c_in_path} ${_test_large_file_c_path})
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
message(STATUS "Checking for fseeko/ftello") message(STATUS "Checking for fseeko/ftello")
# Test if ftello/fseeko are available # Test if ftello/fseeko are available
try_compile(FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}" try_compile(FSEEKO_COMPILE_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_large_file_c_path})
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c")
if(FSEEKO_COMPILE_OK) if(FSEEKO_COMPILE_OK)
message(STATUS "Checking for fseeko/ftello - present") message(STATUS "Checking for fseeko/ftello - present")
endif() endif()
if(NOT FSEEKO_COMPILE_OK) if(NOT FSEEKO_COMPILE_OK)
# glibc 2.2 neds _LARGEFILE_SOURCE for fseeko (but not 64-bit off_t...) # glibc 2.2 neds _LARGEFILE_SOURCE for fseeko (but not 64-bit off_t...)
try_compile( try_compile(FSEEKO_COMPILE_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_large_file_c_path}
FSEEKO_COMPILE_OK "${CMAKE_BINARY_DIR}" COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE")
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestLargeFiles.c"
COMPILE_DEFINITIONS "-D_LARGEFILE_SOURCE")
if(FSEEKO_COMPILE_OK) if(FSEEKO_COMPILE_OK)
message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE") message(STATUS "Checking for fseeko/ftello - present with _LARGEFILE_SOURCE")
set(_LARGEFILE_SOURCE 1 CACHE INTERNAL "64-bit fseeko requires _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 # 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}" "${MYX_CMAKE_FUNCTIONS_DIR}/largefiles/TestWindowsFSeek.c") try_compile(FILE64_OK ${CMAKE_CURRENT_BINARY_DIR} ${_test_windows_fseek_c_path})
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")
@ -141,7 +192,7 @@ macro(myx_cmake_test_large_files VARIABLE)
if(FSEEKO_COMPILE_OK) if(FSEEKO_COMPILE_OK)
set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) 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) elseif(HAVE__FSEEKI64)
set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE) set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
set(HAVE__FSEEKI64 1 CACHE INTERNAL "Windows 64-bit fseek" 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 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) set(${VARIABLE} 1 CACHE INTERNAL "Result of test for large file support" FORCE)
else() else()
message(FATAL_ERROR "Checking for 64bit file support failed.") message(FATAL_ERROR "Checking for 64-bit file support failed.")
endif() endif()
endif() endif()
endif() endif()
endmacro(myx_cmake_test_large_files VARIABLE) endmacro(myx_cmake_test_large_files VARIABLE)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
# Если выбран генератор Ninja, то в основном сборочном каталоге создаётся файл # Если выбран генератор Ninja, то в основном сборочном каталоге создаётся файл
# Makefile, который обрабатывается командой make и передаёт исполнение системе # Makefile, который обрабатывается командой make и передаёт исполнение системе
# сборки ninja. Таким образом можно выполнять команду make, даже если правила # сборки ninja. Таким образом можно выполнять команду make, даже если правила

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
function(myx_cmake_generate_pkgconfig target) function(myx_cmake_generate_pkgconfig target)
set(options) set(options)
set(oneVA COMPONENT BASENAME) set(oneVA COMPONENT BASENAME)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
# cmake-format: off # cmake-format: off
if(${CMAKE_VERSION} VERSION_LESS "3.16.0") if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
include(cotire OPTIONAL) include(cotire OPTIONAL)

View File

@ -1,3 +1,5 @@
include_guard(GLOBAL)
function(myx_cmake_check_project_version) function(myx_cmake_check_project_version)
if(NOT ${PROJECT_VERSION_PATCH} MATCHES "([0-9]+)") if(NOT ${PROJECT_VERSION_PATCH} MATCHES "([0-9]+)")
myx_cmake_message_error("MyxCMake: Please set project version in X.Y.Z format") myx_cmake_message_error("MyxCMake: Please set project version in X.Y.Z format")

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
function(myx_cmake_qt5_translation outfiles) function(myx_cmake_qt5_translation outfiles)
find_package(Qt5 COMPONENTS LinguistTools REQUIRED) find_package(Qt5 COMPONENTS LinguistTools REQUIRED)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
# https://stackoverflow.com/a/49216539 # https://stackoverflow.com/a/49216539
# #
# Removes the specified compile flag from the specified target. # Removes the specified compile flag from the specified target.

View File

@ -1,27 +1,33 @@
# # Обязательные переменные, значения которым необходимо присвоить
# Обязательные переменные, значения которым необходимо присвоить в файле # в файле CMakeLists.txt до подключения MyxCMake, либо передать через ключ -D
# CMakeLists.txt до подключения MyxCMake, либо передать из командной строки
# через ключ -D include_guard(GLOBAL)
#
# cmake-format: off # cmake-format: off
if(NOT MYX_CMAKE_ORGANIZATION_NAME) 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() endif()
if(NOT MYX_CMAKE_AUTHOR_NAME) 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() endif()
if(NOT MYX_CMAKE_AUTHOR_EMAIL) 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() endif()
if(NOT MYX_CMAKE_DESCRIPTION) 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() endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${MYX_CMAKE_DESCRIPTION} CACHE STRING "") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${MYX_CMAKE_DESCRIPTION} CACHE STRING "")
set(CPACK_PACKAGE_CONTACT "${MYX_CMAKE_AUTHOR_NAME} <${MYX_CMAKE_AUTHOR_EMAIL}>" CACHE STRING "") set(CPACK_PACKAGE_CONTACT "${MYX_CMAKE_AUTHOR_NAME} <${MYX_CMAKE_AUTHOR_EMAIL}>" CACHE STRING "")
# cmake-format: on # cmake-format: on

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
if(NOT TARGET uninstall) if(NOT TARGET uninstall)
configure_file("${CMAKE_CURRENT_LIST_DIR}/MyxCMakeUninstall.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)

View File

@ -1,3 +1,5 @@
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS "3.16.0") if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
include(cotire OPTIONAL) include(cotire OPTIONAL)
if(COMMAND cotire) if(COMMAND cotire)

View File

@ -1,3 +1,6 @@
include_guard(GLOBAL)
function(myx_cmake_write_compiler_detection_header) function(myx_cmake_write_compiler_detection_header)
if(${CMAKE_VERSION} VERSION_LESS "3.6.0") if(${CMAKE_VERSION} VERSION_LESS "3.6.0")