Compare commits

..

No commits in common. "2964f29139081fe28c1f7c6b2240220f37a314e2" and "90ab2473b1e815c82133e24f3982ec19f94b0a61" have entirely different histories.

45 changed files with 208 additions and 2489 deletions

View File

@ -1,4 +1,4 @@
# Uncrustify-0.77.1_f
# Uncrustify-0.74.0_f
#
# General options
@ -127,11 +127,6 @@ sp_before_assign = force # ignore/add/remove/force/not_defined
# Overrides sp_assign.
sp_after_assign = force # ignore/add/remove/force/not_defined
# Add or remove space in 'enum {'.
#
# Default: add
sp_enum_brace = force # ignore/add/remove/force/not_defined
# Add or remove space in 'NS_ENUM ('.
sp_enum_paren = ignore # ignore/add/remove/force/not_defined
@ -195,11 +190,6 @@ sp_before_ptr_star = remove # ignore/add/remove/force/not_defined
# variable name. If set to ignore, sp_before_ptr_star is used instead.
sp_before_unnamed_ptr_star = remove # ignore/add/remove/force/not_defined
# Add or remove space between a qualifier and a pointer star '*' that isn't
# followed by a variable name, as in '(char const *)'. If set to ignore,
# sp_before_ptr_star is used instead.
sp_qualifier_unnamed_ptr_star = ignore # ignore/add/remove/force/not_defined
# Add or remove space between pointer stars '*', as in 'int ***a;'.
sp_between_ptr_star = remove # ignore/add/remove/force/not_defined
@ -228,33 +218,18 @@ sp_after_ptr_star_trailing = ignore # ignore/add/remove/force/not_defined
# in a function pointer definition.
sp_ptr_star_func_var = ignore # ignore/add/remove/force/not_defined
# Add or remove space between the pointer star '*' and the name of the type
# in a function pointer type definition.
sp_ptr_star_func_type = remove # ignore/add/remove/force/not_defined
# Add or remove space after a pointer star '*', if followed by an open
# parenthesis, as in 'void* (*)()'.
sp_ptr_star_paren = ignore # ignore/add/remove/force/not_defined
# Add or remove space before a pointer star '*', if followed by a function
# prototype or function definition. If set to ignore, sp_before_ptr_star is
# used instead.
# prototype or function definition.
sp_before_ptr_star_func = remove # ignore/add/remove/force/not_defined
# Add or remove space between a qualifier and a pointer star '*' followed by
# the name of the function in a function prototype or definition, as in
# 'char const *foo()`. If set to ignore, sp_before_ptr_star is used instead.
sp_qualifier_ptr_star_func = ignore # ignore/add/remove/force/not_defined
# Add or remove space before a pointer star '*' in the trailing return of a
# function prototype or function definition.
sp_before_ptr_star_trailing = ignore # ignore/add/remove/force/not_defined
# Add or remove space between a qualifier and a pointer star '*' in the
# trailing return of a function prototype or function definition, as in
# 'auto foo() -> char const *'.
sp_qualifier_ptr_star_trailing = ignore # ignore/add/remove/force/not_defined
# Add or remove space before a reference sign '&'.
sp_before_byref = remove # ignore/add/remove/force/not_defined
@ -277,10 +252,6 @@ sp_after_byref_func = ignore # ignore/add/remove/force/not_defined
# prototype or function definition.
sp_before_byref_func = ignore # ignore/add/remove/force/not_defined
# Add or remove space after a reference sign '&', if followed by an open
# parenthesis, as in 'char& (*)()'.
sp_byref_paren = force # ignore/add/remove/force/not_defined
# Add or remove space between type and word. In cases where total removal of
# whitespace would be a syntax error, a value of 'remove' is treated the same
# as 'force'.
@ -408,11 +379,11 @@ sp_before_semi_for = remove # ignore/add/remove/force/not_defined
# Add or remove space before a semicolon of an empty left part of a for
# statement, as in 'for ( <here> ; ; )'.
sp_before_semi_for_empty = force # ignore/add/remove/force/not_defined
sp_before_semi_for_empty = remove # ignore/add/remove/force/not_defined
# Add or remove space between the semicolons of an empty middle part of a for
# statement, as in 'for ( ; <here> ; )'.
sp_between_semi_for_empty = force # ignore/add/remove/force/not_defined
sp_between_semi_for_empty = remove # ignore/add/remove/force/not_defined
# Add or remove space after ';', except when followed by a comment.
#
@ -426,7 +397,7 @@ sp_after_semi_for = force # ignore/add/remove/force/not_defined
# Add or remove space after the final semicolon of an empty part of a for
# statement, as in 'for ( ; ; <here> )'.
sp_after_semi_for_empty = force # ignore/add/remove/force/not_defined
sp_after_semi_for_empty = remove # ignore/add/remove/force/not_defined
# Add or remove space before '[' (except '[]').
sp_before_square = ignore # ignore/add/remove/force/not_defined
@ -463,15 +434,15 @@ sp_after_comma = force # ignore/add/remove/force/not_defined
# Default: remove
sp_before_comma = remove # ignore/add/remove/force/not_defined
# (C#, Vala) Add or remove space between ',' and ']' in multidimensional array type
# (C#) Add or remove space between ',' and ']' in multidimensional array type
# like 'int[,,]'.
sp_after_mdatype_commas = ignore # ignore/add/remove/force/not_defined
# (C#, Vala) Add or remove space between '[' and ',' in multidimensional array type
# (C#) Add or remove space between '[' and ',' in multidimensional array type
# like 'int[,,]'.
sp_before_mdatype_commas = ignore # ignore/add/remove/force/not_defined
# (C#, Vala) Add or remove space between ',' in multidimensional array type
# (C#) Add or remove space between ',' in multidimensional array type
# like 'int[,,]'.
sp_between_mdatype_commas = ignore # ignore/add/remove/force/not_defined
@ -481,17 +452,14 @@ sp_between_mdatype_commas = ignore # ignore/add/remove/force/not_defined
# Default: force
sp_paren_comma = force # ignore/add/remove/force/not_defined
# Add or remove space between a type and ':'.
sp_type_colon = force # ignore/add/remove/force/not_defined
# Add or remove space after the variadic '...' when preceded by a
# non-punctuator.
# The value REMOVE will be overridden with FORCE
# The value REMOVE will be overriden with FORCE
sp_after_ellipsis = ignore # ignore/add/remove/force/not_defined
# Add or remove space before the variadic '...' when preceded by a
# non-punctuator.
# The value REMOVE will be overridden with FORCE
# The value REMOVE will be overriden with FORCE
sp_before_ellipsis = force # ignore/add/remove/force/not_defined
# Add or remove space between a type and '...'.
@ -500,6 +468,9 @@ sp_type_ellipsis = force # ignore/add/remove/force/not_defined
# Add or remove space between a '*' and '...'.
sp_ptr_type_ellipsis = ignore # ignore/add/remove/force/not_defined
# (D) Add or remove space between a type and '?'.
sp_type_question = ignore # ignore/add/remove/force/not_defined
# Add or remove space between ')' and '...'.
sp_paren_ellipsis = ignore # ignore/add/remove/force/not_defined
@ -644,16 +615,6 @@ sp_inside_fparens = remove # ignore/add/remove/force/not_defined
# Add or remove space inside function '(' and ')'.
sp_inside_fparen = force # ignore/add/remove/force/not_defined
# Add or remove space inside user functor '(' and ')'.
sp_func_call_user_inside_rparen = ignore # ignore/add/remove/force/not_defined
# Add or remove space inside empty functor '()'.
# Overrides sp_after_angle unless use_sp_after_angle_always is set to true.
sp_inside_rparens = ignore # ignore/add/remove/force/not_defined
# Add or remove space inside functor '(' and ')'.
sp_inside_rparen = ignore # ignore/add/remove/force/not_defined
# Add or remove space inside the first parentheses in a function type, as in
# 'void (*x)(...)'.
sp_inside_tparen = ignore # ignore/add/remove/force/not_defined
@ -770,10 +731,10 @@ sp_macro = ignore # ignore/add/remove/force/not_defined
sp_macro_func = ignore # ignore/add/remove/force/not_defined
# Add or remove space between 'else' and '{' if on the same line.
sp_else_brace = force # ignore/add/remove/force/not_defined
sp_else_brace = ignore # ignore/add/remove/force/not_defined
# Add or remove space between '}' and 'else' if on the same line.
sp_brace_else = force # ignore/add/remove/force/not_defined
sp_brace_else = ignore # ignore/add/remove/force/not_defined
# Add or remove space between '}' and the name of a typedef on the same line.
sp_brace_typedef = ignore # ignore/add/remove/force/not_defined
@ -808,7 +769,7 @@ sp_getset_brace = ignore # ignore/add/remove/force/not_defined
# Add or remove space between a variable and '{' for C++ uniform
# initialization.
sp_word_brace_init_lst = add # ignore/add/remove/force/not_defined
sp_word_brace_init_lst = force # ignore/add/remove/force/not_defined
# Add or remove space between a variable and '{' for a namespace.
#
@ -829,10 +790,6 @@ sp_d_array_colon = ignore # ignore/add/remove/force/not_defined
# Default: remove
sp_not = remove # ignore/add/remove/force/not_defined
# Add or remove space between two '!' (not) unary operators.
# If set to ignore, sp_not will be used.
sp_not_not = ignore # ignore/add/remove/force/not_defined
# Add or remove space after the '~' (invert) unary operator.
#
# Default: remove
@ -991,15 +948,7 @@ sp_before_for_colon = remove # ignore/add/remove/force/not_defined
sp_extern_paren = ignore # ignore/add/remove/force/not_defined
# Add or remove space after the opening of a C++ comment, as in '// <here> A'.
sp_cmt_cpp_start = add # ignore/add/remove/force/not_defined
# remove space after the '//' and the pvs command '-V1234',
# only works with sp_cmt_cpp_start set to add or force.
sp_cmt_cpp_pvs = true # true/false
# remove space after the '//' and the command 'lint',
# only works with sp_cmt_cpp_start set to add or force.
sp_cmt_cpp_lint = true # true/false
sp_cmt_cpp_start = ignore # ignore/add/remove/force/not_defined
# Add or remove space in a C++ region marker comment, as in '// <here> BEGIN'.
# A region marker is defined as a comment which is not preceded by other text
@ -1029,7 +978,7 @@ sp_between_new_paren = ignore # ignore/add/remove/force/not_defined
# Add or remove space between ')' and type in 'new(foo) BAR'.
sp_after_newop_paren = ignore # ignore/add/remove/force/not_defined
# Add or remove space inside parentheses of the new operator
# Add or remove space inside parenthesis of the new operator
# as in 'new(foo) BAR'.
sp_inside_newop_paren = ignore # ignore/add/remove/force/not_defined
@ -1095,21 +1044,15 @@ force_tab_after_define = false # true/false
# Default: 8
indent_columns = 8 # unsigned number
# Whether to ignore indent for the first continuation line. Subsequent
# continuation lines will still be indented to match the first.
indent_ignore_first_continue = false # true/false
# The continuation indent. If non-zero, this overrides the indent of '(', '['
# and '=' continuation indents. Negative values are OK; negative value is
# absolute and not increased for each '(' or '[' level.
#
# For FreeBSD, this is set to 4.
# Requires indent_ignore_first_continue=false.
indent_continue = 0 # number
# The continuation indent, only for class header line(s). If non-zero, this
# overrides the indent of 'class' continuation indents.
# Requires indent_ignore_first_continue=false.
indent_continue_class_head = 0 # unsigned number
# Whether to indent empty lines (i.e. lines which contain only spaces before
@ -1185,23 +1128,16 @@ indent_namespace_level = 0 # unsigned number
# indented. Requires indent_namespace=true. 0 means no limit.
indent_namespace_limit = 0 # unsigned number
# Whether to indent only in inner namespaces (nested in other namespaces).
# Requires indent_namespace=true.
indent_namespace_inner_only = false # true/false
# Whether the 'extern "C"' body is indented.
indent_extern = false # true/false
# Whether the 'class' body is indented.
indent_class = true # true/false
# Whether to ignore indent for the leading base class colon.
indent_ignore_before_class_colon = true # true/false
# Additional indent before the leading base class colon.
# Negative values decrease indent down to the first column.
# Requires indent_ignore_before_class_colon=false and a newline break before
# the colon (see pos_class_colon and nl_class_colon)
# Requires a newline break before colon (see pos_class_colon
# and nl_class_colon)
indent_before_class_colon = 0 # number
# Whether to indent the stuff after a leading base class colon.
@ -1211,9 +1147,6 @@ indent_class_colon = true # true/false
# colon. Requires indent_class_colon=true.
indent_class_on_colon = true # true/false
# Whether to ignore indent for a leading class initializer colon.
indent_ignore_before_constr_colon = true # true/false
# Whether to indent the stuff after a leading class initializer colon.
indent_constr_colon = false # true/false
@ -1244,12 +1177,9 @@ indent_var_def_blk = 0 # number
# Whether to indent continued variable declarations instead of aligning.
indent_var_def_cont = false # true/false
# How to indent continued shift expressions ('<<' and '>>').
# Set align_left_shift=false when using this.
# 0: Align shift operators instead of indenting them (default)
# 1: Indent by one level
# -1: Preserve original indentation
indent_shift = 0 # number
# Whether to indent continued shift expressions ('<<' and '>>') instead of
# aligning. Set align_left_shift=false when enabling this.
indent_shift = false # true/false
# Whether to force indentation of function definitions to start in column 1.
indent_func_def_force_col1 = false # true/false
@ -1336,9 +1266,6 @@ indent_switch_case = 0 # unsigned number
# Usually the same as indent_columns or indent_switch_case.
indent_switch_body = 0 # unsigned number
# Whether to ignore indent for '{' following 'case'.
indent_ignore_case_brace = false # true/false
# Spaces to indent '{' from 'case'. By default, the brace will appear under
# the 'c' in case. Usually set to 0 or indent_columns. Negative values are OK.
# It might be wise to choose the same value for the option indent_switch_case.
@ -1407,11 +1334,10 @@ indent_paren_nl = false # true/false
# How to indent a close parenthesis after a newline.
#
# 0: Indent to body level (default)
# 1: Align under the open parenthesis
# 2: Indent to the brace level
# -1: Preserve original indentation
indent_paren_close = 0 # number
# 0: Indent to body level (default)
# 1: Align under the open parenthesis
# 2: Indent to the brace level
indent_paren_close = 0 # unsigned number
# Whether to indent the open parenthesis of a function definition,
# if the parenthesis is on its own line.
@ -1425,41 +1351,24 @@ indent_paren_after_func_decl = false # true/false
# if the parenthesis is on its own line.
indent_paren_after_func_call = false # true/false
# How to indent a comma when inside braces.
# 0: Indent by one level (default)
# 1: Align under the open brace
# -1: Preserve original indentation
indent_comma_brace = 0 # number
# Whether to indent a comma when inside a brace.
# If true, aligns under the open brace.
indent_comma_brace = false # true/false
# How to indent a comma when inside parentheses.
# 0: Indent by one level (default)
# 1: Align under the open parenthesis
# -1: Preserve original indentation
indent_comma_paren = 1 # number
# Whether to indent a comma when inside a parenthesis.
# If true, aligns under the open parenthesis.
indent_comma_paren = true # true/false
# How to indent a Boolean operator when inside parentheses.
# 0: Indent by one level (default)
# 1: Align under the open parenthesis
# -1: Preserve original indentation
indent_bool_paren = 0 # number
# Whether to ignore the indentation of a Boolean operator when outside
# parentheses.
indent_ignore_bool = false # true/false
# Whether to ignore the indentation of an arithmetic operator.
indent_ignore_arith = false # true/false
# Whether to indent a Boolean operator when inside a parenthesis.
# If true, aligns under the open parenthesis.
indent_bool_paren = false # true/false
# Whether to indent a semicolon when inside a for parenthesis.
# If true, aligns under the open for parenthesis.
indent_semicolon_for_paren = false # true/false
# Whether to ignore the indentation of a semicolon outside of a 'for'
# statement.
indent_ignore_semicolon = false # true/false
# Whether to align the first expression to following ones
# if indent_bool_paren=1.
# if indent_bool_paren=true.
indent_first_bool_expr = false # true/false
# Whether to align the first expression to following ones
@ -1473,9 +1382,6 @@ indent_square_nl = false # true/false
# (ESQL/C) Whether to preserve the relative indent of 'EXEC SQL' bodies.
indent_preserve_sql = false # true/false
# Whether to ignore the indentation of an assignment operator.
indent_ignore_assign = false # true/false
# Whether to align continued statements at the '='. If false or if the '=' is
# followed by a newline, the next line is indent one tab.
#
@ -1571,7 +1477,7 @@ indent_using_block = true # true/false
# How to indent the continuation of ternary operator.
#
# 0: Off (default)
# 1: When the `if_false` is a continuation, indent it under the `if_true` branch
# 1: When the `if_false` is a continuation, indent it under `if_false`
# 2: When the `:` is a continuation, indent it under `?`
indent_ternary_operator = 2 # unsigned number
@ -1599,14 +1505,9 @@ donot_indent_func_def_close_paren = false # true/false
# Newline adding and removing options
#
# Whether to collapse empty blocks between '{' and '}' except for functions.
# Use nl_collapse_empty_body_functions to specify how empty function braces
# should be formatted.
nl_collapse_empty_body = true # true/false
# Whether to collapse empty blocks between '{' and '}' for functions only.
# If true, overrides nl_inside_empty_func.
nl_collapse_empty_body_functions = true # true/false
# Whether to collapse empty blocks between '{' and '}'.
# If true, overrides nl_inside_empty_func
nl_collapse_empty_body = false # true/false
# Don't split one-line braced assignments, as in 'foo_t f = { 1, 2 };'.
nl_assign_leave_one_liners = true # true/false
@ -1695,7 +1596,7 @@ nl_after_square_assign = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between a function call's ')' and '{', as in
# 'list_for_each(item, &list) { }'.
nl_fcall_brace = force # ignore/add/remove/force/not_defined
nl_fcall_brace = add # ignore/add/remove/force/not_defined
# Add or remove newline between 'enum' and '{'.
nl_enum_brace = force # ignore/add/remove/force/not_defined
@ -1719,17 +1620,17 @@ nl_struct_brace = force # ignore/add/remove/force/not_defined
nl_union_brace = force # ignore/add/remove/force/not_defined
# Add or remove newline between 'if' and '{'.
nl_if_brace = remove # ignore/add/remove/force/not_defined
nl_if_brace = force # ignore/add/remove/force/not_defined
# Add or remove newline between '}' and 'else'.
nl_brace_else = ignore # ignore/add/remove/force/not_defined
nl_brace_else = force # ignore/add/remove/force/not_defined
# Add or remove newline between 'else if' and '{'. If set to ignore,
# nl_if_brace is used instead.
nl_elseif_brace = force # ignore/add/remove/force/not_defined
# Add or remove newline between 'else' and '{'.
nl_else_brace = remove # ignore/add/remove/force/not_defined
nl_else_brace = force # ignore/add/remove/force/not_defined
# Add or remove newline between 'else' and 'if'.
nl_else_if = force # ignore/add/remove/force/not_defined
@ -1753,7 +1654,7 @@ nl_try_brace = ignore # ignore/add/remove/force/not_defined
nl_getset_brace = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'for' and '{'.
nl_for_brace = remove # ignore/add/remove/force/not_defined
nl_for_brace = add # ignore/add/remove/force/not_defined
# Add or remove newline before the '{' of a 'catch' statement, as in
# 'catch (decl) <here> {'.
@ -1777,7 +1678,7 @@ nl_brace_square = ignore # ignore/add/remove/force/not_defined
nl_brace_fparen = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'while' and '{'.
nl_while_brace = remove # ignore/add/remove/force/not_defined
nl_while_brace = add # ignore/add/remove/force/not_defined
# (D) Add or remove newline between 'scope (x)' and '{'.
nl_scope_brace = ignore # ignore/add/remove/force/not_defined
@ -1802,7 +1703,7 @@ nl_do_brace = ignore # ignore/add/remove/force/not_defined
nl_brace_while = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'switch' and '{'.
nl_switch_brace = remove # ignore/add/remove/force/not_defined
nl_switch_brace = add # ignore/add/remove/force/not_defined
# Add or remove newline between 'synchronized' and '{'.
nl_synchronized_brace = ignore # ignore/add/remove/force/not_defined
@ -1901,7 +1802,7 @@ nl_template_var = ignore # ignore/add/remove/force/not_defined
nl_template_using = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'class' and '{'.
nl_class_brace = force # ignore/add/remove/force/not_defined
nl_class_brace = add # ignore/add/remove/force/not_defined
# Add or remove newline before or after (depending on pos_class_comma,
# may not be IGNORE) each',' in the base class list.
@ -2060,12 +1961,6 @@ nl_template_end = false # true/false
# See nl_oc_msg_leave_one_liner.
nl_oc_msg_args = false # true/false
# (OC) Minimum number of Objective-C message parameters before applying nl_oc_msg_args.
nl_oc_msg_args_min_params = 0 # unsigned number
# (OC) Max code width of Objective-C message before applying nl_oc_msg_args.
nl_oc_msg_args_max_code_width = 0 # unsigned number
# Add or remove newline between function signature and '{'.
nl_fdef_brace = add # ignore/add/remove/force/not_defined
@ -2079,9 +1974,6 @@ nl_cpp_ldef_brace = remove # ignore/add/remove/force/not_defined
# Add or remove newline between 'return' and the return expression.
nl_return_expr = ignore # ignore/add/remove/force/not_defined
# Add or remove newline between 'throw' and the throw expression.
nl_throw_expr = ignore # ignore/add/remove/force/not_defined
# Whether to add a newline after semicolons, except in 'for' statements.
nl_after_semicolon = false # true/false
@ -2090,8 +1982,7 @@ nl_after_semicolon = false # true/false
nl_paren_dbrace_open = ignore # ignore/add/remove/force/not_defined
# Whether to add a newline after the type in an unnamed temporary
# direct-list-initialization, better:
# before a direct-list-initialization.
# direct-list-initialization.
nl_type_brace_init_lst = ignore # ignore/add/remove/force/not_defined
# Whether to add a newline after the open brace in an unnamed temporary
@ -2275,7 +2166,7 @@ nl_max_blank_in_func = 2 # unsigned number
# The number of newlines inside an empty function body.
# This option overrides eat_blanks_after_open_brace and
# eat_blanks_before_close_brace, but is ignored when
# nl_collapse_empty_body_functions=true
# nl_collapse_empty_body=true
nl_inside_empty_func = 0 # unsigned number
# The number of newlines before a function prototype.
@ -2327,6 +2218,12 @@ nl_after_func_body_class = 2 # unsigned number
# Overrides nl_after_func_body and nl_after_func_body_class.
nl_after_func_body_one_liner = 0 # unsigned number
# The number of blank lines after a block of variable definitions at the top
# of a function body.
#
# 0: No change (default).
nl_func_var_def_blk = 0 # unsigned number
# The number of newlines before a block of typedefs. If nl_after_access_spec
# is non-zero, that option takes precedence.
#
@ -2343,27 +2240,15 @@ nl_typedef_blk_end = 0 # unsigned number
# 0: No change (default).
nl_typedef_blk_in = 0 # unsigned number
# The minimum number of blank lines after a block of variable definitions
# at the top of a function body. If any preprocessor directives appear
# between the opening brace of the function and the variable block, then
# it is considered as not at the top of the function.Newlines are added
# before trailing preprocessor directives, if any exist.
#
# 0: No change (default).
nl_var_def_blk_end_func_top = 0 # unsigned number
# The minimum number of empty newlines before a block of variable definitions
# not at the top of a function body. If nl_after_access_spec is non-zero,
# that option takes precedence. Newlines are not added at the top of the
# file or just after an opening brace. Newlines are added above any
# preprocessor directives before the block.
# The number of newlines before a block of variable definitions not at the top
# of a function body. If nl_after_access_spec is non-zero, that option takes
# precedence.
#
# 0: No change (default).
nl_var_def_blk_start = 0 # unsigned number
# The minimum number of empty newlines after a block of variable definitions
# not at the top of a function body. Newlines are not added if the block
# is at the bottom of the file or just before a preprocessor directive.
# The number of newlines after a block of variable definitions not at the top
# of a function body.
#
# 0: No change (default).
nl_var_def_blk_end = 0 # unsigned number
@ -2393,13 +2278,13 @@ nl_after_multiline_comment = false # true/false
nl_after_label_colon = false # true/false
# The number of newlines before a struct definition.
nl_before_struct = 1 # unsigned number
nl_before_struct = 0 # unsigned number
# The number of newlines after '}' or ';' of a struct/enum/union definition.
nl_after_struct = 0 # unsigned number
# The number of newlines before a class definition.
nl_before_class = 1 # unsigned number
nl_before_class = 0 # unsigned number
# The number of newlines after '}' or ';' of a class definition.
nl_after_class = 0 # unsigned number
@ -2690,22 +2575,6 @@ align_assign_func_proto_span = 1 # unsigned number
# 0: No limit (default).
align_assign_thresh = 0 # number
# Whether to align on the left most assignment when multiple
# definitions are found on the same line.
# Depends on 'align_assign_span' and 'align_assign_thresh' settings.
align_assign_on_multi_var_defs = true # true/false
# The span for aligning on '{' in braced init list.
#
# 0: Don't align (default).
align_braced_init_list_span = 0 # unsigned number
# The threshold for aligning on '{' in braced init list.
# Use a negative number for absolute thresholds.
#
# 0: No limit (default).
align_braced_init_list_thresh = 0 # number
# How to apply align_assign_span to function declaration "assignments", i.e.
# 'virtual void foo() = 0' or '~foo() = {default|delete}'.
#
@ -2867,16 +2736,9 @@ align_single_line_brace_gap = 0 # unsigned number
# 0: Don't align (default).
align_oc_msg_spec_span = 0 # unsigned number
# Whether and how to align backslashes that split a macro onto multiple lines.
# This will not work right if the macro contains a multi-line comment.
#
# 0: Do nothing (default)
# 1: Align the backslashes in the column at the end of the longest line
# 2: Align with the backslash that is farthest to the left, or, if that
# backslash is farther left than the end of the longest line, at the end of
# the longest line
# 3: Align with the backslash that is farthest to the right
align_nl_cont = 0 # unsigned number
# Whether to align macros wrapped with a backslash and a newline. This will
# not work right if the macro contains a multi-line comment.
align_nl_cont = false # true/false
# Whether to align macro functions and variables together.
align_pp_define_together = false # true/false
@ -2918,7 +2780,7 @@ align_oc_decl_colon = false # true/false
# (OC) Whether to not align parameters in an Objectve-C message call if first
# colon is not on next line of the message call (the same way Xcode does
# alignment)
# aligment)
align_oc_msg_colon_xcode_like = false # true/false
#
@ -2978,7 +2840,7 @@ cmt_convert_tab_to_spaces = false # true/false
# keyword substitution and leading chars.
#
# Default: true
cmt_indent_multi = false # true/false
cmt_indent_multi = true # true/false
# Whether to align doxygen javadoc-style tags ('@param', '@return', etc.)
# and corresponding fields such that groups of consecutive block tags,
@ -2986,7 +2848,7 @@ cmt_indent_multi = false # true/false
# which is specified by the cmt_sp_after_star_cont. If cmt_width > 0, it may
# be necessary to enable cmt_indent_multi and set cmt_reflow_mode = 2
# in order to achieve the desired alignment for line-wrapping.
cmt_align_doxygen_javadoc_tags = true # true/false
cmt_align_doxygen_javadoc_tags = false # true/false
# The number of spaces to insert after the star and before doxygen
# javadoc-style tags (@param, @return, etc). Requires enabling
@ -2997,7 +2859,7 @@ cmt_align_doxygen_javadoc_tags = true # true/false
cmt_sp_before_doxygen_javadoc_tags = 1 # unsigned number
# Whether to change trailing, single-line c-comments into cpp-comments.
cmt_trailing_single_line_c_to_cpp = true # true/false
cmt_trailing_single_line_c_to_cpp = true # true/false
# Whether to group c-comments that look like they are in a block.
cmt_c_group = false # true/false
@ -3028,10 +2890,10 @@ cmt_cpp_nl_start = false # true/false
cmt_cpp_nl_end = false # true/false
# Whether to put a star on subsequent comment lines.
cmt_star_cont = false # true/false
cmt_star_cont = true # true/false
# The number of spaces to insert at the start of subsequent comment lines.
cmt_sp_before_star_cont = 1 # unsigned number
cmt_sp_before_star_cont = 0 # unsigned number
# The number of spaces to insert after the star on subsequent comment lines.
cmt_sp_after_star_cont = 1 # unsigned number
@ -3118,17 +2980,12 @@ mod_full_brace_function = ignore # ignore/add/remove/force/not_defined
mod_full_brace_if = add # ignore/add/remove/force/not_defined
# Whether to enforce that all blocks of an 'if'/'else if'/'else' chain either
# have, or do not have, braces. Overrides mod_full_brace_if.
# have, or do not have, braces. If true, braces will be added if any block
# needs braces, and will only be removed if they can be removed from all
# blocks.
#
# 0: Don't override mod_full_brace_if
# 1: Add braces to all blocks if any block needs braces and remove braces if
# they can be removed from all blocks
# 2: Add braces to all blocks if any block already has braces, regardless of
# whether it needs them
# 3: Add braces to all blocks if any block needs braces and remove braces if
# they can be removed from all blocks, except if all blocks have braces
# despite none needing them
mod_full_brace_if_chain = 0 # unsigned number
# Overrides mod_full_brace_if.
mod_full_brace_if_chain = false # true/false
# Whether to add braces to all blocks of an 'if'/'else if'/'else' chain.
# If true, mod_full_brace_if_chain will only remove braces from an 'if' that
@ -3160,12 +3017,9 @@ mod_full_brace_nl = 0 # unsigned number
# mod_full_brace_function
mod_full_brace_nl_block_rem_mlcond = false # true/false
# Add or remove unnecessary parentheses on 'return' statement.
# Add or remove unnecessary parenthesis on 'return' statement.
mod_paren_on_return = add # ignore/add/remove/force/not_defined
# Add or remove unnecessary parentheses on 'throw' statement.
mod_paren_on_throw = ignore # ignore/add/remove/force/not_defined
# (Pawn) Whether to change optional semicolons to real semicolons.
mod_pawn_semicolon = false # true/false
@ -3173,26 +3027,12 @@ mod_pawn_semicolon = false # true/false
# statement, as in 'if (a && b > c)' => 'if (a && (b > c))'.
mod_full_paren_if_bool = true # true/false
# Whether to fully parenthesize Boolean expressions after '='
# statement, as in 'x = a && b > c;' => 'x = (a && (b > c));'.
mod_full_paren_assign_bool = true # true/false
# Whether to fully parenthesize Boolean expressions after '='
# statement, as in 'return a && b > c;' => 'return (a && (b > c));'.
mod_full_paren_return_bool = true # true/false
# Whether to remove superfluous semicolons.
mod_remove_extra_semicolon = true # true/false
# Whether to remove duplicate include.
mod_remove_duplicate_include = true # true/false
# the following options (mod_XX_closebrace_comment) use different comment,
# depending of the setting of the next option.
# false: Use the c comment (default)
# true : Use the cpp comment
mod_add_force_c_closebrace_comment = false # true/false
# If a function body exceeds the specified number of newlines and doesn't have
# a comment after the close brace, a comment will be added.
mod_add_long_function_closebrace_comment = 20 # unsigned number
@ -3254,10 +3094,6 @@ mod_sort_incl_import_grouping_enabled = false # true/false
# the close brace, as in 'case X: { ... } break;' => 'case X: { ... break; }'.
mod_move_case_break = false # true/false
# Whether to move a 'return' that appears after a fully braced 'case' before
# the close brace, as in 'case X: { ... } return;' => 'case X: { ... return; }'.
mod_move_case_return = false # true/false
# Add or remove braces around a fully braced case statement. Will only remove
# braces if there are no variable declarations in the block.
mod_case_brace = ignore # ignore/add/remove/force/not_defined
@ -3269,49 +3105,6 @@ mod_remove_empty_return = false # true/false
# Add or remove the comma after the last value of an enumeration.
mod_enum_last_comma = ignore # ignore/add/remove/force/not_defined
# Syntax to use for infinite loops.
#
# 0: Leave syntax alone (default)
# 1: Rewrite as `for(;;)`
# 2: Rewrite as `while(true)`
# 3: Rewrite as `do`...`while(true);`
# 4: Rewrite as `while(1)`
# 5: Rewrite as `do`...`while(1);`
#
# Infinite loops that do not already match one of these syntaxes are ignored.
# Other options that affect loop formatting will be applied after transforming
# the syntax.
mod_infinite_loop = 0 # unsigned number
# Add or remove the 'int' keyword in 'int short'.
mod_int_short = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'short int'.
mod_short_int = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'int long'.
mod_int_long = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'long int'.
mod_long_int = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'int signed'.
mod_int_signed = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'signed int'.
mod_signed_int = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'int unsigned'.
mod_int_unsigned = ignore # ignore/add/remove/force/not_defined
# Add or remove the 'int' keyword in 'unsigned int'.
mod_unsigned_int = ignore # ignore/add/remove/force/not_defined
# If there is a situation where mod_int_* and mod_*_int would result in
# multiple int keywords, whether to keep the rightmost int (the default) or the
# leftmost int.
mod_int_prefer_int_on_left = false # true/false
# (OC) Whether to organize the properties. If true, properties will be
# rearranged according to the mod_sort_oc_property_*_weight factors.
mod_sort_oc_properties = false # true/false
@ -3343,16 +3136,6 @@ mod_sort_oc_property_nullability_weight = 0 # number
# Preprocessor options
#
# How to use tabs when indenting preprocessor code.
#
# -1: Use 'indent_with_tabs' setting (default)
# 0: Spaces only
# 1: Indent with tabs to brace level, align with spaces
# 2: Indent and align with tabs, using spaces when not on a tabstop
#
# Default: -1
pp_indent_with_tabs = -1 # number
# Add or remove indentation of preprocessor directives inside #if blocks
# at brace level 0 (file-level).
pp_indent = ignore # ignore/add/remove/force/not_defined
@ -3361,10 +3144,6 @@ pp_indent = ignore # ignore/add/remove/force/not_defined
# indented from column 1.
pp_indent_at_level = true # true/false
# Whether to indent #if/#else/#endif at the parenthesis level if the brace
# level is 0. If false, these are indented from column 1.
pp_indent_at_level0 = false # true/false
# Specifies the number of columns to indent preprocessors per level
# at brace level 0 (file-level). If pp_indent_at_level=false, also specifies
# the number of columns to indent preprocessors per level
@ -3373,11 +3152,10 @@ pp_indent_at_level0 = false # true/false
# Default: 1
pp_indent_count = 4 # unsigned number
# Add or remove space after # based on pp level of #if blocks.
pp_space = remove # compat
pp_space_after = remove # ignore/add/remove/force/not_defined
# Add or remove space after # based on pp_level of #if blocks.
pp_space = remove # ignore/add/remove/force/not_defined
# Sets the number of spaces per level added with pp_space_after.
# Sets the number of spaces per level added with pp_space.
pp_space_count = 0 # unsigned number
# The indent for '#region' and '#endregion' in C# and '#pragma region' in
@ -3410,70 +3188,33 @@ pp_include_at_level = false # true/false
# Whether to ignore the '#define' body while formatting.
pp_ignore_define_body = false # true/false
# An offset value that controls the indentation of the body of a multiline #define.
# 'body' refers to all the lines of a multiline #define except the first line.
# Requires 'pp_ignore_define_body = false'.
#
# <0: Absolute column: the body indentation starts off at the specified column
# (ex. -3 ==> the body is indented starting from column 3)
# >=0: Relative to the column of the '#' of '#define'
# (ex. 3 ==> the body is indented starting 3 columns at the right of '#')
#
# Default: 8
pp_multiline_define_body_indent = 8 # number
# Whether to indent case statements between #if, #else, and #endif.
# Only applies to the indent of the preprocessor that the case statements
# Only applies to the indent of the preprocesser that the case statements
# directly inside of.
#
# Default: true
pp_indent_case = true # true/false
# Whether to indent whole function definitions between #if, #else, and #endif.
# Only applies to the indent of the preprocessor that the function definition
# Only applies to the indent of the preprocesser that the function definition
# is directly inside of.
#
# Default: true
pp_indent_func_def = true # true/false
# Whether to indent extern C blocks between #if, #else, and #endif.
# Only applies to the indent of the preprocessor that the extern block is
# Only applies to the indent of the preprocesser that the extern block is
# directly inside of.
#
# Default: true
pp_indent_extern = true # true/false
# How to indent braces directly inside #if, #else, and #endif.
# Requires pp_if_indent_code=true and only applies to the indent of the
# preprocessor that the braces are directly inside of.
# 0: No extra indent
# 1: Indent by one level
# -1: Preserve original indentation
# Whether to indent braces directly inside #if, #else, and #endif.
# Only applies to the indent of the preprocesser that the braces are directly
# inside of.
#
# Default: 1
pp_indent_brace = 1 # number
# Whether to print warning messages for unbalanced #if and #else blocks.
# This will print a message in the following cases:
# - if an #ifdef block ends on a different indent level than
# where it started from. Example:
#
# #ifdef TEST
# int i;
# {
# int j;
# #endif
#
# - an #elif/#else block ends on a different indent level than
# the corresponding #ifdef block. Example:
#
# #ifdef TEST
# int i;
# #else
# }
# int j;
# #endif
pp_warn_unbalanced_if = false # true/false
# Default: true
pp_indent_brace = true # true/false
#
# Sort includes options
@ -3512,16 +3253,17 @@ use_indent_func_call_param = true # true/false
#
# true: indent_continue will be used only once
# false: indent_continue will be used every time (default)
#
# Requires indent_ignore_first_continue=false.
use_indent_continue_only_once = false # true/false
# The indentation can be:
# - after the assignment, at the '[' character
# - at the beginning of the lambda body
# The value might be used twice:
# - at the assignment
# - at the opening brace
#
# true: indentation will be at the beginning of the lambda body
# false: indentation will be after the assignment (default)
# To prevent the double use of the indentation value, use this option with the
# value 'true'.
#
# true: indentation will be used only once
# false: indentation will be used every time (default)
indent_cpp_lambda_only_once = true # true/false
# Whether sp_after_angle takes precedence over sp_inside_fparen. This was the
@ -3573,18 +3315,6 @@ debug_timeout = 0 # number
# 0: do not truncate.
debug_truncate = 0 # unsigned number
# sort (or not) the tracking info.
#
# Default: true
debug_sort_the_tracks = true # true/false
# decode (or not) the flags as a new line.
# only if the -p option is set.
debug_decode_the_flags = false # true/false
# insert the number of the line at the beginning of each line
set_numbering_for_html_output = false # true/false
# Meaning of the settings:
# Ignore - do not do any changes
# Add - makes sure there is 1 or more space/brace/newline/etc
@ -3637,5 +3367,5 @@ set_numbering_for_html_output = false # true/false
# `macro-close END_MESSAGE_MAP`
#
#
# option(s) with 'not default' value: 217
# option(s) with 'not default' value: 193
#

View File

@ -1,57 +1,32 @@
# Минимальная версия CMake, требуемая для сборки проекта
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
# Минимальная версия CMake
cmake_minimum_required(VERSION 3.3)
# Предпочтительно следовать стандартам принятым в указанном диапазоне версий
cmake_policy(VERSION 3.6..3.7)
cmake_policy(VERSION 3.0.2..3.7)
# Название и версия проекта и используемые языки программирования
project(myx-example-features VERSION 0.3.0 LANGUAGES CXX)
project(myx-cmake-example-features VERSION 0.2.0 LANGUAGES CXX)
set(${PROJECT_NAME}_VENDOR unknown)
set(${PROJECT_NAME}_CONTACT unknown)
###
# Обязательные переменные для MyxCMake
###
# Название организации
set(MYX_CMAKE_ORGANIZATION_NAME "Org." CACHE STRING "")
# Рекомендуемый способ подключения MyxCMake
include(cmake/myx_setup.cmake)
# Имя автора
set(MYX_CMAKE_AUTHOR_NAME "John Doe" CACHE STRING "")
# Поиск пакетов
myx_find_required_packages(
Qt5 Core
Qt5Private Core)
# Почта автора
set(MYX_CMAKE_AUTHOR_EMAIL "mail@johndoe.com" CACHE STRING "")
# Цель для создания исполняемого файла
add_executable(${PROJECT_NAME})
# Краткое описание проекта
set(MYX_CMAKE_DESCRIPTION "Пример проекта: разные возможности" CACHE STRING "")
# Настройка свойств цели
myx_target_setup(${PROJECT_NAME}
CPP
${PROJECT_SOURCE_DIR}/src/${PROJECT_NAME}/main.cpp
)
find_package(MyxCMake 0.3.7 REQUIRED)
# Настройка Qt для цели
myx_qt5_target_setup(${PROJECT_NAME}
COMPONENTS Core
PRIVATE Core
PRIVATE_MOC
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/processor.hpp
)
# Qt5
find_package(Qt5 COMPONENTS Core REQUIRED)
# Автоматически генерируемый файл с информацией о репозитории
myx_generate_git_info_header(${PROJECT_NAME} "git_info_p.hpp")
# Автоматически генерируемый приватный заголовочный файл
myx_generate_private_config_header(${PROJECT_NAME} "config_p.hpp")
# Форматирование исходных текстов с помощью uncrustify
myx_uncrustify(${PROJECT_NAME})
# Формирование документации
myx_doc_doxygen(${PROJECT_NAME} HTML YES)
# Создание пакетов
myx_create_packages(${PROJECT_NAME})
# Подключение функций для сопровождения проекта
if(MyxxCMake_DIR)
myxx()
endif()
# Приложение
add_subdirectory(src/myx-cmake-example-features)

View File

@ -1,79 +0,0 @@
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # IN_LIST operator
# CMake выполняет проверку системного окружения с помощью модулей,
# расположенных в следующих каталогах:
# /usr/share/cmake-${CMAKE_VERSION}/Modules
# /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/cmake
# /usr/lib/cmake
# Если для используемой программы или библиотеки нет стандартного
# модуля для поиска, то можно использовать собственный.
# С помощью переменной `CMAKE_MODULE_PATH` указывается перечень
# дополнительных каталогов, в которых производится поиск модулей.
set(MYX_CMAKE_FIND_DIR "${PROJECT_SOURCE_DIR}/cmake/find")
if(IS_DIRECTORY "${MYX_CMAKE_FIND_DIR}")
if(NOT ${MYX_CMAKE_FIND_DIR} IN_LIST CMAKE_MODULE_PATH)
list(INSERT CMAKE_MODULE_PATH 0 "${MYX_CMAKE_FIND_DIR}")
endif()
endif()
get_filename_component(MYX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
set(MYX_CMAKE_BACKPORTS_DIR "${MYX_CMAKE_SOURCE_DIR}/backports")
set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib")
# Модули для обеспечения обратной совместимости со старыми версиями CMake
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
include(${MYX_CMAKE_BACKPORTS_DIR}/FetchContent.cmake)
else()
include(FetchContent)
endif()
# Загрузка стандартных модулей
include(GNUInstallDirs)
include(CMakeDependentOption)
# Полезные макросы
include(${MYX_CMAKE_LIB_DIR}/macro/CreateSymlink.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/FindPackages.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/InstallRelative.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/CheckEnableCxxCompilerFlag.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/GTest.cmake)
include(${MYX_CMAKE_LIB_DIR}/macro/QTest.cmake)
include(${MYX_CMAKE_LIB_DIR}/ColoredMessages.cmake)
include(${MYX_CMAKE_LIB_DIR}/PopulateCMakeBinaryDir.cmake)
include(${MYX_CMAKE_LIB_DIR}/CurrentDate.cmake)
include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWarning.cmake)
include(${MYX_CMAKE_LIB_DIR}/DirectoriesGuards.cmake)
include(${MYX_CMAKE_LIB_DIR}/SemanticProjectVersion.cmake)
include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWrapper.cmake)
include(${MYX_CMAKE_LIB_DIR}/AddExternalTarget.cmake)
include(${MYX_CMAKE_LIB_DIR}/FetchContentAdd.cmake)
set(MYX_CMAKE_TOOLCHAINS_DIR "${MYX_CMAKE_LIB_DIR}/toolchains")
include(${MYX_CMAKE_LIB_DIR}/Toolchains.cmake)
unset(MYX_CMAKE_TOOLCHAINS_DIR)
include(${MYX_CMAKE_LIB_DIR}/AddExecutable.cmake)
include(${MYX_CMAKE_LIB_DIR}/AddInterfaceLibrary.cmake)
include(${MYX_CMAKE_LIB_DIR}/AddObjectLibrary.cmake)
include(${MYX_CMAKE_LIB_DIR}/TargetSetup.cmake)
include(${MYX_CMAKE_LIB_DIR}/Qt5TargetSetup.cmake)
include(${MYX_CMAKE_LIB_DIR}/uncrustify/Uncrustify.cmake)
include(${MYX_CMAKE_LIB_DIR}/doc/Doxygen.cmake)
include(${MYX_CMAKE_LIB_DIR}/generators/PrivateConfigHeader.cmake)
include(${MYX_CMAKE_LIB_DIR}/generators/GitInfoHeader.cmake)
include(${MYX_CMAKE_LIB_DIR}/CreatePackages.cmake)
include(${MYX_CMAKE_LIB_DIR}/Uninstall.cmake)
unset(MYX_CMAKE_SOURCE_DIR)
unset(MYX_CMAKE_BACKPORTS_DIR)
unset(MYX_CMAKE_LIB_DIR)
cmake_policy(POP)

