Форматирование кода

This commit is contained in:
Andrei Astafev 2020-03-29 08:44:48 +03:00
parent 9719383c86
commit 0c02885f2c
17 changed files with 264 additions and 193 deletions

View File

@ -1,151 +1,237 @@
# ----------------------------------
# Options affecting listfile parsing
# ----------------------------------
with section("parse"):
# -------------------------- # Specify structure for custom cmake functions
# General Formatting Options additional_commands = {
# -------------------------- 'add_common_library': { 'flags': [],
# How wide to allow formatted cmake files 'kwargs': { 'OUTPUT_NAME': '*',
line_width = 100 'SOURCES': '*',
'TARGET': '*'}},
'foo': { 'flags': ['BAR', 'BAZ'],
'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}},
'pvs_studio_add_target': { 'flags': [ 'COMPILE_COMMANDS',
'OUTPUT',
'HIDE_HELP'],
'kwargs': { 'ARGS': '*',
'CONFIG': '*',
'DEPENDS': '*',
'FORMAT': '*',
'MODE': '*',
'TARGET': '*'}},
'write_compiler_detection_header': { 'flags': [],
'kwargs': { 'COMPILERS': '*',
'FEATURES': '*',
'FILE': '*',
'PREFIX': '*'}}}
# How many spaces to tab for indent # Specify variable tags.
tab_size = 2 vartags = []
# If arglists are longer than this, break them always # Specify property tags.
max_subargs_per_line = 3 proptags = []
# If true, separate flow control names from their parentheses with a space # -----------------------------
separate_ctrl_name_with_space = False # Options affecting formatting.
# -----------------------------
with section("format"):
# If true, separate function names from parentheses with a space # How wide to allow formatted cmake files
separate_fn_name_with_space = False line_width = 90
# If a statement is wrapped to more than one line, than dangle the closing # How many spaces to tab for indent
# parenthesis on it's own line tab_size = 2
dangle_parens = False
# If the statement spelling length (including space and parenthesis is larger # If an argument group contains more than this many sub-groups (parg or kwarg
# than the tab width by more than this amoung, then force reject un-nested # groups) then force it to a vertical layout.
# layouts. max_subgroups_hwrap = 2
max_prefix_chars = 2
# If a candidate layout is wrapped horizontally but it exceeds this many lines, # If a positional argument group contains more than this many arguments, then
# then reject the layout. # force it to a vertical layout.
max_lines_hwrap = 2 max_pargs_hwrap = 6
# What style line endings to use in the output. # If a cmdline positional group consumes more than this many lines without
line_ending = 'unix' # nesting, then invalidate the layout (and nest)
max_rows_cmdline = 2
# Format command names consistently as 'lower' or 'upper' case # If true, separate flow control names from their parentheses with a space
command_case = 'canonical' separate_ctrl_name_with_space = False
# Format keywords consistently as 'lower' or 'upper' case # If true, separate function names from parentheses with a space
keyword_case = 'upper' separate_fn_name_with_space = False
# Specify structure for custom cmake functions # If a statement is wrapped to more than one line, than dangle the closing
additional_commands = { # parenthesis on its own line.
"foo": { dangle_parens = False
"flags": [
"BAR",
"BAZ"
],
"kwargs": {
"HEADERS": "*",
"SOURCES": "*",
"DEPENDS": "*"
}
},
"pvs_studio_add_target" : {
"flags": [
"COMPILE_COMMANDS",
"OUTPUT",
"HIDE_HELP"
],
"kwargs": {
"TARGET": "*",
"DEPENDS": "*",
"FORMAT": "*",
"CONFIG": "*",
"ARGS": "*",
"MODE": "*"
}
},
"write_compiler_detection_header" : {
"flags": [ ],
"kwargs": {
"FILE": "*",
"PREFIX": "*",
"COMPILERS": "*",
"FEATURES": "*"
}
}
}
# A list of command names which should always be wrapped # If the trailing parenthesis must be 'dangled' on its on line, then align it
always_wrap = [] # to this reference: `prefix`: the start of the statement, `prefix-indent`:
# the start of the statement, plus one indentation level, `child`: align to
# the column of the arguments
dangle_align = 'prefix'
# Specify the order of wrapping algorithms during successive reflow attempts # If the statement spelling length (including space and parenthesis) is
algorithm_order = [0, 1, 2, 3, 4] # smaller than this amount, then force reject nested layouts.
min_prefix_chars = 4
# If true, the argument lists which are known to be sortable will be sorted # If the statement spelling length (including space and parenthesis) is larger
# lexicographicall # than the tab width by more than this amount, then force reject un-nested
enable_sort = True # layouts.
max_prefix_chars = 2
# If true, the parsers may infer whether or not an argument list is sortable # If a candidate layout is wrapped horizontally but it exceeds this many
# (without annotation). # lines, then reject the layout.
autosort = False max_lines_hwrap = 2
# If a comment line starts with at least this many consecutive hash characters, # What style line endings to use in the output.
# then don't lstrip() them off. This allows for lazy hash rulers where the first line_ending = 'unix'
# hash char is not separated by space
hashruler_min_length = 10
# A dictionary containing any per-command configuration overrides. Currently # Format command names consistently as 'lower' or 'upper' case
# only `command_case` is supported. command_case = 'canonical'
per_command = {}
# Format keywords consistently as 'lower' or 'upper' case
keyword_case = 'upper'
# -------------------------- # A list of command names which should always be wrapped
# Comment Formatting Options always_wrap = []
# --------------------------
# What character to use for bulleted lists
bullet_char = '*'
# What character to use as punctuation after numerals in an enumerated list # If true, the argument lists which are known to be sortable will be sorted
enum_char = '.' # lexicographicall
enable_sort = True
# enable comment markup parsing and reflow # If true, the parsers may infer whether or not an argument list is sortable
enable_markup = False # (without annotation).
autosort = False
# If comment markup is enabled, don't reflow the first comment block in each # By default, if cmake-format cannot successfully fit everything into the
# listfile. Use this to preserve formatting of your copyright/license # desired linewidth it will apply the last, most agressive attempt that it
# statements. # made. If this flag is True, however, cmake-format will print error, exit
first_comment_is_literal = False # with non-zero status code, and write-out nothing
require_valid_layout = False
# If comment markup is enabled, don't reflow any comment block which matches # A dictionary mapping layout nodes to a list of wrap decisions. See the
# this (regex) pattern. Default is `None` (disabled). # documentation for more information.
literal_comment_pattern = None layout_passes = {}
# Regular expression to match preformat fences in comments # ------------------------------------------------
# default=r'^\s*([`~]{3}[`~]*)(.*)$' # Options affecting comment reflow and formatting.
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$' # ------------------------------------------------
with section("markup"):
# Regular expression to match rulers in comments # What character to use for bulleted lists
# default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$' bullet_char = '*'
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
# If true, then insert a space between the first hash char and remaining hash # What character to use as punctuation after numerals in an enumerated list
# chars in a hash ruler, and normalize it's length to fill the column enum_char = '.'
canonicalize_hashrulers = True
# If comment markup is enabled, don't reflow the first comment block in each
# listfile. Use this to preserve formatting of your copyright/license
# statements.
first_comment_is_literal = False
# --------------------------------- # If comment markup is enabled, don't reflow any comment block which matches
# Miscellaneous Options # this (regex) pattern. Default is `None` (disabled).
# --------------------------------- literal_comment_pattern = None
# If true, emit the unicode byte-order mark (BOM) at the start of the file
emit_byteorder_mark = False
# Specify the encoding of the input file. Defaults to utf-8. # Regular expression to match preformat fences in comments default=
input_encoding = 'utf-8' # ``r'^\s*([`~]{3}[`~]*)(.*)$'``
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake # Regular expression to match rulers in comments default=
# only claims to support utf-8 so be careful when using anything else # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
output_encoding = 'utf-8' ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
# If a comment line matches starts with this pattern then it is explicitly a
# trailing comment for the preceeding argument. Default is '#<'
explicit_trailing_pattern = '#<'
# If a comment line starts with at least this many consecutive hash
# characters, then don't lstrip() them off. This allows for lazy hash rulers
# where the first hash char is not separated by space
hashruler_min_length = 10
# If true, then insert a space between the first hash char and remaining hash
# chars in a hash ruler, and normalize its length to fill the column
canonicalize_hashrulers = True
# enable comment markup parsing and reflow
enable_markup = False
# ----------------------------
# Options affecting the linter
# ----------------------------
with section("lint"):
# a list of lint codes to disable
disabled_codes = []
# regular expression pattern describing valid function names
function_pattern = '[0-9a-z_]+'
# regular expression pattern describing valid macro names
macro_pattern = '[0-9A-Z_]+'
# regular expression pattern describing valid names for variables with global
# scope
global_var_pattern = '[0-9A-Z][0-9A-Z_]+'
# regular expression pattern describing valid names for variables with global
# scope (but internal semantic)
internal_var_pattern = '_[0-9A-Z][0-9A-Z_]+'
# regular expression pattern describing valid names for variables with local
# scope
local_var_pattern = '[0-9a-z_]+'
# regular expression pattern describing valid names for privatedirectory
# variables
private_var_pattern = '_[0-9a-z_]+'
# regular expression pattern describing valid names for publicdirectory
# variables
public_var_pattern = '[0-9A-Z][0-9A-Z_]+'
# regular expression pattern describing valid names for keywords used in
# functions or macros
keyword_pattern = '[0-9A-Z_]+'
# In the heuristic for C0201, how many conditionals to match within a loop in
# before considering the loop a parser.
max_conditionals_custom_parser = 2
# Require at least this many newlines between statements
min_statement_spacing = 1
# Require no more than this many newlines between statements
max_statement_spacing = 1
max_returns = 6
max_branches = 12
max_arguments = 5
max_localvars = 15
max_statements = 50
# -------------------------------
# Options affecting file encoding
# -------------------------------
with section("encode"):
# If true, emit the unicode byte-order mark (BOM) at the start of the file
emit_byteorder_mark = False
# Specify the encoding of the input file. Defaults to utf-8
input_encoding = 'utf-8'
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
# only claims to support utf-8 so be careful when using anything else
output_encoding = 'utf-8'
# -------------------------------------
# Miscellaneous configurations options.
# -------------------------------------
with section("misc"):
# A dictionary containing any per-command configuration overrides. Currently
# only `command_case` is supported.
per_command = {}