View File

@ -1,9 +0,0 @@
set(MYX_CMAKE_PACKAGE_VERSION "2.3.8")
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View File

@ -1,486 +0,0 @@
include_guard(GLOBAL)
set(__FetchContent_privateDir "${CMAKE_CURRENT_LIST_DIR}/FetchContent")
#=======================================================================
# Recording and retrieving content details for later population
#=======================================================================
# Internal use, projects must not call this directly. It is
# intended for use by FetchContent_Declare() only.
#
# Sets a content-specific global property (not meant for use
# outside of functions defined here in this file) which can later
# be retrieved using __FetchContent_getSavedDetails() with just the
# same content name. If there is already a value stored in the
# property, it is left unchanged and this call has no effect.
# This allows parent projects to define the content details,
# overriding anything a child project may try to set (properties
# are not cached between runs, so the first thing to set it in a
# build will be in control).
function(__FetchContent_declareDetails contentName)
string(TOLOWER ${contentName} contentNameLower)
set(propertyName "_FetchContent_${contentNameLower}_savedDetails")
get_property(alreadyDefined GLOBAL PROPERTY ${propertyName} DEFINED)
if(NOT alreadyDefined)
define_property(GLOBAL PROPERTY ${propertyName}
BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
)
set_property(GLOBAL PROPERTY ${propertyName} ${ARGN})
endif()
endfunction()
# Internal use, projects must not call this directly. It is
# intended for use by the FetchContent_Declare() function.
#
# Retrieves details saved for the specified content in an
# earlier call to __FetchContent_declareDetails().
function(__FetchContent_getSavedDetails contentName outVar)
string(TOLOWER ${contentName} contentNameLower)
set(propertyName "_FetchContent_${contentNameLower}_savedDetails")
get_property(alreadyDefined GLOBAL PROPERTY ${propertyName} DEFINED)
if(NOT alreadyDefined)
message(FATAL_ERROR "No content details recorded for ${contentName}")
endif()
get_property(propertyValue GLOBAL PROPERTY ${propertyName})
set(${outVar} "${propertyValue}" PARENT_SCOPE)
endfunction()
# Saves population details of the content, sets defaults for the
# SOURCE_DIR and BUILD_DIR.
function(FetchContent_Declare contentName)
set(options "")
set(oneValueArgs SVN_REPOSITORY)
set(multiValueArgs "")
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
unset(srcDirSuffix)
unset(svnRepoArgs)
if(ARG_SVN_REPOSITORY)
# Add a hash of the svn repository URL to the source dir. This works
# around the problem where if the URL changes, the download would
# fail because it tries to checkout/update rather than switch the
# old URL to the new one. We limit the hash to the first 7 characters
# so that the source path doesn't get overly long (which can be a
# problem on windows due to path length limits).
string(SHA1 urlSHA ${ARG_SVN_REPOSITORY})
string(SUBSTRING ${urlSHA} 0 7 urlSHA)
set(srcDirSuffix "-${urlSHA}")
set(svnRepoArgs SVN_REPOSITORY ${ARG_SVN_REPOSITORY})
endif()
string(TOLOWER ${contentName} contentNameLower)
__FetchContent_declareDetails(
${contentNameLower}
SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src${srcDirSuffix}"
BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build"
${svnRepoArgs}
# List these last so they can override things we set above
${ARG_UNPARSED_ARGUMENTS}
)
endfunction()
#=======================================================================
# Set/get whether the specified content has been populated yet.
# The setter also records the source and binary dirs used.
#=======================================================================
# Internal use, projects must not call this directly. It is
# intended for use by the FetchContent_Populate() function to
# record when FetchContent_Populate() is called for a particular
# content name.
function(__FetchContent_setPopulated contentName sourceDir binaryDir)
string(TOLOWER ${contentName} contentNameLower)
set(prefix "_FetchContent_${contentNameLower}")
set(propertyName "${prefix}_sourceDir")
define_property(GLOBAL PROPERTY ${propertyName}
BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
)
set_property(GLOBAL PROPERTY ${propertyName} ${sourceDir})
set(propertyName "${prefix}_binaryDir")
define_property(GLOBAL PROPERTY ${propertyName}
BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
)
set_property(GLOBAL PROPERTY ${propertyName} ${binaryDir})
set(propertyName "${prefix}_populated")
define_property(GLOBAL PROPERTY ${propertyName}
BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
)
set_property(GLOBAL PROPERTY ${propertyName} True)
endfunction()
# Set variables in the calling scope for any of the retrievable
# properties. If no specific properties are requested, variables
# will be set for all retrievable properties.
#
# This function is intended to also be used by projects as the canonical
# way to detect whether they should call FetchContent_Populate()
# and pull the populated source into the build with add_subdirectory(),
# if they are using the populated content in that way.
function(FetchContent_GetProperties contentName)
string(TOLOWER ${contentName} contentNameLower)
set(options "")
set(oneValueArgs SOURCE_DIR BINARY_DIR POPULATED)
set(multiValueArgs "")
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT ARG_SOURCE_DIR AND
NOT ARG_BINARY_DIR AND
NOT ARG_POPULATED)
# No specific properties requested, provide them all
set(ARG_SOURCE_DIR ${contentNameLower}_SOURCE_DIR)
set(ARG_BINARY_DIR ${contentNameLower}_BINARY_DIR)
set(ARG_POPULATED ${contentNameLower}_POPULATED)
endif()
set(prefix "_FetchContent_${contentNameLower}")
if(ARG_SOURCE_DIR)
set(propertyName "${prefix}_sourceDir")
get_property(value GLOBAL PROPERTY ${propertyName})
if(value)
set(${ARG_SOURCE_DIR} ${value} PARENT_SCOPE)
endif()
endif()
if(ARG_BINARY_DIR)
set(propertyName "${prefix}_binaryDir")
get_property(value GLOBAL PROPERTY ${propertyName})
if(value)
set(${ARG_BINARY_DIR} ${value} PARENT_SCOPE)
endif()
endif()
if(ARG_POPULATED)
set(propertyName "${prefix}_populated")
get_property(value GLOBAL PROPERTY ${propertyName} DEFINED)
set(${ARG_POPULATED} ${value} PARENT_SCOPE)
endif()
endfunction()
#=======================================================================
# Performing the population
#=======================================================================
# The value of contentName will always have been lowercased by the caller.
# All other arguments are assumed to be options that are understood by
# ExternalProject_Add(), except for QUIET and SUBBUILD_DIR.
function(__FetchContent_directPopulate contentName)
set(options
QUIET
)
set(oneValueArgs
SUBBUILD_DIR
SOURCE_DIR
BINARY_DIR
# We need special processing if DOWNLOAD_NO_EXTRACT is true
DOWNLOAD_NO_EXTRACT
# Prevent the following from being passed through
CONFIGURE_COMMAND
BUILD_COMMAND
INSTALL_COMMAND
TEST_COMMAND
# We force both of these to be ON since we are always executing serially
# and we want all steps to have access to the terminal in case they
# need input from the command line (e.g. ask for a private key password)
# or they want to provide timely progress. We silently absorb and
# discard these if they are set by the caller.
USES_TERMINAL_DOWNLOAD
USES_TERMINAL_UPDATE
)
set(multiValueArgs "")
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT ARG_SUBBUILD_DIR)
message(FATAL_ERROR "Internal error: SUBBUILD_DIR not set")
elseif(NOT IS_ABSOLUTE "${ARG_SUBBUILD_DIR}")
set(ARG_SUBBUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_SUBBUILD_DIR}")
endif()
if(NOT ARG_SOURCE_DIR)
message(FATAL_ERROR "Internal error: SOURCE_DIR not set")
elseif(NOT IS_ABSOLUTE "${ARG_SOURCE_DIR}")
set(ARG_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_SOURCE_DIR}")
endif()
if(NOT ARG_BINARY_DIR)
message(FATAL_ERROR "Internal error: BINARY_DIR not set")
elseif(NOT IS_ABSOLUTE "${ARG_BINARY_DIR}")
set(ARG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_BINARY_DIR}")
endif()
# Ensure the caller can know where to find the source and build directories
# with some convenient variables. Doing this here ensures the caller sees
# the correct result in the case where the default values are overridden by
# the content details set by the project.
set(${contentName}_SOURCE_DIR "${ARG_SOURCE_DIR}" PARENT_SCOPE)
set(${contentName}_BINARY_DIR "${ARG_BINARY_DIR}" PARENT_SCOPE)
# The unparsed arguments may contain spaces, so build up ARG_EXTRA
# in such a way that it correctly substitutes into the generated
# CMakeLists.txt file with each argument quoted.
unset(ARG_EXTRA)
foreach(arg IN LISTS ARG_UNPARSED_ARGUMENTS)
set(ARG_EXTRA "${ARG_EXTRA} \"${arg}\"")
endforeach()
if(ARG_DOWNLOAD_NO_EXTRACT)
set(ARG_EXTRA "${ARG_EXTRA} DOWNLOAD_NO_EXTRACT YES")
set(__FETCHCONTENT_COPY_FILE
"
ExternalProject_Get_Property(${contentName}-populate DOWNLOADED_FILE)
get_filename_component(dlFileName \"\${DOWNLOADED_FILE}\" NAME)
ExternalProject_Add_Step(${contentName}-populate copyfile
COMMAND \"${CMAKE_COMMAND}\" -E copy_if_different
\"<DOWNLOADED_FILE>\" \"${ARG_SOURCE_DIR}\"
DEPENDEES patch
DEPENDERS configure
BYPRODUCTS \"${ARG_SOURCE_DIR}/\${dlFileName}\"
COMMENT \"Copying file to SOURCE_DIR\"
)
")
else()
unset(__FETCHCONTENT_COPY_FILE)
endif()
# Hide output if requested, but save it to a variable in case there's an
# error so we can show the output upon failure. When not quiet, don't
# capture the output to a variable because the user may want to see the
# output as it happens (e.g. progress during long downloads). Combine both
# stdout and stderr in the one capture variable so the output stays in order.
if (ARG_QUIET)
set(outputOptions
OUTPUT_VARIABLE capturedOutput
ERROR_VARIABLE capturedOutput
)
else()
set(capturedOutput)
set(outputOptions)
message(STATUS "Populating ${contentName}")
endif()
if(CMAKE_GENERATOR)
set(subCMakeOpts "-G${CMAKE_GENERATOR}")
if(CMAKE_GENERATOR_PLATFORM)
list(APPEND subCMakeOpts "-A${CMAKE_GENERATOR_PLATFORM}")
endif()
if(CMAKE_GENERATOR_TOOLSET)
list(APPEND subCMakeOpts "-T${CMAKE_GENERATOR_TOOLSET}")
endif()
if(CMAKE_MAKE_PROGRAM)
list(APPEND subCMakeOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
endif()
else()
# Likely we've been invoked via CMake's script mode where no
# generator is set (and hence CMAKE_MAKE_PROGRAM could not be
# trusted even if provided). We will have to rely on being
# able to find the default generator and build tool.
unset(subCMakeOpts)
endif()
# Create and build a separate CMake project to carry out the population.
# If we've already previously done these steps, they will not cause
# anything to be updated, so extra rebuilds of the project won't occur.
# Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project
# has this set to something not findable on the PATH.
configure_file("${__FetchContent_privateDir}/CMakeLists.cmake.in"
"${ARG_SUBBUILD_DIR}/CMakeLists.txt")
execute_process(
COMMAND ${CMAKE_COMMAND} ${subCMakeOpts} .
RESULT_VARIABLE result
${outputOptions}
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
)
if(result)
if(capturedOutput)
message("${capturedOutput}")
endif()
message(FATAL_ERROR "CMake step for ${contentName} failed: ${result}")
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
${outputOptions}
WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
)
if(result)
if(capturedOutput)
message("${capturedOutput}")
endif()
message(FATAL_ERROR "Build step for ${contentName} failed: ${result}")
endif()
endfunction()
option(FETCHCONTENT_FULLY_DISCONNECTED "Disables all attempts to download or update content and assumes source dirs already exist")
option(FETCHCONTENT_UPDATES_DISCONNECTED "Enables UPDATE_DISCONNECTED behavior for all content population")
option(FETCHCONTENT_QUIET "Enables QUIET option for all content population" ON)
set(FETCHCONTENT_BASE_DIR "${CMAKE_BINARY_DIR}/_deps" CACHE PATH "Directory under which to collect all populated content")
# Populate the specified content using details stored from
# an earlier call to FetchContent_Declare().
function(FetchContent_Populate contentName)
if(NOT contentName)
message(FATAL_ERROR "Empty contentName not allowed for FetchContent_Populate()")
endif()
string(TOLOWER ${contentName} contentNameLower)
if(ARGN)
# This is the direct population form with details fully specified
# as part of the call, so we already have everything we need
__FetchContent_directPopulate(
${contentNameLower}
SUBBUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${contentNameLower}-subbuild"
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${contentNameLower}-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${contentNameLower}-build"
${ARGN} # Could override any of the above ..._DIR variables
)
# Pass source and binary dir variables back to the caller
set(${contentNameLower}_SOURCE_DIR "${${contentNameLower}_SOURCE_DIR}" PARENT_SCOPE)
set(${contentNameLower}_BINARY_DIR "${${contentNameLower}_BINARY_DIR}" PARENT_SCOPE)
# Don't set global properties, or record that we did this population, since
# this was a direct call outside of the normal declared details form.
# We only want to save values in the global properties for content that
# honours the hierarchical details mechanism so that projects are not
# robbed of the ability to override details set in nested projects.
return()
endif()
# No details provided, so assume they were saved from an earlier call
# to FetchContent_Declare(). Do a check that we haven't already
# populated this content before in case the caller forgot to check.
FetchContent_GetProperties(${contentName})
if(${contentNameLower}_POPULATED)
message(FATAL_ERROR "Content ${contentName} already populated in ${${contentNameLower}_SOURCE_DIR}")
endif()
string(TOUPPER ${contentName} contentNameUpper)
set(FETCHCONTENT_SOURCE_DIR_${contentNameUpper}
"${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}"
CACHE PATH "When not empty, overrides where to find pre-populated content for ${contentName}")
if(FETCHCONTENT_SOURCE_DIR_${contentNameUpper})
# The source directory has been explicitly provided in the cache,
# so no population is required
set(${contentNameLower}_SOURCE_DIR "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
set(${contentNameLower}_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build")
elseif(FETCHCONTENT_FULLY_DISCONNECTED)
# Bypass population and assume source is already there from a previous run
set(${contentNameLower}_SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src")
set(${contentNameLower}_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build")
else()
# Support both a global "disconnect all updates" and a per-content
# update test (either one being set disables updates for this content).
option(FETCHCONTENT_UPDATES_DISCONNECTED_${contentNameUpper}
"Enables UPDATE_DISCONNECTED behavior just for population of ${contentName}")
if(FETCHCONTENT_UPDATES_DISCONNECTED OR
FETCHCONTENT_UPDATES_DISCONNECTED_${contentNameUpper})
set(disconnectUpdates True)
else()
set(disconnectUpdates False)
endif()
if(FETCHCONTENT_QUIET)
set(quietFlag QUIET)
else()
unset(quietFlag)
endif()
__FetchContent_getSavedDetails(${contentName} contentDetails)
if("${contentDetails}" STREQUAL "")
message(FATAL_ERROR "No details have been set for content: ${contentName}")
endif()
__FetchContent_directPopulate(
${contentNameLower}
${quietFlag}
UPDATE_DISCONNECTED ${disconnectUpdates}
SUBBUILD_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-subbuild"
SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src"
BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build"
# Put the saved details last so they can override any of the
# the options we set above (this can include SOURCE_DIR or
# BUILD_DIR)
${contentDetails}
)
endif()
__FetchContent_setPopulated(
${contentName}
${${contentNameLower}_SOURCE_DIR}
${${contentNameLower}_BINARY_DIR}
)
# Pass variables back to the caller. The variables passed back here
# must match what FetchContent_GetProperties() sets when it is called
# with just the content name.
set(${contentNameLower}_SOURCE_DIR "${${contentNameLower}_SOURCE_DIR}" PARENT_SCOPE)
set(${contentNameLower}_BINARY_DIR "${${contentNameLower}_BINARY_DIR}" PARENT_SCOPE)
set(${contentNameLower}_POPULATED True PARENT_SCOPE)
endfunction()
# Arguments are assumed to be the names of dependencies that have been
# declared previously and should be populated. It is not an error if
# any of them have already been populated (they will just be skipped in
# that case). The command is implemented as a macro so that the variables
# defined by the FetchContent_GetProperties() and FetchContent_Populate()
# calls will be available to the caller.
macro(FetchContent_MakeAvailable)
foreach(contentName IN ITEMS ${ARGV})
string(TOLOWER ${contentName} contentNameLower)
FetchContent_GetProperties(${contentName})
if(NOT ${contentNameLower}_POPULATED)
FetchContent_Populate(${contentName})
# Only try to call add_subdirectory() if the populated content
# can be treated that way. Protecting the call with the check
# allows this function to be used for projects that just want
# to ensure the content exists, such as to provide content at
# a known location.
if(EXISTS ${${contentNameLower}_SOURCE_DIR}/CMakeLists.txt)
add_subdirectory(${${contentNameLower}_SOURCE_DIR}
${${contentNameLower}_BINARY_DIR})
endif()
endif()
endforeach()
endmacro()

View File

@ -1,28 +0,0 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION ${CMAKE_VERSION})
# We name the project and the target for the ExternalProject_Add() call
# to something that will highlight to the user what we are working on if
# something goes wrong and an error message is produced.
project(${contentName}-populate NONE)
@__FETCHCONTENT_CACHED_INFO@
include(ExternalProject)
ExternalProject_Add(${contentName}-populate
${ARG_EXTRA}
SOURCE_DIR "${ARG_SOURCE_DIR}"
BINARY_DIR "${ARG_BINARY_DIR}"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
USES_TERMINAL_DOWNLOAD YES
USES_TERMINAL_UPDATE YES
USES_TERMINAL_PATCH YES
)
@__FETCHCONTENT_COPY_FILE@

View File

@ -1,12 +0,0 @@
# Защита для однократного включения файла *.cmake
# Функция include_guard() реализована в версии 3.10
# Макрос реализован для обратной совместимости
if(${CMAKE_VERSION} VERSION_LESS "3.10.0")
macro(include_guard)
if(CMAKE_FILE_${CMAKE_CURRENT_LIST_FILE}_ALREADY_INCLUDED)
return()
endif()
set(CMAKE_FILE_${CMAKE_CURRENT_LIST_FILE}_ALREADY_INCLUDED TRUE)
endmacro()
endif()

View File

@ -1,11 +0,0 @@
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS 3.21)
get_property(__parent_directory DIRECTORY PROPERTY PARENT_DIRECTORY)
if(NOT __parent_directory)
set(PROJECT_IS_TOP_LEVEL TRUE)
else()
set(PROJECT_IS_TOP_LEVEL FALSE)
endif()
unset(__parent_directory)
endif()

View File

@ -1,22 +0,0 @@
#[=======================================================================[.rst:
myx_add_executable
------------------
Вспомогательная функция для создания исполняемого файла::
myx_add_executable(TARGET_NAME)
Используется для совместимости с версиями CMake раньше 3.11,
в которых было необходимо указать хотя бы один файл с исходными текстами.
#]=======================================================================]
include_guard(GLOBAL)
function(myx_add_executable TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
add_executable(${TARGET_NAME} ${ARGN} "")
else()
add_executable(${TARGET_NAME} ${ARGN})
endif()
endfunction()

View File

@ -1,56 +0,0 @@
#[=======================================================================[.rst:
Обёртки для функции `message()`, которые в терминале UNIX
подсвечивают сообщения в зависимости от важности.
#]=======================================================================]
include_guard(GLOBAL)
if(DEFINED ENV{COLORTERM} AND UNIX)
string(ASCII 27 Esc)
set(MyxColorReset "${Esc}[m")
set(MyxColorBold "${Esc}[1m")
set(MyxColorRed "${Esc}[31m")
set(MyxColorGreen "${Esc}[32m")
set(MyxColorYellow "${Esc}[33m")
set(MyxColorBlue "${Esc}[34m")
set(MyxColorMagenta "${Esc}[35m")
set(MyxColorCyan "${Esc}[36m")
set(MyxColorWhite "${Esc}[37m")
set(MyxColorBoldRed "${Esc}[1;31m")
set(MyxColorBoldGreen "${Esc}[1;32m")
set(MyxColorBoldYellow "${Esc}[1;33m")
set(MyxColorBoldBlue "${Esc}[1;34m")
set(MyxColorBoldMagenta "${Esc}[1;35m")
set(MyxColorBoldCyan "${Esc}[1;36m")
set(MyxColorBoldWhite "${Esc}[1;37m")
endif()
function(myx_message_fatal_error)
message(FATAL_ERROR ${MyxColorBoldRed}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_send_error)
message(SEND_ERROR ${MyxColorBoldRed}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_warning)
message(WARNING ${MyxColorRed}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_deprecation)
message(DEPRECATION ${MyxColorBoldMagenta}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_status)
message(STATUS ${MyxColorMagenta}${ARGV}${MyxColorReset})
endfunction()
function(myx_message_notice)
message(${MyxColorBold}${ARGV}${MyxColorReset})
endfunction()
function(myx_message)
message(${MyxColorReset}${ARGV}${MyxColorReset})
endfunction()

View File

@ -1,194 +0,0 @@
function(myx_create_packages TARGET_NAME)
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
set(options)
set(oneValueArgs DEBIAN_PACKAGE_TYPE CPACK_DEBIAN_PACKAGE_SECTION CPACK_DEBIAN_PACKAGE_PRIORITY
CMAKE_INSTALL_DEFAULT_COMPONENT_NAME CPACK_PACKAGE_CONTACT CPACK_PACKAGING_INSTALL_PREFIX)
set(multiValueArgs CPACK_SOURCE_GENERATOR CPACK_GENERATOR CPACK_SOURCE_IGNORE_FILES)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Общие настройки для пакета: организация, автор, версия
if(NOT ${PROJECT_NAME}_CONTACT)
if(${PROJECT_NAME}_AUTHOR_NAME AND ${PROJECT_NAME}_AUTHOR_EMAIL)
set(CPACK_PACKAGE_CONTACT "${${PROJECT_NAME}_AUTHOR_NAME} <${${PROJECT_NAME}_AUTHOR_EMAIL}>")
else()
set(CPACK_PACKAGE_CONTACT "unknown maintainer <nonexistent@mailbox>")
myx_message_warning("\${PROJECT_NAME}_CONTACT variable is required for packaging but unset")
endif()
else()
set(CPACK_PACKAGE_CONTACT ${${PROJECT_NAME}_CONTACT})
endif()
if(NOT ${PROJECT_NAME}_VENDOR)
if(${PROJECT_NAME}_AUTHOR_NAME)
set(CPACK_PACKAGE_VENDOR "${${PROJECT_NAME}_AUTHOR_NAME}")
else()
set(CPACK_PACKAGE_VENDOR "unknown vendor")
myx_message_warning("\${PROJECT_NAME}_VENDOR variable is required for packaging but unset")
endif()
else()
set(CPACK_PACKAGE_VENDOR ${${PROJECT_NAME}_VENDOR})
endif()
string(TOLOWER ${PROJECT_NAME} PN)
set(CPACK_PACKAGE_NAME ${PN})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
if(NOT CPACK_PACKAGING_INSTALL_PREFIX)
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
endif()
# Параметры для архива исходных текстов
if(NOT ARG_CPACK_SOURCE_GENERATOR)
set(CPACK_SOURCE_GENERATOR "TXZ")
else()
set(ARG_CPACK_SOURCE_GENERATOR ${CPACK_SOURCE_GENERATOR})
endif()
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PN}-${CPACK_PACKAGE_VERSION}")
# Типы генераторов для бинарных архивов
if(NOT ARG_CPACK_GENERATOR)
set(CPACK_GENERATOR "TXZ" "DEB")
else()
set(CPACK_GENERATOR ${ARG_CPACK_GENERATOR})
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
list(REMOVE_ITEM CPACK_GENERATOR "DEB")
endif()
# Параметры для архива собранного проекта
set(CPACK_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CPACK_TARGET_ARCH "amd64")
endif()
set(CPACK_PACKAGE_FILE_NAME "${PN}_${CPACK_PACKAGE_VERSION}")
# Список масок для исключения из архива исходных текстов
set(CPACK_SOURCE_IGNORE_FILES
${ARG_CPACK_SOURCE_IGNORE_FILES}
${CMAKE_BINARY_DIR}
"^${CMAKE_SOURCE_DIR}/.?build.?/"
"^${CMAKE_SOURCE_DIR}/.?output.?/"
"^${CMAKE_SOURCE_DIR}/files/var"
"^${CMAKE_SOURCE_DIR}/files/log"
"CMakeLists.txt.user.*"
".*.autosave"
".*.status"
"~$"
"\\\\.swp$")
option(MYX_COMPACT_SOURCE_PACKAGE "Make compact source package" ON)
if(MYX_COMPACT_SOURCE_PACKAGE)
# Список масок для исключения из архива исходных текстов для более компактного архива
set(CPACK_SOURCE_IGNORE_FILES
${CPACK_SOURCE_IGNORE_FILES}
"\\\\.git"
"/\\\\.git/"
"/\\\\.gitlab-ci/"
"\\\\.clang-tidy$"
"\\\\.cmake-format$"
"\\\\.gitignore$"
"\\\\.gitattributes$"
"\\\\.gitmodules$"
"\\\\.gitlab-ci.yml$")
endif()
if("TXZ" IN_LIST CPACK_GENERATOR)
set(CPACK_ARCHIVE_COMPONENT_INSTALL OFF)
set(CPACK_ARCHIVE_FILE_NAME "${PN}_${CPACK_TARGET_ARCH}_${CPACK_PACKAGE_VERSION}")
endif()
if("DEB" IN_LIST CPACK_GENERATOR)
set(CPACK_DEB_MONOLITHIC_INSTALL OFF)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
# По умолчанию пакет собирается для дистрибутива unstable
if(NOT ARG_DEBIAN_PACKAGE_TYPE)
set(DEBIAN_PACKAGE_TYPE "unstable")
endif()
if(NOT ARG_CPACK_DEBIAN_PACKAGE_SECTION)
set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
endif()
if(NOT ARG_CPACK_DEBIAN_PACKAGE_PRIORITY)
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
endif()
# По умолчанию пакет для Debian делится на компоненты
if(NOT ARG_CPACK_DEB_COMPONENT_INSTALL)
set(CPACK_DEB_COMPONENT_INSTALL ON)
endif()
# Если имя компонента по умолчанию не определено, то устанавливается main
if(NOT CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME MAIN)
endif()
# В списке компонентов обязательно должны быть main, lib, dev, static и doc
#list(APPEND CPACK_COMPONENTS_ALL main lib dev static doc)
# TODO
#list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL)
set(deb_arch_suffix "${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb")
# Правило формирования имени пакета и файла для компонента main
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "${PN}")
set(CPACK_DEBIAN_MAIN_FILE_NAME ${CPACK_DEBIAN_MAIN_PACKAGE_NAME}_${deb_arch_suffix})
# Правило формирования имени пакета и файла для компонента lib
set(CPACK_DEBIAN_LIB_PACKAGE_NAME "lib${PN}${PROJECT_VERSION_MAJOR}")
set(CPACK_DEBIAN_LIB_FILE_NAME ${CPACK_DEBIAN_LIB_PACKAGE_NAME}_${deb_arch_suffix})
# Правило формирования имени пакета и файла для компонента dev
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "lib${PN}-dev")
set(CPACK_DEBIAN_DEV_FILE_NAME ${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${deb_arch_suffix})
# Правило формирования имени пакета и файла для компонента static
set(CPACK_DEBIAN_STATIC_PACKAGE_NAME "lib${PN}${PROJECT_VERSION_MAJOR}-static-dev")
set(CPACK_DEBIAN_STATIC_FILE_NAME ${CPACK_DEBIAN_STATIC_PACKAGE_NAME}_${deb_arch_suffix})
set(CPACK_DEBIAN_STATIC_PACKAGE_DEPENDS "lib${PN}-dev")
# Правило формирования имени пакета и файла для компонента doc
set(CPACK_DEBIAN_DOC_PACKAGE_NAME "${PN}-doc")
set(CPACK_DEBIAN_DOC_FILE_NAME ${PN}-doc_${CPACK_PACKAGE_VERSION}_all.deb)
foreach(iter ${CPACK_COMPONENTS_ALL})
string(TOLOWER ${iter} _cl)
string(TOUPPER ${iter} _cu)
# Правила формирования имени пакета и файла для остальных компонентов
if((NOT ${_cu} STREQUAL MAIN) AND
(NOT ${_cu} STREQUAL LIB) AND
(NOT ${_cu} STREQUAL DEV) AND
(NOT ${_cu} STREQUAL STATIC) AND
(NOT ${_cu} STREQUAL DOC))
set(CPACK_DEBIAN_${_cu}_PACKAGE_NAME "${PN}-${_cl}")
set(CPACK_DEBIAN_${_cu}_FILE_NAME "${CPACK_DEBIAN_${_cu}_PACKAGE_NAME}_${deb_arch_suffix}")
endif()
# Если в каталоге ${CMAKE_SOURCE_DIR}/cmake/deb/${_cl} находятся сценарии сопровождающего
# postinst, preinst, postrm и prerm, то они будут добавлены к пакету.
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/preinst")
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/preinst")
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postinst")
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postinst")
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/prerm")
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/prerm")
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postrm")
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postrm")
endif()
endforeach()
if(UNIX AND NOT TARGET deb)
add_custom_target(deb WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND cpack -G DEB)
add_dependencies(deb ${TARGET_NAME})
endif()
endif()
# Подключение модуля, выполняющего сборку архивов и пакетов
include(CPack)
endfunction(myx_create_packages TARGET_NAME)

View File

@ -1,19 +0,0 @@
include_guard(GLOBAL)
if(NOT MYX_TODAY)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_TODAY)
else()
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_TODAY)
endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" MYX_TODAY ${MYX_TODAY})
endif()
if(NOT MYX_YEAR)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_YEAR)
else()
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_YEAR)
endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3" MYX_YEAR ${MYX_YEAR})
endif()

View File

@ -1,74 +0,0 @@
#[=======================================================================[.rst:
Запись результатов сборки проекта внутрь иерархии каталогов с исходными текстами
приводит к засорению файлами формируемыми на этапе сборки, которые затрудняют
разработку, поиск в оригинальных файлах и мешают ориентироваться в проекте.
При работе с несколькими типами сборки, например, отладка и выпуск, появляется
необходимость корректного полного удаления результатов предыдущего варианта.
#]=======================================================================]
include_guard(GLOBAL)
get_filename_component(cmake_source_dir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(cmake_binary_dir "${CMAKE_BINARY_DIR}" REALPATH)
get_filename_component(project_source_dir "${PROJECT_SOURCE_DIR}" REALPATH)
get_filename_component(project_binary_dir "${PROJECT_BINARY_DIR}" REALPATH)
get_filename_component(cmake_install_prefix "${CMAKE_INSTALL_PREFIX}" REALPATH)
if(cmake_install_prefix STREQUAL cmake_binary_dir)
myx_message_fatal_error(
"Myx: Cannot install into build directory ${CMAKE_INSTALL_PREFIX}.")
endif()
if(cmake_install_prefix STREQUAL cmake_source_dir)
myx_message_fatal_error(
"Myx: Cannot install into source directory ${CMAKE_INSTALL_PREFIX}.")
endif()
if(cmake_install_prefix STREQUAL project_binary_dir)
myx_message_fatal_error(
"Myx: Cannot install into build directory ${CMAKE_INSTALL_PREFIX}.")
endif()
if(cmake_install_prefix STREQUAL project_source_dir)
myx_message_fatal_error(
"Myx: Cannot install into source directory ${CMAKE_INSTALL_PREFIX}.")
endif()
if(cmake_binary_dir STREQUAL cmake_source_dir)
myx_message_fatal_error(
"Myx: Cannot build in source directory ${CMAKE_SOURCE_DIR}")
endif()
if(project_binary_dir STREQUAL project_source_dir)
myx_message_fatal_error(
"Myx: Cannot build in source directory ${CMAKE_SOURCE_DIR}")
endif()
# Очистка от сгенерированных файлов
file(GLOB_RECURSE cmakelists_files RELATIVE ${cmake_source_dir} CMakeLists.txt)
foreach(it ${cmakelists_files})
get_filename_component(file ${it} REALPATH)
get_filename_component(dir ${file} DIRECTORY)
file(REMOVE_RECURSE
${dir}/.cmake
${dir}/CMakeFiles)
file(REMOVE
${dir}/CMakeFiles
${dir}/CMakeCache.txt
${dir}/cmake_install.cmake
${dir}/compile_commands.json
${dir}/Makefile
${dir}/.ninja_deps
${dir}/.ninja_logs
${dir}/build.ninja
${dir}/rules.ninja)
endforeach()
unset(cmakelists_files)
unset(cmake_source_dir)
unset(cmake_binary_dir)
unset(project_source_dir)
unset(project_binary_dir)
unset(cmake_install_prefix)

View File

@ -1,56 +0,0 @@
#[=======================================================================[.rst:
FetchContent_Add
----------------
Вспомогательная функция для `FetchContent_Declare()`::
FetchContent_Add(NAME
[ GIT_REPOSITORY repo ] |
[ GIT_REMOTE remote ] |
[ GIT_PATH path ])
Обязательные параметры: `NAME` - идентификатор загружаемого ресурса.
Параметр `GIT_REPOSITORY` определяет имя репозитория по умолчанию.
Если указана пара параметров `GIT_REMOTE` и `GIT_PATH` и у git-репозитория
основного проекта указан удалённый репозиторий с именем, определяемым
переменной `GIT_REMOTE`, то адрес репозитория для получения проекта
изменяется. В этом случае загрузка будет производиться с сервера,
определяемого из адреса с меткой `GIT_REMOTE`, и по пути `GIT_PATH`.
#]=======================================================================]
include_guard(GLOBAL)
# Обязательно в глобальной области
find_package(Git)
function(FetchContent_Add TARGET_NAME)
set(options "")
set(oneValueArgs GIT_REPOSITORY GIT_REMOTE GIT_PATH)
set(multiValueArgs "")
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(GIT_FOUND AND ARG_GIT_REMOTE AND ARG_GIT_PATH)
execute_process(COMMAND ${GIT_EXECUTABLE} config --get remote.${ARG_GIT_REMOTE}.url OUTPUT_VARIABLE REMOTE_URL ERROR_QUIET)
if(REMOTE_URL)
string(REGEX REPLACE ":.*" "" SERVER ${REMOTE_URL})
string(FIND ${SERVER} "http" POS)
if(NOT POS EQUAL 0)
if(NOT SERVER STREQUAL REMOTE_URL)
set(ARG_GIT_REPOSITORY "${SERVER}:${ARG_GIT_PATH}")
endif()
endif()
endif()
endif()
FetchContent_Declare(
${TARGET_NAME}
${ARG_UNPARSED_ARGUMENTS}
GIT_REPOSITORY ${ARG_GIT_REPOSITORY}
GIT_SHALLOW 1
)
set(FETCHCONTENT_QUIET off)
FetchContent_MakeAvailable(${TARGET_NAME})
endfunction()

View File

@ -1,8 +0,0 @@
# Версии CMake, как минимум до 3.8.0, генерируют некорректные
# правила для ninja.
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS "3.8.0" AND CMAKE_GENERATOR MATCHES Ninja)
myx_message_send_error("Myx: Old CMake versions should use Makefile generator")
endif()