View File

@ -1,13 +1,13 @@
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_SOURCE_GENERATOR TXZ) set(CPACK_SOURCE_GENERATOR TXZ)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMLIB_PROJECT_NAME_LOWER}-${CPACK_PACKAGE_VERSION}")
set(CPACK_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) set(CPACK_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CPACK_TARGET_ARCH "amd64") set(CPACK_TARGET_ARCH "amd64")
endif() endif()
set(CPACK_PACKAGE_FILE_NAME set(CPACK_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}") "${CMLIB_PROJECT_NAME_LOWER}_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}")
include(CPack) include(CPack)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)

View File

@ -16,9 +16,8 @@ function(add_code_coverage)
add_custom_target( add_custom_target(
coverage-${_target} coverage-${_target}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND COMMAND ${LCOV_EXE} --test-name ${_target} --output "${_target}.lcov" --capture
${LCOV_EXE} --test-name ${_target} --output "${_target}.lcov" --capture --directory ${CMAKE_BINARY_DIR})
--directory ${CMAKE_BINARY_DIR})
add_dependencies(coverage-${_target} ${_target}) add_dependencies(coverage-${_target} ${_target})
if(GENHTML_EXE) if(GENHTML_EXE)

View File

@ -19,6 +19,7 @@ include(CMLibProjectVersion)
set_project_version() set_project_version()
include(CMLibRequiredVariables) include(CMLibRequiredVariables)
include(CMLibGlobalFunctions)
include(CMLibGlobalVariables) include(CMLibGlobalVariables)
include(CMLibLSBInfo) include(CMLibLSBInfo)
include(CMLibCompiler) include(CMLibCompiler)