View File

@ -1,11 +0,0 @@
# Если выбран генератор Ninja, то в основном сборочном каталоге создаётся
# файл Makefile, который обрабатывается командой make и передаёт исполнение
# системе сборки ninja. Таким образом можно выполнять команду make,
# даже если правила сборки проекта сгенерированы для ninja.
include_guard(GLOBAL)
if(CMAKE_GENERATOR MATCHES Ninja AND PROJECT_IS_TOP_LEVEL)
file(WRITE ${CMAKE_BINARY_DIR}/Makefile
".PHONY: build\n" "%:\n" "\t@ninja \$@\n" "build:\n" "\t@ninja\n")
endif()

View File

@ -1,15 +0,0 @@
include_guard(GLOBAL)
# Создание в каталоге ${CMAKE_BINARY_DIR} стандартных каталогов bin,include,lib,
# а также символических ссылок на каталоги в ${CMAKE_SOURCE_DIR}/files
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/etc" "${CMAKE_BINARY_DIR}/etc")
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/log" "${CMAKE_BINARY_DIR}/log")
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/share" "${CMAKE_BINARY_DIR}/share")
myx_create_symlink("${CMAKE_SOURCE_DIR}/files/var" "${CMAKE_BINARY_DIR}/var")

View File

@ -1,112 +0,0 @@
include_guard(GLOBAL)
function(myx_qt5_target_setup TARGET_NAME)
set(options)
set(oneValueArgs)
set(multiValueArgs COMPONENTS PRIVATE PUBLIC_MOC PRIVATE_MOC UI QRC LANGS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_target_property(__target_type ${TARGET_NAME} TYPE)
foreach(iter ${ARG_COMPONENTS})
if(__target_type STREQUAL "INTERFACE_LIBRARY")
target_include_directories(${TARGET_NAME} INTERFACE ${Qt5${iter}_INCLUDE_DIRS})
else()
target_include_directories(${TARGET_NAME} PRIVATE ${Qt5${iter}_INCLUDE_DIRS})
endif()
if(NOT iter STREQUAL "LinguistTools")
if(__target_type STREQUAL "EXECUTABLE")
target_link_libraries(${TARGET_NAME} PRIVATE "Qt5::${iter}")
endif()
if(__target_type STREQUAL "SHARED_LIBRARY")
target_link_libraries(${TARGET_NAME} PUBLIC "Qt5::${iter}")
endif()
if((${CMAKE_VERSION} VERSION_GREATER "3.8.0") AND (__target_type STREQUAL "OBJECT_LIBRARY"))
target_link_libraries(${TARGET_NAME} PUBLIC "Qt5::${iter}")
endif()
endif()
endforeach()
foreach(iter ${ARG_PRIVATE})
if(__target_type STREQUAL "INTERFACE_LIBRARY")
target_include_directories(${TARGET_NAME} INTERFACE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS})
else()
target_include_directories(${TARGET_NAME} PRIVATE ${Qt5${iter}_PRIVATE_INCLUDE_DIRS})
endif()
endforeach()
if(__target_type STREQUAL "EXECUTABLE")
target_compile_options(${TARGET_NAME} PRIVATE ${Qt5Core_EXECUTABLE_COMPILE_FLAGS})
endif()
if(ARG_PUBLIC_MOC)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_MOC}")
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_MOC})
endif()
if(ARG_PRIVATE_MOC)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_MOC}")
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_MOC})
endif()
if(ARG_PUBLIC_MOC OR ARG_PRIVATE_MOC)
qt5_wrap_cpp(moc_cpp ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC})
endif()
if(ARG_QRC)
qt5_add_resources(qrc_cpp ${ARG_QRC})
endif()
if(ARG_UI AND "Widgets" IN_LIST ARG_COMPONENTS)
qt5_wrap_ui(ui_h ${ARG_UI})
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_UI})
# TODO
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_BINARY_DIR})
endif()
# Перечень файлов, подлежащих переводу
if(__target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(tr ${TARGET_NAME} INTERFACE_TR_FILES)
else()
get_target_property(tr ${TARGET_NAME} TR_FILES)
endif()
# Формирование файла ресурсов с переводами
if("LinguistTools" IN_LIST ARG_COMPONENTS AND tr)
# Заглавие файла ресурсов
file(WRITE ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc "<RCC><qresource prefix=\"/qm\">\n")
# Для каждого языка, указанное в параметре LANGS
foreach(iter ${ARG_LANGS})
# Создание или обновление файла переводов в каталоге ${PROJECT_SOURCE_DIR}/l10n
# и его компиляция в каталог ${PROJECT_BINARY_DIR}
qt5_create_translation(qm ${tr}
"${PROJECT_SOURCE_DIR}/l10n/${TARGET_NAME}_${iter}.ts"
OPTIONS -I ${PROJECT_SOURCE_DIR}/include -I ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME})
# Добавление записи для скомпилированного файла переводов в ресурсный файл
file(APPEND ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc
"<file alias=\"${TARGET_NAME}_${iter}\">${TARGET_NAME}_${iter}.qm</file>\n")
# Добавление скомпилированного файла переводов к списку зависимостей для цели
target_sources(${TARGET_NAME} PRIVATE ${qm})
endforeach()
# Окончание файла ресурсов
file(APPEND ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc "</qresource></RCC>\n")
# Компиляция файла ресурсов с переводами
qt5_add_resources(qrc_l10n ${PROJECT_BINARY_DIR}/${TARGET_NAME}_l10n.qrc)
target_sources(${TARGET_NAME} PRIVATE ${qrc_l10n})
endif()
unset(tr)
if(__target_type STREQUAL "INTERFACE_LIBRARY")
target_sources(${TARGET_NAME} INTERFACE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})
else()
target_sources(${TARGET_NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})
endif()
# Установка публичных заголовочных файлов
if(PROJECT_IS_TOP_LEVEL)
myx_install_relative(${PROJECT_SOURCE_DIR}
FILES ${ARG_PUBLIC_MOC}
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT DEV
)
endif()
endfunction()

View File

@ -1,17 +0,0 @@
include_guard(GLOBAL)
function(myx_is_semantic_project_version)
if(NOT ${PROJECT_VERSION_PATCH} MATCHES "([0-9]+)")
myx_message_error("Myx: Please set project version in X.Y.Z format")
endif()
endfunction()
function(myx_project_version_int)
# cmake-format: off
myx_is_semantic_project_version()
math(EXPR v "(${PROJECT_VERSION_MAJOR} << 32) + (${PROJECT_VERSION_MINOR} << 16) + ${PROJECT_VERSION_PATCH}")
set_property(GLOBAL PROPERTY PROJECT_VERSION_INT ${v})
# cmake-format: on
endfunction()
myx_is_semantic_project_version()

View File

@ -1,126 +0,0 @@
include_guard(GLOBAL)
function(myx_target_setup TARGET_NAME)
set(options)
set(oneValueArgs PCH)
set(multiValueArgs COMPILE_DEFINITIONS PACKAGES LINK_LIBRARIES
CPP PUBLIC_HEADERS PRIVATE_HEADERS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT TARGET ${TARGET_NAME})
myx_message_fatal_error("Target ${TARGET_NAME} does not exists.")
endif()
get_target_property(__target_type ${TARGET_NAME} TYPE)
if(${__target_type} STREQUAL "INTERFACE_LIBRARY")
myx_message_fatal_error("This function will not work for interface targets.")
endif()
foreach(iter ${ARG_PACKAGES})
target_include_directories(${TARGET_NAME} PRIVATE ${${iter}_INCLUDE_DIRS})
target_compile_definitions(${TARGET_NAME} PRIVATE ${${iter}_COMPILE_DEFINITIONS})
endforeach()
if(ARG_CPP)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY CPP_FILES ${ARG_CPP})
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_CPP})
endif()
if(ARG_PUBLIC_HEADERS)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_HEADERS}")
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PUBLIC_HEADERS})
endif()
if(ARG_PRIVATE_HEADERS)
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_HEADERS}")
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY TR_FILES ${ARG_PRIVATE_HEADERS})
endif()
if(ARG_PCH)
if((${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16) AND (PROJECT_IS_TOP_LEVEL OR MYX_USE_LOCAL_DIRECTORIES))
target_precompile_headers(${TARGET_NAME} PRIVATE ${ARG_PCH})
else()
target_compile_options(${TARGET_NAME} PRIVATE -include ${ARG_PCH})
endif()
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PCH}")
endif()
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>)
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/src")
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
endif()
if(__target_type STREQUAL "EXECUTABLE")
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/include")
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
endif()
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}")
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}>)
endif()
set_target_properties(${TARGET_NAME} PROPERTIES
POSITION_INDEPENDENT_CODE ON
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
)
if(CMAKE_CXX_COMPILE_OPTIONS_PIE)
target_compile_options(${TARGET_NAME} PUBLIC ${CMAKE_CXX_COMPILE_OPTIONS_PIE})
endif()
install(TARGETS ${TARGET_NAME} COMPONENT MAIN RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
target_sources(${TARGET_NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
target_sources(${TARGET_NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
target_sources(${TARGET_NAME} PUBLIC $<BUILD_INTERFACE:${ARG_INTERFACE_HEADERS}>)
target_compile_definitions(${TARGET_NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
# CMake до версии 3.12 не умеет извлекать из целей типа `OBJECT_LIBRARY`
# информацию о заголовочных файлах. Это обход.
if(${CMAKE_VERSION} VERSION_GREATER "3.11.99")
target_link_libraries(${TARGET_NAME} PRIVATE ${ARG_LINK_LIBRARIES})
else()
if((NOT ${__target_type} STREQUAL "OBJECT_LIBRARY") AND
(NOT ${__target_type} STREQUAL "EXECUTABLE"))
target_link_libraries(${TARGET_NAME} PRIVATE ${ARG_LINK_LIBRARIES})
else()
foreach(__link_library ${ARG_LINK_LIBRARIES})
if(TARGET ${__link_library})
get_target_property(__lib_type ${__link_library} TYPE)
if(__lib_type)
get_target_property(__include_dirs ${__link_library} INTERFACE_INCLUDE_DIRECTORIES)
if(__include_dirs)
target_include_directories(${TARGET_NAME} PUBLIC ${__include_dirs})
endif()
if(${__target_type} STREQUAL "EXECUTABLE")
if(${__lib_type} STREQUAL "OBJECT_LIBRARY")
if(TARGET ${__link_library}_static)
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}_static)
else()
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library}_shared)
endif()
else()
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library})
endif()
endif()
endif()
else()
target_link_libraries(${TARGET_NAME} PRIVATE ${__link_library})
endif()
endforeach()
endif()
endif()
# Установка публичных заголовочных файлов
if(PROJECT_IS_TOP_LEVEL AND ARG_PUBLIC_HEADERS)
myx_install_relative(${PROJECT_SOURCE_DIR}
FILES ${ARG_PUBLIC_HEADERS}
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT DEV
)
endif()
endfunction()

View File

@ -1,13 +0,0 @@
#[=======================================================================[.rst:
Цель для удаления файлов, установленных выполнением цели `install`.
Если при установке использовалась переменная `DESTDIR`, то при удалении
файлов нужно указать то же значение.
#]=======================================================================]
include_guard(GLOBAL)
if((NOT TARGET uninstall) AND (NOT DEFINED ENV{SAPR_PREFIX}))
configure_file(${CMAKE_CURRENT_LIST_DIR}/uninstall.cmake.in
${CMAKE_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)
endif()

View File

@ -1,31 +0,0 @@
PROJECT_NAME = @DOXYGEN_PROJECT_TITLE@
OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@
OUTPUT_LANGUAGE = @ARG_LANGUAGE@
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
STRIP_FROM_INC_PATH = @PROJECT_SOURCE_DIR@
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_METHODS = YES
INPUT = "@PROJECT_SOURCE_DIR@/doc/doxygen" "@PROJECT_SOURCE_DIR@/include" "@PROJECT_SOURCE_DIR@/src"
RECURSIVE = YES
CLANG_ASSISTED_PARSING = YES
CLANG_DATABASE_PATH = @CMAKE_BINARY_DIR@
GENERATE_HTML = @ARG_HTML@
GENERATE_TREEVIEW = YES
GENERATE_LATEX = @ARG_LATEX@
LATEX_CMD_NAME = xelatex
COMPACT_LATEX = YES
GENERATE_XML = @ARG_XML@
UML_LOOK = YES
TEMPLATE_RELATIONS = YES
CALL_GRAPH = YES
CALLER_GRAPH = YES
INTERACTIVE_SVG = YES

View File

@ -1,75 +0,0 @@
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(MYX_CMAKE_LIB_DOC_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
function(myx_doc_doxygen TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DOC_DIR_BACKPORT})
endif()
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_FOUND ON CACHE STRING "Doxygen documentation generator enabled" FORCE)
set(DOXYGEN_EXECUTABLE "${DOXYGEN_EXECUTABLE}" CACHE STRING "Path to Doxygen executable")
else()
set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE)
endif()
set(target myx-doc-doxygen-${TARGET_NAME})
if(TARGET ${target})
myx_message_warning("Target ${target} already defined")
return()
endif()
if(NOT DOXYGEN_FOUND)
add_custom_target(${target} VERBATIM COMMENT "Doxygen is not found. Skipping target ${target} build")
return()
endif()
set(options)
set(oneValueArgs HTML LATEX XML LANGUAGE DOXYFILE_TEMPLATE)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT ARG_HTML)
set(ARG_HTML NO)
endif()
if(NOT ARG_LATEX)
set(ARG_LATEX NO)
endif()
if(NOT ARG_XML)
set(ARG_XML YES)
endif()
if(NOT ARG_LANGUAGE)
set(ARG_LANGUAGE "Russian")
endif()
if(NOT ARG_DOXYFILE_TEMPLATE OR NOT EXISTS "${ARG_DOXYFILE_TEMPLATE}")
set(ARG_DOXYFILE_TEMPLATE "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Doxyfile.in")
endif()
if(NOT DOXYGEN_PROJECT_NAME)
set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME})
endif()
set(work_dir ${PROJECT_BINARY_DIR}/doc/doxygen)
configure_file(${ARG_DOXYFILE_TEMPLATE} ${work_dir}/Doxyfile @ONLY)
add_custom_target(${target}
VERBATIM
WORKING_DIRECTORY ${work_dir}
COMMAND ${DOXYGEN_EXECUTABLE} ${work_dir}/Doxyfile
COMMENT "Generating API documentation with Doxygen")
if(ARG_HTML)
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/doxygen/html/
COMPONENT DOC OPTIONAL
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/doxygen)
endif()
if(NOT TARGET myx-doc-doxygen)
add_custom_target(myx-doc-doxygen)
endif()
add_dependencies(myx-doc-doxygen ${target})
endfunction()