View File

@ -28,14 +28,9 @@ function(add_common_library)
set_target_properties( set_target_properties(
${LIBNAME}_shared ${LIBNAME}_shared
PROPERTIES PROPERTIES
VERSION VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} OUTPUT_NAME
${PROJECT_VERSION} ${OUTNAME}
SOVERSION LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
${PROJECT_VERSION_MAJOR}
OUTPUT_NAME
${OUTNAME}
LIBRARY_OUTPUT_DIRECTORY
${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${LIBNAME}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS ${LIBNAME}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif() endif()
@ -43,7 +38,7 @@ function(add_common_library)
add_library(${LIBNAME}_static STATIC $<TARGET_OBJECTS:${LIBNAME}>) add_library(${LIBNAME}_static STATIC $<TARGET_OBJECTS:${LIBNAME}>)
set_target_properties( set_target_properties(
${LIBNAME}_static PROPERTIES OUTPUT_NAME ${OUTNAME} ARCHIVE_OUTPUT_DIRECTORY ${LIBNAME}_static PROPERTIES OUTPUT_NAME ${OUTNAME} ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_INSTALL_LIBDIR}) ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${LIBNAME}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS ${LIBNAME}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif() endif()

View File

@ -7,7 +7,10 @@ function(common_target_properties Name)
set(__interface 1) set(__interface 1)
set(__visibility INTERFACE) set(__visibility INTERFACE)
endif() endif()
target_compile_features(${Name} ${__visibility} ${COMMON_CXX_FEATURES}) target_compile_features(
${Name}
${__visibility}
${COMMON_CXX_FEATURES})
get_target_property(_targetType ${Name} TYPE) get_target_property(_targetType ${Name} TYPE)
if(_targetType STREQUAL "EXECUTABLE" AND CMAKE_CXX_COMPILE_OPTIONS_PIE) if(_targetType STREQUAL "EXECUTABLE" AND CMAKE_CXX_COMPILE_OPTIONS_PIE)
target_compile_options(${Name} PUBLIC "${CMAKE_CXX_COMPILE_OPTIONS_PIE}") target_compile_options(${Name} PUBLIC "${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
@ -19,7 +22,10 @@ function(common_target_properties Name)
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>) $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
if(APPLE) if(APPLE)
target_compile_definitions(${Name} ${__visibility} Darwin) target_compile_definitions(
${Name}
${__visibility}
Darwin)
endif() endif()
if(NOT __interface) if(NOT __interface)
if(TARGET Qt5::Core) if(TARGET Qt5::Core)

View File

@ -3,10 +3,6 @@ function(cmlib_config_hpp_generate)
cmlib_test_large_files(HAVE_LARGEFILES) cmlib_test_large_files(HAVE_LARGEFILES)
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT) get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
string(TOLOWER ${ORGANIZATION_NAME} ORGANIZATION_NAME_LOWER)
string(TOUPPER ${ORGANIZATION_NAME} ORGANIZATION_NAME_UPPER)
string(TOLOWER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_LOWER)
string(TOUPPER ${CMAKE_PROJECT_NAME} CMAKE_PROJECT_NAME_UPPER)
configure_file(${CMLIB_MODULE_DIR}/hpp/cmlib_config.hpp.in configure_file(${CMLIB_MODULE_DIR}/hpp/cmlib_config.hpp.in
${CMAKE_BINARY_DIR}/include/cmlib_config.hpp) ${CMAKE_BINARY_DIR}/include/cmlib_${CMLIB_PROJECT_NAME_LOWER}_config.hpp)
endfunction() endfunction()

View File

@ -53,10 +53,10 @@ function(add_breathe_target)
configure_file(${DOXY_FILE} ${WORK_DIR}/Doxyfile @ONLY) configure_file(${DOXY_FILE} ${WORK_DIR}/Doxyfile @ONLY)
add_custom_target( add_custom_target(
${_BREATHE_TARGET_NAME} VERBATIM ${_BREATHE_TARGET_NAME}
COMMAND VERBATIM
${SPHINX_EXECUTABLE} -q -b html -c ${WORK_DIR} -d ${WORK_DIR}/cache ${WORK_DIR} COMMAND ${SPHINX_EXECUTABLE} -q -b html -c ${WORK_DIR} -d ${WORK_DIR}/cache
${CMAKE_BINARY_DIR}/doc/breathe ${WORK_DIR} ${CMAKE_BINARY_DIR}/doc/breathe
COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe") COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe")
set(INDEX_MD_FILE ${CMAKE_SOURCE_DIR}/doc/breathe/index.md.in) set(INDEX_MD_FILE ${CMAKE_SOURCE_DIR}/doc/breathe/index.md.in)
@ -65,7 +65,8 @@ function(add_breathe_target)
file(GLOB MD_FILES ${CMAKE_SOURCE_DIR}/doc/breathe/*.md) file(GLOB MD_FILES ${CMAKE_SOURCE_DIR}/doc/breathe/*.md)
if(MD_FILES) if(MD_FILES)
add_custom_command( add_custom_command(
TARGET ${_BREATHE_TARGET_NAME} PRE_BUILD TARGET ${_BREATHE_TARGET_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MD_FILES} ${WORK_DIR}) COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MD_FILES} ${WORK_DIR})
endif() endif()
endif() endif()
@ -76,13 +77,15 @@ function(add_breathe_target)
file(GLOB RST_FILES ${CMAKE_SOURCE_DIR}/doc/breathe/*.rst) file(GLOB RST_FILES ${CMAKE_SOURCE_DIR}/doc/breathe/*.rst)
if(RST_FILES) if(RST_FILES)
add_custom_command( add_custom_command(
TARGET ${_BREATHE_TARGET_NAME} PRE_BUILD TARGET ${_BREATHE_TARGET_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RST_FILES} ${WORK_DIR}) COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RST_FILES} ${WORK_DIR})
endif() endif()
endif() endif()
else() else()
add_custom_target( add_custom_target(
${_BREATHE_TARGET_NAME} VERBATIM ${_BREATHE_TARGET_NAME}
VERBATIM
COMMENT "Breathe is not found. Skipping target ${_BREATHE_TARGET_NAME} build") COMMENT "Breathe is not found. Skipping target ${_BREATHE_TARGET_NAME} build")
endif() endif()
endfunction() endfunction()

View File

@ -40,14 +40,16 @@ function(add_doxygen_target)
configure_file(${CMAKE_SOURCE_DIR}/cmake/doc/Doxyfile.in ${WORK_DIR}/Doxyfile @ONLY) configure_file(${CMAKE_SOURCE_DIR}/cmake/doc/Doxyfile.in ${WORK_DIR}/Doxyfile @ONLY)
add_custom_target( add_custom_target(
${_DOXYGEN_TARGET_NAME} VERBATIM ${_DOXYGEN_TARGET_NAME}
VERBATIM
COMMAND "${CMAKE_COMMAND}" -E remove -f "${WORK_DIR}/doxygen_sqlite3.db" COMMAND "${CMAKE_COMMAND}" -E remove -f "${WORK_DIR}/doxygen_sqlite3.db"
COMMAND ${DOXYGEN_EXECUTABLE} ${WORK_DIR}/Doxyfile COMMAND ${DOXYGEN_EXECUTABLE} ${WORK_DIR}/Doxyfile
WORKING_DIRECTORY ${WORK_DIR} WORKING_DIRECTORY ${WORK_DIR}
COMMENT "Generating API documentation with Doxygen") COMMENT "Generating API documentation with Doxygen")
else() else()
add_custom_target( add_custom_target(
${_DOXYGEN_TARGET_NAME} VERBATIM ${_DOXYGEN_TARGET_NAME}
VERBATIM
COMMENT "Doxygen is not found. Skipping target ${_DOXYGEN_TARGET_NAME} build") COMMENT "Doxygen is not found. Skipping target ${_DOXYGEN_TARGET_NAME} build")
endif() endif()
endfunction() endfunction()

View File

@ -51,8 +51,8 @@ macro(remove_flag_from_file _target _file _flag)
endif() endif()
# Apply the compile flags to the current source file. # Apply the compile flags to the current source file.
string(REPLACE ";" " " _source_file_cxx_flags_string "${_source_file_cxx_flags}") string(REPLACE ";" " " _source_file_cxx_flags_string "${_source_file_cxx_flags}")
set_source_files_properties(${_source_file} PROPERTIES COMPILE_FLAGS set_source_files_properties(
"${_source_file_cxx_flags_string}") ${_source_file} PROPERTIES COMPILE_FLAGS "${_source_file_cxx_flags_string}")
endforeach() endforeach()
endif() endif()
list(FIND _target_sources ${_file} _file_found_at) list(FIND _target_sources ${_file} _file_found_at)
@ -70,7 +70,7 @@ macro(remove_flag_from_file _target _file _flag)
list(REMOVE_ITEM _cached_${_target}_${_file}_cxx_flags ${_flag}) list(REMOVE_ITEM _cached_${_target}_${_file}_cxx_flags ${_flag})
string(REPLACE ";" " " _cached_${_target}_${_file}_cxx_flags_string string(REPLACE ";" " " _cached_${_target}_${_file}_cxx_flags_string
"${_cached_${_target}_${_file}_cxx_flags}") "${_cached_${_target}_${_file}_cxx_flags}")
set_source_files_properties(${_file} PROPERTIES COMPILE_FLAGS set_source_files_properties(
"${_cached_${_target}_${_file}_cxx_flags_string}") ${_file} PROPERTIES COMPILE_FLAGS "${_cached_${_target}_${_file}_cxx_flags_string}")
endif() endif()
endmacro() endmacro()

View File

@ -24,8 +24,8 @@ function(add_format_sources)
find_program(DOS2UNIX_EXE NAMES dos2unix) find_program(DOS2UNIX_EXE NAMES dos2unix)
if(DOS2UNIX_EXE) if(DOS2UNIX_EXE)
list(APPEND DOS2UNIX_OPTS -k -r) list(APPEND DOS2UNIX_OPTS -k -r)
add_custom_target(format-sources-dos2unix-${_target} COMMAND ${DOS2UNIX_EXE} ${DOS2UNIX_OPTS} add_custom_target(format-sources-dos2unix-${_target}
${_sources}) COMMAND ${DOS2UNIX_EXE} ${DOS2UNIX_OPTS} ${_sources})
add_dependencies(format-sources format-sources-dos2unix-${_target}) add_dependencies(format-sources format-sources-dos2unix-${_target})
else() else()
message(STATUS "CMLIB warning:") message(STATUS "CMLIB warning:")

View File

@ -0,0 +1,7 @@
function(canonical_string INV OUTV)
string(TOUPPER ${INV} _arg_uppercase)
string(REGEX REPLACE "[ -]" "_" _arg_fixed ${_arg_uppercase})
set(${OUTV}
${_arg_fixed}
PARENT_SCOPE)
endfunction()

View File

@ -1,7 +1,8 @@
# CMLIB_PROJECT_NAME_CANONICAL canonical_string(PROJECT_NAME CMLIB_PROJECT_NAME_CANONICAL)
string(TOUPPER ${PROJECT_NAME} _project_name_uppercase) canonical_string(ORGANIZATION_NAME CMLIB_ORGANIZATION_NAME_CANONICAL)
string(REGEX REPLACE "[ -]" "_" _project_name_fixed ${_project_name_uppercase})
set(CMLIB_PROJECT_NAME_CANONICAL ${_project_name_fixed}) string(TOLOWER ${CMLIB_ORGANIZATION_NAME_CANONICAL} CMLIB_ORGANIZATION_NAME_LOWER)
string(TOLOWER ${CMLIB_PROJECT_NAME_CANONICAL} CMLIB_PROJECT_NAME_LOWER)
# CMLIB_MODULE_DIR # CMLIB_MODULE_DIR
foreach(_m ${CMAKE_MODULE_PATH}) foreach(_m ${CMAKE_MODULE_PATH})

View File

@ -20,19 +20,13 @@ if(EXISTS /etc/mcst_version)
else() else()
find_program(_lsb_release_executable lsb_release) find_program(_lsb_release_executable lsb_release)
if(_lsb_release_executable) if(_lsb_release_executable)
execute_process( execute_process(COMMAND ${_lsb_release_executable} -si
COMMAND ${_lsb_release_executable} -si OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process( execute_process(COMMAND ${_lsb_release_executable} -sc
COMMAND ${_lsb_release_executable} -sc OUTPUT_VARIABLE LSB_CODENAME OUTPUT_STRIP_TRAILING_WHITESPACE)
OUTPUT_VARIABLE LSB_CODENAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process( execute_process(COMMAND ${_lsb_release_executable} -sr
COMMAND ${_lsb_release_executable} -sr OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
OUTPUT_VARIABLE LSB_RELEASE
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif() endif()
endif() endif()

View File

@ -1,21 +0,0 @@
# read file cmake/etc/organization.txt and set global property ORGANIZATION_NAME
function(set_organization_name)
set(_organization_file "${CMAKE_SOURCE_DIR}/cmake/etc/organization.txt")
if(NOT EXISTS "${_organization_file}")
message(FATAL_ERROR "File ${ORGANIZATION_FILE} doesn't exist")
endif()
file(READ "${_organization_file}" _org)
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS ${_organization_file})
if(NOT "${_org}" MATCHES "^([0-9A-Za-z ,.]+)\n")
message(FATAL_ERROR "File ${_organization_file} has wrong format")
endif()
string(REGEX MATCH "^([0-9A-Za-z ,.]+)\n" _ ${_org})
set_property(GLOBAL PROPERTY ORGANIZATION_NAME ${CMAKE_MATCH_1})
endfunction()

View File

@ -1,6 +1,8 @@
#ifndef @CMLIB_PROJECT_NAME_CANONICAL@_CMLIB_CONFIG_HPP_ #ifndef @CMLIB_PROJECT_NAME_CANONICAL@_CMLIB_CONFIG_HPP_
#define @CMLIB_PROJECT_NAME_CANONICAL@_CMLIB_CONFIG_HPP_ #define @CMLIB_PROJECT_NAME_CANONICAL@_CMLIB_CONFIG_HPP_
#pragma once
#define @CMLIB_PROJECT_NAME_CANONICAL@_VERSION_STR "@PROJECT_VERSION@" #define @CMLIB_PROJECT_NAME_CANONICAL@_VERSION_STR "@PROJECT_VERSION@"
#define @CMLIB_PROJECT_NAME_CANONICAL@_VERSION_INT @PROJECT_VERSION_INT@ #define @CMLIB_PROJECT_NAME_CANONICAL@_VERSION_INT @PROJECT_VERSION_INT@
#define ORGANIZATION_NAME "@ORGANIZATION_NAME@" #define ORGANIZATION_NAME "@ORGANIZATION_NAME@"

@ -1 +1 @@
Subproject commit dfa7faf459634501a7b76944ad264d5959f14615 Subproject commit 26eced86d8e759c625b697f6b0588d7a28746725