View File

@ -1,32 +0,0 @@
cmake_policy(PUSH)
cmake_policy(SET CMP0053 NEW) # IN_LIST operator
set(ARG_PREFIX "${PREFIX}")
set(GIT_REV "N/A")
set(GIT_DIFF "")
set(GIT_TAG "N/A")
set(GIT_BRANCH "N/A")
find_package(Git)
if(GIT_EXECUTABLE)
execute_process(COMMAND ${GIT_EXECUTABLE} log --pretty=format:'%h' -n 1 OUTPUT_VARIABLE 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 "${GIT_REV}" STREQUAL "")
execute_process(COMMAND bash -c "${GIT_EXECUTABLE} diff --quiet --exit-code || echo +" OUTPUT_VARIABLE GIT_DIFF)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --exact-match --tags OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE GIT_BRANCH)
string(STRIP "${GIT_REV}" GIT_REV)
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
string(STRIP "${GIT_DIFF}" GIT_DIFF)
string(STRIP "${GIT_TAG}" GIT_TAG)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
endif()
endif()
configure_file("GitInfo.hpp.in" "${GIT_INFO_FILE}")
cmake_policy(POP)

View File

@ -1,26 +0,0 @@
// -*- C++ -*-
#pragma once
#if defined (@PREFIX@GIT_REV)
#error "Duplicate definition of macros @PREFIX@GIT_REV"
#else
#define @PREFIX@GIT_REV "@GIT_REV@"
#endif
#if defined (@PREFIX@GIT_DIFF)
#error "Duplicate definition of macros @PREFIX@GIT_DIFF"
#else
#define @PREFIX@GIT_DIFF "@GIT_DIFF@"
#endif
#if defined (@PREFIX@GIT_BRANCH)
#error "Duplicate definition of macros @PREFIX@GIT_BRANCH"
#else
#define @PREFIX@GIT_BRANCH "@GIT_BRANCH@"
#endif
#if defined (@PREFIX@GIT_TAG)
#error "Duplicate definition of macros @PREFIX@GIT_TAG"
#else
#define @PREFIX@GIT_TAG "@GIT_TAG@"
#endif

View File

@ -1,56 +0,0 @@
#[=======================================================================[.rst:
myx_generate_git_info_header
----------------------------------
Вспомогательная функция для автоматической генерации заголовочного
файла, содержащего информацию о текущем состоянии репозитория git::
myx_generate_git_info_header(TARGET_NAME BASE_FILENAME
[ PREFIX prefix ] )
Обязательные параметры: `TARGET_NAME` - имя цели, с которой связан
заголовочный файл, и `BASE_FILENAME` - имя генерируемого заголовочного
файла. Дополнительный аргумент `PREFIX` добавляет префикс к генерируемым
именам переменных.
#]=======================================================================]
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
function(myx_generate_git_info_header TARGET_NAME BASE_FILENAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT})
endif()
set(options)
set(oneValueArgs PREFIX)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(__filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
file(APPEND ${__filename} "")
set(__prefix "")
if(ARG_PREFIX)
string(APPEND ARG_PREFIX "_")
string(REPLACE "-" "_" __prefix ${ARG_PREFIX})
endif()
# cmake-format: off
if(NOT TARGET ${TARGET_NAME}-git-info-header)
add_custom_target(${TARGET_NAME}-git-info-header ALL
${CMAKE_COMMAND} -DGIT_INFO_FILE=${__filename} -DPREFIX=${__prefix}
-P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/GitInfo.cmake
BYPRODUCTS ${__filename}
WORKING_DIRECTORY ${CMAKE_CURRENT_FUNCTION_LIST_DIR})
endif()
# cmake-format: on
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${__filename})
target_sources(${TARGET_NAME} PRIVATE ${__filename})
add_dependencies(${TARGET_NAME} ${TARGET_NAME}-git-info-header)
endfunction()

View File

@ -1,12 +0,0 @@
// -*- C++ -*-
#pragma once
#define PROJECT_VERSION_STR "@PROJECT_VERSION@"
#define PROJECT_VERSION_INT @PROJECT_VERSION_INT@
#cmakedefine PROJECT_NAME "@PROJECT_NAME@"
#cmakedefine AUTHOR_NAME "@AUTHOR_NAME@"
#cmakedefine AUTHOR_EMAIL "@AUTHOR_EMAIL@"
#cmakedefine DESCRIPTION "@PROJECT_DESCRIPTION@"
#cmakedefine BUILD_TYPE "@CMAKE_BUILD_TYPE@"
#cmakedefine BUILD_DATE "@MYX_TODAY@"

View File

@ -1,35 +0,0 @@
#[=======================================================================[.rst:
myx_generate_private_config_header
----------------------------------
Вспомогательная функция для автоматической генерации заголовочного
файла, содержащего информацию о проекте::
myx_generate_private_config_header(TARGET_NAME BASE_FILENAME)
Обязательные параметры: `TARGET_NAME` - имя цели, с которой связан
заголовочный файл, и `BASE_FILENAME` - имя генерируемого заголовочного файла.
#]=======================================================================]
include_guard(GLOBAL)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
function(myx_generate_private_config_header TARGET_NAME BASE_FILENAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_GENERATORS_DIR_BACKPORT})
endif()
set(BUILD_DATE ${MYX_TODAY})
myx_project_version_int()
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
set(__filename "${PROJECT_BINARY_DIR}/include/${BASE_FILENAME}")
configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/PrivateConfig.hpp.in" ${__filename})
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY PRIVATE_HEADER_FILES ${__filename})
target_sources(${TARGET_NAME} PRIVATE ${__filename})
endfunction()

View File

@ -1,5 +0,0 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components("@PROJECT_NAME@")

View File

@ -1,38 +0,0 @@
include_guard(GLOBAL)
# Добавление флага к списку используемых после проверки
# возможности его использования текущим компилятором
# Основано на https://github.com/bluescarni/yacma
include(CheckCXXCompilerFlag)
macro(check_enable_cxx_compiler_flag FLAG)
set(options)
set(oneValueArgs TARGET)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(CMAKE_REQUIRED_QUIET TRUE)
check_cxx_compiler_flag("${FLAG}" check_cxx_flag)
unset(CMAKE_REQUIRED_QUIET)
if(check_cxx_flag)
myx_message_notice("'${FLAG}': flag is supported.")
if(ARG_TARGET)
target_compile_options(${ARG_TARGET} PUBLIC ${FLAG})
else()
add_compile_options(${FLAG})
endif()
else()
myx_message_status("'${FLAG}': flag is NOT supported.")
endif()
unset(check_cxx_flag CACHE)
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${__iter})
endforeach()
unset(ARG_UNPARSED_ARGUMENTS)
unset(multiValueArgs)
unset(oneValueArgs)
unset(options)
endmacro()

View File

@ -1,13 +0,0 @@
include_guard(GLOBAL)
# Создание символических ссылок
macro(myx_create_symlink ORIGINAL_FILENAME LINKNAME)
if(UNIX AND (NOT EXISTS ${LINKNAME}))
if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${ORIGINAL_FILENAME} ${LINKNAME})
else()
file(CREATE_LINK ${ORIGINAL_FILENAME} ${LINKNAME} SYMBOLIC)
endif()
endif()
endmacro(myx_create_symlink ORIGINAL_FILENAME LINKNAME)

View File

@ -1,44 +0,0 @@
include_guard(GLOBAL)
macro(myx_find_required_packages)
set(options)
set(oneValueArgs)
set(multiValueArgs PACKAGES Boost Qt5 Qt5Private Qt6 Qt6Private)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
foreach(iter ${ARG_PACKAGES})
find_package(${iter} REQUIRED)
endforeach()
if(ARG_Boost)
find_package(Boost COMPONENTS ${ARG_Boost} REQUIRED)
endif()
if(ARG_Qt5)
find_package(Qt5 COMPONENTS ${ARG_Qt5} REQUIRED)
endif()
if(ARG_Qt5Private)
foreach(iter ${ARG_Qt5Private})
find_package("Qt5${iter}" COMPONENTS Private REQUIRED)
endforeach()
endif()
if(ARG_Qt6)
find_package(Qt6 COMPONENTS ${ARG_Qt6} REQUIRED)
endif()
if(ARG_Qt6Private)
foreach(iter ${ARG_Qt6Private})
find_package("Qt6${iter}" COMPONENTS Private REQUIRED)
endforeach()
endif()
foreach(__iter IN LISTS oneValueArgs multiValueArgs)
unset(ARG_${__iter})
endforeach()
unset(ARG_UNPARSED_ARGUMENTS)
unset(multiValueArgs)
unset(oneValueArgs)
unset(options)
endmacro(myx_find_required_packages)

View File

@ -1,19 +0,0 @@
#[=======================================================================[.rst:
myx_install_relative
--------------------
#]=======================================================================]
macro(myx_install_relative STRIP_DIRECTORY)
set(options)
set(oneValueArgs DESTINATION)
set(multiValueArgs FILES)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
foreach(FILE ${ARG_FILES})
get_filename_component(DIR ${FILE} DIRECTORY)
string(REPLACE ${STRIP_DIRECTORY} "" RELATIVE_DIR ${DIR})
INSTALL(FILES ${FILE} DESTINATION ${ARG_DESTINATION}/${RELATIVE_DIR} ${ARG_UNPARSED_ARGUMENTS})
endforeach()
endmacro(myx_install_relative STRIP_DIRECTORY)

View File

@ -1,96 +0,0 @@
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
endif()
find_program(UNCRUSTIFY_EXE NAMES uncrustify)
function(myx_uncrustify TARGET_NAME)
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_UNCRUSTIFY_DIR_BACKPORT})
endif()
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
return()
endif()
set(options)
set(oneValueArgs CONFIG)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT ARG_CONFIG)
set(ARG_CONFIG "${PROJECT_SOURCE_DIR}/uncrustify.cfg")
endif()
if(NOT EXISTS ${ARG_CONFIG})
myx_message_notice("MyxCMake: uncrustify config is not found")
return()
endif()
if(NOT UNCRUSTIFY_EXE)
myx_message_notice("MyxCMake: uncrustify executable is not found")
return()
endif()
if(NOT TARGET myx-uncrustify)
add_custom_target(myx-uncrustify)
endif()
if(NOT TARGET myx-uncrustify-check)
add_custom_target(myx-uncrustify-check)
endif()
if(NOT TARGET myx-uncrustify-append-comments)
add_custom_target(myx-uncrustify-append-comments)
endif()
# Динамически сгенерированные файлы исключаются
get_target_property(__target_type ${TARGET_NAME} TYPE)
if((${__target_type} STREQUAL "INTERFACE_LIBRARY") AND (${CMAKE_VERSION} VERSION_LESS "3.17.0"))
get_target_property(__s1 ${TARGET_NAME} INTERFACE_SOURCES)
if(__s1)
list(APPEND __all_sources ${__s1})
endif()
else()
get_target_property(__s2 ${TARGET_NAME} SOURCES)
if(__s2)
list(APPEND __all_sources ${__s2})
endif()
endif()
foreach(iter ${__all_sources})
string(FIND ${iter} ${CMAKE_BINARY_DIR} pos)
if(pos EQUAL -1)
list(APPEND __sources ${iter})
endif()
endforeach()
target_sources(${TARGET_NAME} PRIVATE ${ARG_CONFIG})
set(__fixed_config ${PROJECT_BINARY_DIR}/uncrustify-${TARGET_NAME}.cfg)
add_custom_command(OUTPUT ${__fixed_config}
DEPENDS ${ARG_CONFIG}
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
-c ${ARG_CONFIG} -o ${__fixed_config})
list(APPEND __options -c ${__fixed_config})
# cmake-format: off
add_custom_target(${TARGET_NAME}-uncrustify-check
DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${__options} --check ${__sources})
list(APPEND __options --replace --no-backup)
add_custom_target(${TARGET_NAME}-uncrustify
DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${__options} --mtime ${__sources})
add_custom_target(${TARGET_NAME}-uncrustify-append-comments
DEPENDS ${__fixed_config}
COMMAND ${UNCRUSTIFY_EXE} ${__options}
--set cmt_insert_class_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/classheader.txt
--set cmt_insert_file_footer=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/filefooter.txt
--set cmt_insert_file_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fileheader.txt
--set cmt_insert_func_header=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/funcheader.txt
--set cmt_insert_before_ctor_dtor=true --mtime ${__sources})
# cmake-format: on
add_dependencies(myx-uncrustify ${TARGET_NAME}-uncrustify)
add_dependencies(myx-uncrustify-check ${TARGET_NAME}-uncrustify-check)
add_dependencies(myx-uncrustify-append-comments ${TARGET_NAME}-uncrustify-append-comments)
endfunction()

View File

@ -1,5 +0,0 @@
/**
* @class $(fclass)
* @brief TODO
* @details TODO
*/

View File

@ -1 +0,0 @@
// EOF $(filename)

View File

@ -1,6 +0,0 @@
// -*- C++ -*-
/**
* @file $(filename)
* @brief TODO
* @details TODO
*/

View File

@ -1,5 +0,0 @@
/**
* @fn $(fclass)::$(function)
* $(javaparam)
* @details TODO
*/

View File

@ -1,31 +0,0 @@
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
# Удаление пустых каталогов
foreach(_file ${files})
set(_res 0)
while(_res EQUAL 0)
get_filename_component(_file ${_file} DIRECTORY)
execute_process(COMMAND rmdir ${_file} RESULT_VARIABLE _res OUTPUT_QUIET ERROR_QUIET)
endwhile()
endforeach()

View File

@ -1,43 +0,0 @@
#[=======================================================================[.rst:
Подключение дополнительных функций для CMake
По умолчанию предполагается использование версии MyxCMake,
файлы которой находятся в каталоге `cmake/myx` текущего проекта.
Для удобства разработки библиотеки MyxCMake можно указать путь
к её репозиторию с помощью переменной проекта CMake `MYX_CMAKE_DIR`
или переменной окружения `MYX_CMAKE_DIR`.
Если определена переменная `MYX_CMAKE_USE_SYSTEM`, то выполняется
поиск версии в каталогах перечисленных в переменной `CMAKE_MODULES_DIR`.
Кроме того выполняется попытка поиска (MyxxCMake)[../../../../myxx] --
расширения для библиотеки, позволяющего в режиме разработки программного
проекта использовать дополнительные инструменты для его сопровождения.
#]=======================================================================]
if(ENV{MYX_CMAKE_DIR})
set(MYX_CMAKE_DIR $ENV{MYX_CMAKE_DIR})
endif()
if(MYX_CMAKE_DIR)
find_package(MyxCMake 2.3.8 REQUIRED CONFIG PATHS ${MYX_CMAKE_DIR} NO_DEFAULT_PATH)
myx_message_notice("== MyxCMake directory: ${MyxCMake_CONFIG} ==")
else()
if(MYX_CMAKE_USE_SYSTEM)
find_package(MyxCMake 2.3.8 REQUIRED)
myx_message_notice("== MyxCMake directory: ${MyxCMake_CONFIG} ==")
else()
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
myx_message_notice("== MyxCMake directory: ${PROJECT_SOURCE_DIR}/cmake/myx ==")
endif()
endif()
if(ENV{MYXX_CMAKE_DIR})
set(MYXX_CMAKE_DIR $ENV{MYXX_CMAKE_DIR})
endif()
if(MYXX_CMAKE_DIR)
find_package(MyxxCMake CONFIG PATHS ${MYXX_CMAKE_DIR} NO_DEFAULT_PATH)
else()
find_package(MyxxCMake CONFIG PATHS "$ENV{XDG_DATA_DIR}/cmake" QUIET)
endif()

View File

@ -1,27 +0,0 @@
/**
* \file Класс Processor
*/
#ifndef PROCESSOR_HPP_
#define PROCESSOR_HPP_
#pragma once
#include <QObject>
#include <QDebug>
/**
* \brief Класс Processor
*/
class Processor : public QObject
{
Q_OBJECT
public:
/**
* \brief Слот, печатающий сообщение
*/
Q_SLOT void process() { qCritical() << "about to close"; }
};
#endif // ifndef PROCESSOR_HPP_
// EOF processor.hpp

View File

@ -0,0 +1,32 @@
# Название основной цели и имени программы в текущем каталоге
set(TRGT myx-cmake-example-features)
# Список файлов исходных текстов
set(TRGT_cpp ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
# Заголовочные файлы, для которых необходима обработка препроцессором moc
# (содержат класс, унаследованный от QObject, использующий сигналы и/или слоты)
set(TRGT_moc_hpp ${CMAKE_CURRENT_SOURCE_DIR}/processor.hpp)
# Заголовочные файлы
set(TRGT_hpp)
set(TRGT_headers ${TRGT_hpp} ${TRGT_moc_hpp})
# Правило для автоматической генерации препроцессором moc
qt5_wrap_cpp(TRGT_moc_cpp ${TRGT_moc_hpp})
# Функция для создания цели, результатом которой будет сборка приложения
add_executable(${TRGT} ${TRGT_cpp} ${TRGT_headers} ${TRGT_moc_cpp})
myx_cmake_common_target_properties(${TRGT})
# Qt5: подключение заголовочных файлов
target_include_directories(${TRGT} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
# Qt5: подключение библиотек
target_link_libraries(${TRGT} Qt5::Core)
# Дополнительные функции для цели ${TRGT}.
# Вызов обязательно после всех функций target_link_libraries
myx_cmake_common_target_properties_post_link(${TRGT})

View File

@ -0,0 +1,56 @@
#include "processor.hpp"
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QTimer>
int qStringToInt( const QString s )
{
return( s.toInt() );
}
int unused( int a )
{
return( a );
}
int main( int argc, char** argv )
{
QCoreApplication app( argc, argv );
// qt-keywords
QList< int > il;
il << 111 << 222;
Q_FOREACH ( int i, il )
{
qDebug() << i;
}
QStringList sl;
sl << "111" << "222";
for ( auto s: sl )
{
qDebug() << s;
}
for ( auto s: qAsConst( sl ) )
{
s.append( "0" );
}
QString s { QStringLiteral( "100" ) };
auto ir = qStringToInt( s );
QFile* f = new QFile();
Processor p;
QObject::connect( &app, SIGNAL(aboutToQuit()), &p, SLOT(process()));
QTimer::singleShot( 100, &app, SLOT(quit()));
int arr[3];
qCritical() << arr[2];
return( QCoreApplication::exec() );
} // main

View File

@ -1,7 +1,3 @@
/**
* \file Класс Processor
*/
#ifndef PROCESSOR_HPP_
#define PROCESSOR_HPP_
@ -10,17 +6,11 @@
#include <QObject>
#include <QDebug>
/**
* \brief Класс Processor
*/
class Processor : public QObject
{
Q_OBJECT
public:
/**
* \brief Слот, печатающий сообщение
*/
Q_SLOT void process() { qCritical() << "about to close"; }
};
#endif // ifndef PROCESSOR_HPP_
#endif

View File

@ -1,116 +0,0 @@
/**
* \file Основной файл проекта
*/
#include <myx-example-features/processor.hpp>
#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QRandomGenerator>
#include <QTimer>
/**
* @brief Перевод строки в целое число
* @param Строка
* @return Целое число
*/
int qStringToInt( const QString& s )
{
return( s.toInt() );
}
/**
* \brief Неиспользуемая функция для тестирования анализа покрытия кода
*/
int unused( int a )
{
return( a );
}
/**
* \brief Медленная функция
*/
int slowFunction()
{
constexpr int size = 16 * 1024;
double a[size];
for ( int i = 0; i < size; i++ ) {
a[i] = QRandomGenerator::global()->bounded( 4 );
for ( int j = 0; j < i; j++ ) a[i] += sin( a[j] );
a[0] += a[i];
}
return( qRound( a[0] ) );
} // slowFunction
/**
* \brief Быстрая функция
*/
int fastFunction()
{
constexpr int size = 8 * 1024;
double a[size];
for ( int i = 0; i < size; i++ ) {
a[i] = QRandomGenerator::global()->bounded( 4 );
for ( int j = 0; j < i; j++ ) a[i] += sin( a[j] );
a[0] += a[i];
}
return( qRound( a[0] ) );
}
/**
* \brief Основная функция
* \param argc Количество параметров командной строки
* \param argv Массив параметров
* \return Результат выполнения QApplication::exec()
*/
int main( int argc, char** argv )
{
QCoreApplication app( argc, argv );
// qt-keywords
QList< int > il;
il << 111 << 222;
Q_FOREACH ( int i, il ) {
qDebug() << i;
}
QStringList sl;
sl << QStringLiteral( "111" ) << QStringLiteral( "222" );
for ( const auto& s: qAsConst( sl ) ) {
qDebug() << s;
}
for ( auto s: qAsConst( sl ) ) {
s.append( "0" );
}
QString s { QStringLiteral( "100" ) };
auto ir = qStringToInt( s );
QFile* f = new QFile();
Processor p;
QObject::connect( &app, &QCoreApplication::aboutToQuit, &p, &Processor::process );
QTimer::singleShot( 100, &app, SLOT(quit()));
#ifdef PROFILE
qCritical() << "Slow: " << slowFunction();
qCritical() << "Fast: " << fastFunction();
#endif
int arr[3];
qCritical() << arr[2];
return( QCoreApplication::exec() );
}// main
// EOF main.cpp