summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2022-06-01 17:31:03 -0400
committerAllen Winter <allen.winter@kdab.com>2022-06-01 17:32:28 -0400
commitacf22732a262139e1710330bb102bb7fe54c3fe1 (patch)
treea1254be9ba2b6d5ec6ad87969b9d14ffafed1dc2
parentab8c10c88b987e756e746b63f1a7b29668a338bd (diff)
downloadlibical-git-acf22732a262139e1710330bb102bb7fe54c3fe1.tar.gz
CMake files - cmake-linting
-rw-r--r--.cmake-format.py241
-rw-r--r--.krazy1
-rw-r--r--CMakeLists.txt88
-rw-r--r--cmake/modules/FindGObjectIntrospection.cmake3
-rw-r--r--cmake/modules/GObjectIntrospectionMacros.cmake58
-rw-r--r--cmake/modules/GtkDoc.cmake38
-rw-r--r--cmake/modules/LibIcalMacrosInternal.cmake9
-rw-r--r--cmake/run_test.cmake6
-rw-r--r--doc/CMakeLists.txt2
-rw-r--r--src/test/CMakeLists.txt13
10 files changed, 401 insertions, 58 deletions
diff --git a/.cmake-format.py b/.cmake-format.py
new file mode 100644
index 00000000..b78b7969
--- /dev/null
+++ b/.cmake-format.py
@@ -0,0 +1,241 @@
+# ----------------------------------
+# Options affecting listfile parsing
+# ----------------------------------
+with section("parse"):
+
+ # Specify structure for custom cmake functions
+ additional_commands = { 'foo': { 'flags': ['BAR', 'BAZ'],
+ 'kwargs': {'DEPENDS': '*', 'HEADERS': '*', 'SOURCES': '*'}}}
+
+ # Override configurations per-command where available
+ override_spec = {}
+
+ # Specify variable tags.
+ vartags = []
+
+ # Specify property tags.
+ proptags = []
+
+# -----------------------------
+# Options affecting formatting.
+# -----------------------------
+with section("format"):
+
+ # Disable formatting entirely, making cmake-format a no-op
+ disable = False
+
+ # How wide to allow formatted cmake files
+ line_width = 120
+
+ # How many spaces to tab for indent
+ tab_size = 2
+
+ # If true, lines are indented using tab characters (utf-8 0x09) instead of
+ # <tab_size> space characters (utf-8 0x20). In cases where the layout would
+ # require a fractional tab character, the behavior of the fractional
+ # indentation is governed by <fractional_tab_policy>
+ use_tabchars = False
+
+ # If <use_tabchars> is True, then the value of this variable indicates how
+ # fractional indentions are handled during whitespace replacement. If set to
+ # 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
+ # to `round-up` fractional indentation is replaced with a single tab character
+ # (utf-8 0x09) effectively shifting the column to the next tabstop
+ fractional_tab_policy = 'use-space'
+
+ # If an argument group contains more than this many sub-groups (parg or kwarg
+ # groups) then force it to a vertical layout.
+ max_subgroups_hwrap = 2
+
+ # If a positional argument group contains more than this many arguments, then
+ # force it to a vertical layout.
+ max_pargs_hwrap = 6
+
+ # If a cmdline positional group consumes more than this many lines without
+ # nesting, then invalidate the layout (and nest)
+ max_rows_cmdline = 2
+
+ # If true, separate flow control names from their parentheses with a space
+ separate_ctrl_name_with_space = False
+
+ # If true, separate function names from parentheses with a space
+ separate_fn_name_with_space = False
+
+ # If a statement is wrapped to more than one line, than dangle the closing
+ # parenthesis on its own line.
+ dangle_parens = False
+
+ # If the trailing parenthesis must be 'dangled' on its on line, then align it
+ # 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'
+
+ # If the statement spelling length (including space and parenthesis) is
+ # smaller than this amount, then force reject nested layouts.
+ min_prefix_chars = 4
+
+ # If the statement spelling length (including space and parenthesis) is larger
+ # than the tab width by more than this amount, then force reject un-nested
+ # layouts.
+ max_prefix_chars = 10
+
+ # If a candidate layout is wrapped horizontally but it exceeds this many
+ # lines, then reject the layout.
+ max_lines_hwrap = 2
+
+ # What style line endings to use in the output.
+ line_ending = 'unix'
+
+ # Format command names consistently as 'lower' or 'upper' case
+ command_case = 'lower'
+
+ # Format keywords consistently as 'lower' or 'upper' case
+ keyword_case = 'upper'
+
+ # A list of command names which should always be wrapped
+ always_wrap = []
+
+ # If true, the argument lists which are known to be sortable will be sorted
+ # lexicographicall
+ enable_sort = True
+
+ # If true, the parsers may infer whether or not an argument list is sortable
+ # (without annotation).
+ autosort = False
+
+ # By default, if cmake-format cannot successfully fit everything into the
+ # desired linewidth it will apply the last, most agressive attempt that it
+ # made. If this flag is True, however, cmake-format will print error, exit
+ # with non-zero status code, and write-out nothing
+ require_valid_layout = False
+
+ # A dictionary mapping layout nodes to a list of wrap decisions. See the
+ # documentation for more information.
+ layout_passes = {}
+
+# ------------------------------------------------
+# Options affecting comment reflow and formatting.
+# ------------------------------------------------
+with section("markup"):
+
+ # What character to use for bulleted lists
+ bullet_char = '*'
+
+ # What character to use as punctuation after numerals in an enumerated list
+ enum_char = '.'
+
+ # 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
+ # this (regex) pattern. Default is `None` (disabled).
+ literal_comment_pattern = None
+
+ # Regular expression to match preformat fences in comments default=
+ # ``r'^\s*([`~]{3}[`~]*)(.*)$'``
+ fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
+
+ # Regular expression to match rulers in comments default=
+ # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
+ 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 = True
+
+# ----------------------------
+# 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
+ # (cache) scope
+ global_var_pattern = '[A-Z][0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for variables with global
+ # scope (but internal semantic)
+ internal_var_pattern = '[A-Z][0-9A-Z_]+'
+
+ # regular expression pattern describing valid names for variables with local
+ # scope
+ local_var_pattern = '[a-z][a-z0-9_]+'
+
+ # regular expression pattern describing valid names for privatedirectory
+ # variables
+ private_var_pattern = '[0-9a-z_]+'
+
+ # regular expression pattern describing valid names for public directory
+ # variables
+ public_var_pattern = '.*'
+
+ # regular expression pattern describing valid names for function/macro
+ # arguments and loop variables.
+ argument_var_pattern = '[a-z_][a-z0-9_]+'
+
+ # regular expression pattern describing valid names for keywords used in
+ # functions or macros
+ keyword_pattern = '[A-Z][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 = 2
+ max_returns = 6
+ max_branches = 15
+ max_arguments = 10
+ 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 = {}
+
diff --git a/.krazy b/.krazy
index 1675131f..ae81b742 100644
--- a/.krazy
+++ b/.krazy
@@ -17,6 +17,7 @@ SKIP /examples/
SKIP /java/
#For now skip python
SKIP /python/
+SKIP \.cmake-format\.py
#For now skip perl
SKIP /Net-ICal-Libical/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2d54c5d0..f8929603 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -128,7 +128,10 @@ if(MSVC)
endif()
endif()
if(BAD_C_MESSAGE)
- message(FATAL_ERROR "\nSorry, ${BAD_C_MESSAGE} is required to build this software. Please retry using a modern C compiler that supports the C99 standard.")
+ message(FATAL_ERROR
+ "\nSorry, ${BAD_C_MESSAGE} is required to build this software. "
+ "Please retry using a modern C compiler that supports the C99 standard."
+ )
endif()
# Enable the test harness
@@ -182,7 +185,10 @@ if(STATIC_ONLY)
set(LIBRARY_TYPE STATIC)
endif()
-libical_option(SHARED_ONLY "Build shared (dynamic) libraries only. Takes precedence over STATIC_ONLY." False)
+libical_option(SHARED_ONLY
+ "Build shared (dynamic) libraries only. Takes precedence over STATIC_ONLY."
+ False
+)
if(SHARED_ONLY)
set(STATIC_ONLY False)
set(LIBRARY_TYPE SHARED)
@@ -263,7 +269,7 @@ if(ICU_FOUND)
message(FATAL_ERROR
"Unable to locate the ICU runtime path. Is your ICU installation broken?")
endif()
- set(ICU_BINARY_DIR ${ICU_EXEC} CACHE STRING DOC "Runtime binaries directory for the ICU library")
+ set(ICU_BINARY_DIR ${ICU_EXEC} CACHE STRING "Runtime binaries directory for the ICU library")
endif()
# compile in Berkeley DB support
@@ -304,7 +310,10 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
if(WIN32)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DYY_NO_UNISTD_H)
- libical_option(USE_32BIT_TIME_T "Build using a 32bit time_t (ignored unless building with MSVC on Windows)." False)
+ libical_option(USE_32BIT_TIME_T
+ "Build using a 32bit time_t (ignored unless building with MSVC on Windows)."
+ False
+ )
if(USE_32BIT_TIME_T)
add_definitions(-D_USE_32BIT_TIME_T)
endif()
@@ -334,14 +343,20 @@ else()
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
endif()
-libical_option(ICAL_ERRORS_ARE_FATAL "icalerror_* calls will abort instead of internally signaling an error." False)
+libical_option(ICAL_ERRORS_ARE_FATAL
+ "icalerror_* calls will abort instead of internally signaling an error."
+ False
+)
if(ICAL_ERRORS_ARE_FATAL)
set(ICAL_ERRORS_ARE_FATAL 1)
else()
set(ICAL_ERRORS_ARE_FATAL 0)
endif()
-libical_option(ICAL_ALLOW_EMPTY_PROPERTIES "Prevents empty properties from being replaced with X-LIC-ERROR properties." False)
+libical_option(ICAL_ALLOW_EMPTY_PROPERTIES
+ "Prevents empty properties from being replaced with X-LIC-ERROR properties."
+ False
+)
if(ICAL_ALLOW_EMPTY_PROPERTIES)
set(ICAL_ALLOW_EMPTY_PROPERTIES 1)
else()
@@ -353,7 +368,12 @@ if(WIN32 OR WINCE)
else()
set(DEF_USE_BUILTIN_TZDATA False)
endif()
-libical_option(USE_BUILTIN_TZDATA "(Careful) Build using libical's built-in timezone data, else use the system timezone data on non-Windows systems. ALWAYS true on Windows. Non-Windows users should know what they're doing if they choose not to use system provided timezone data. The libical project does not guarantee that the built-in timezone data is up-to-date." ${DEF_USE_BUILTIN_TZDATA})
+libical_option(USE_BUILTIN_TZDATA
+ "(Careful) Build using libical's built-in timezone data, else use the system timezone data on non-Windows systems. "
+ "ALWAYS true on Windows. Non-Windows users should know what they're doing if they choose not to use system provided "
+ "timezone data. The libical project does not guarantee that the built-in timezone data is up-to-date."
+ ${DEF_USE_BUILTIN_TZDATA}
+)
mark_as_advanced(USE_BUILTIN_TZDATA)
if(USE_BUILTIN_TZDATA)
set(USE_BUILTIN_TZDATA 1)
@@ -386,7 +406,11 @@ set(INSTALL_TARGETS_DEFAULT_ARGS
find_package(PkgConfig QUIET)
set(MIN_GOBJECT_INTROSPECTION "0.6.7")
-libical_option(GOBJECT_INTROSPECTION "Build GObject introspection \"typelib\" files. Requires GObject Introspection development package ${MIN_GOBJECT_INTROSPECTION} or higher." False)
+libical_option(GOBJECT_INTROSPECTION
+ "Build GObject introspection \"typelib\" files. "
+ "Requires GObject Introspection development package ${MIN_GOBJECT_INTROSPECTION} or higher."
+ False
+)
if(GOBJECT_INTROSPECTION)
if(NOT PKG_CONFIG_FOUND)
message(FATAL_ERROR
@@ -452,7 +476,11 @@ endif()
set(MIN_GLIB "2.44")
set(MIN_LIBXML "2.7.3")
-libical_option(ICAL_GLIB "Build libical-glib interface. Requires glib ${MIN_GLIB} and libxml ${MIN_LIBXML} development packages or higher." True)
+libical_option(ICAL_GLIB
+ "Build libical-glib interface. "
+ "Requires glib ${MIN_GLIB} and libxml ${MIN_LIBXML} development packages or higher."
+ True
+)
if(ICAL_GLIB)
if(NOT PKG_CONFIG_FOUND)
message(FATAL_ERROR
@@ -507,7 +535,11 @@ if(DEFINED CMAKE_C_COMPILER_ID)
endif()
endif()
if(CMAKE_C_COMPILER_IS_GCC OR CMAKE_C_COMPILER_IS_CLANG)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -Wno-deprecated -Wall -Wno-unknown-pragmas -Wextra -Winit-self -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wtype-limits -Wwrite-strings -Werror=return-type")
+ set(CMAKE_C_FLAGS
+ "${CMAKE_C_FLAGS} -fvisibility=hidden "
+ "-Wno-deprecated -Wall -Wno-unknown-pragmas -Wextra -Winit-self -Wunused -Wno-div-by-zero "
+ "-Wundef -Wpointer-arith -Wtype-limits -Wwrite-strings -Werror=return-type"
+ )
libical_add_cflag(-Wunused-but-set-variable UNUSED_BUT_SET)
libical_add_cflag(-Wlogical-op LOGICAL_OP)
libical_add_cflag(-Wsizeof-pointer-memaccess POINTER_MEMACCESS)
@@ -531,7 +563,11 @@ if(DEFINED CMAKE_CXX_COMPILER_ID)
endif()
endif()
if(CMAKE_CXX_COMPILER_IS_GCC OR CMAKE_CXX_COMPILER_IS_CLANG)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Weffc++ -Wno-deprecated -Wall -Wextra -Woverloaded-virtual -Winit-self -Wunused -Wno-div-by-zero -Wundef -Wpointer-arith -Wtype-limits -Wwrite-strings -Werror=return-type")
+ set(CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} -fvisibility=hidden "
+ "-Weffc++ -Wno-deprecated -Wall -Wextra -Woverloaded-virtual -Winit-self -Wunused "
+ "-Wno-div-by-zero -Wundef -Wpointer-arith -Wtype-limits -Wwrite-strings -Werror=return-type"
+ )
libical_add_cxxflag(-Wunused-but-set-variable UNUSED_BUT_SET)
libical_add_cxxflag(-Wlogical-op LOGICAL_OP)
libical_add_cxxflag(-Wsizeof-pointer-memaccess POINTER_MEMACCESS)
@@ -552,7 +588,11 @@ if(SIZEOF_TIME_T EQUAL 4)
endif()
################ Developer Options #####################
-libical_deprecated_option(ABI_DUMPER LIBICAL_DEVMODE_ABI_DUMPER "(Developer-only) Build for abi-dumper." False)
+libical_deprecated_option(ABI_DUMPER
+ LIBICAL_DEVMODE_ABI_DUMPER
+ "(Developer-only) Build for abi-dumper."
+ False
+)
mark_as_advanced(LIBICAL_DEVMODE_ABI_DUMPER)
if(LIBICAL_DEVMODE_ABI_DUMPER)
if(CMAKE_C_COMPILER_IS_GCC)
@@ -564,14 +604,21 @@ if(LIBICAL_DEVMODE_ABI_DUMPER)
endif()
endif()
-libical_option(LIBICAL_DEVMODE_MEMORY_CONSISTENCY "(Developer-only) Build with memory consistency functions." False)
+libical_option(LIBICAL_DEVMODE_MEMORY_CONSISTENCY
+ "(Developer-only) Build with memory consistency functions."
+ False
+)
if(LIBICAL_DEVMODE_MEMORY_CONSISTENCY)
set(CMAKE_BUILD_TYPE "Debug")
add_definitions(-DMEMORY_CONSISTENCY)
endif()
mark_as_advanced(LIBICAL_DEVMODE_MEMORY_CONSISTENCY)
-libical_deprecated_option(ADDRESS_SANITIZER LIBICAL_DEVMODE_ADDRESS_SANITIZER "(Developer-only) Build with the address sanitizer." False)
+libical_deprecated_option(ADDRESS_SANITIZER
+ LIBICAL_DEVMODE_ADDRESS_SANITIZER
+ "(Developer-only) Build with the address sanitizer."
+ False
+)
mark_as_advanced(LIBICAL_DEVMODE_ADDRESS_SANITIZER)
if(LIBICAL_DEVMODE_ADDRESS_SANITIZER)
if(CMAKE_C_COMPILER_IS_GCC OR CMAKE_C_COMPILER_IS_CLANG)
@@ -597,7 +644,11 @@ if(LIBICAL_DEVMODE_ADDRESS_SANITIZER)
endif()
endif()
-libical_deprecated_option(THREAD_SANITIZER LIBICAL_DEVMODE_THREAD_SANITIZER "(Developer-only) Build with the thread sanitizer." False)
+libical_deprecated_option(THREAD_SANITIZER
+ LIBICAL_DEVMODE_THREAD_SANITIZER
+ "(Developer-only) Build with the thread sanitizer."
+ False
+)
mark_as_advanced(LIBICAL_DEVMODE_THREAD_SANITIZER)
if(LIBICAL_DEVMODE_THREAD_SANITIZER)
if(CMAKE_C_COMPILER_IS_GCC OR CMAKE_C_COMPILER_IS_CLANG)
@@ -623,7 +674,11 @@ if(LIBICAL_DEVMODE_THREAD_SANITIZER)
endif()
endif()
-libical_deprecated_option(UNDEFINED_SANITIZER LIBICAL_DEVMODE_UNDEFINED_SANITIZER "(Developer-only) Build with the undefined sanitizer." False)
+libical_deprecated_option(UNDEFINED_SANITIZER
+ LIBICAL_DEVMODE_UNDEFINED_SANITIZER
+ "(Developer-only) Build with the undefined sanitizer."
+ False
+)
mark_as_advanced(LIBICAL_DEVMODE_UNDEFINED_SANITIZER)
if(LIBICAL_DEVMODE_UNDEFINED_SANITIZER)
if(CMAKE_C_COMPILER_IS_GCC OR CMAKE_C_COMPILER_IS_CLANG)
@@ -768,6 +823,7 @@ if(NOT TARGET uninstall)
add_custom_target(uninstall
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
+ COMMENT "Target for uninstalling everything"
)
endif()
diff --git a/cmake/modules/FindGObjectIntrospection.cmake b/cmake/modules/FindGObjectIntrospection.cmake
index 02841f4f..07098b82 100644
--- a/cmake/modules/FindGObjectIntrospection.cmake
+++ b/cmake/modules/FindGObjectIntrospection.cmake
@@ -16,6 +16,7 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+# Get gobject-introspection's specified pkg-config variable
macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname)
execute_process(
COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_varname} gobject-introspection-1.0
@@ -27,7 +28,7 @@ macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname)
else()
string(REGEX REPLACE "[\r\n]" " " _result "${_result}")
string(REGEX REPLACE " +$" "" _result "${_result}")
- separate_arguments(_result)
+ separate_arguments(_result UNIX_COMMAND ${_result})
set(${_outvar} ${_result} CACHE INTERNAL "")
endif()
endmacro(_GIR_GET_PKGCONFIG_VAR)
diff --git a/cmake/modules/GObjectIntrospectionMacros.cmake b/cmake/modules/GObjectIntrospectionMacros.cmake
index d8b37f29..69b7e78f 100644
--- a/cmake/modules/GObjectIntrospectionMacros.cmake
+++ b/cmake/modules/GObjectIntrospectionMacros.cmake
@@ -3,6 +3,7 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+# Generate list from another list, but with each item prepended with a prefix
macro(_gir_list_prefix _outvar _listvar _prefix)
set(${_outvar})
foreach(_item IN LISTS ${_listvar})
@@ -10,13 +11,12 @@ macro(_gir_list_prefix _outvar _listvar _prefix)
endforeach()
endmacro(_gir_list_prefix)
+# cmake-lint: disable=R0915
macro(gir_add_introspections introspections_girs)
-
set(_gir_girs)
set(_gir_typelibs)
foreach(gir IN LISTS ${introspections_girs})
-
set(_gir_name "${gir}")
## Transform the gir filename to something which can reference through a variable
@@ -65,7 +65,6 @@ macro(gir_add_introspections introspections_girs)
message(ERROR "Unspecified or empty ${_gir_name}_FILES variable")
endif()
-
# Variables which provides a list of things
_gir_list_prefix(_gir_libraries ${_gir_name}_LIBS "--library=")
_gir_list_prefix(_gir_packages ${_gir_name}_PACKAGES "--pkg=")
@@ -75,45 +74,54 @@ macro(gir_add_introspections introspections_girs)
set(_gir_libtool "--no-libtool")
add_custom_command(
- COMMAND ${GObjectIntrospection_SCANNER}
- ${GObjectIntrospection_SCANNER_ARGS}
- --namespace=${_gir_namespace}
- --nsversion=${_gir_version}
- ${_gir_libtool}
- ${_gir_program}
- ${_gir_libraries}
- ${_gir_packages}
- ${_gir_includes}
- ${_gir_scannerflags}
- ${${_gir_name}_CFLAGS}
- ${_gir_files}
- --output ${CMAKE_CURRENT_BINARY_DIR}/${gir}
- --accept-unprefixed
- DEPENDS ${_gir_files}
- ${${_gir_name}_LIBS}
OUTPUT ${gir}
+ COMMAND ${GObjectIntrospection_SCANNER}
+ ${GObjectIntrospection_SCANNER_ARGS}
+ --namespace=${_gir_namespace}
+ --nsversion=${_gir_version}
+ ${_gir_libtool}
+ ${_gir_program}
+ ${_gir_libraries}
+ ${_gir_packages}
+ ${_gir_includes}
+ ${_gir_scannerflags}
+ ${${_gir_name}_CFLAGS}
+ ${_gir_files}
+ --output ${CMAKE_CURRENT_BINARY_DIR}/${gir}
+ --accept-unprefixed
+ DEPENDS ${_gir_files} ${${_gir_name}_LIBS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
VERBATIM
+ COMMENT "Run the gobject introspection scanner"
)
list(APPEND _gir_girs ${CMAKE_CURRENT_BINARY_DIR}/${gir})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${gir} DESTINATION ${SHARE_INSTALL_DIR}/gir-1.0)
string(REPLACE ".gir" ".typelib" _typelib "${gir}")
add_custom_command(
+ OUTPUT ${_typelib}
COMMAND ${GObjectIntrospection_COMPILER}
- --includedir=.
- ${CMAKE_CURRENT_BINARY_DIR}/${gir}
- -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}
+ --includedir=.
+ ${CMAKE_CURRENT_BINARY_DIR}/${gir}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir}
- OUTPUT ${_typelib}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Run the gobject introspection compiler"
)
list(APPEND _gir_typelibs ${CMAKE_CURRENT_BINARY_DIR}/${_typelib})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION ${LIB_INSTALL_DIR}/girepository-1.0)
endforeach()
- add_custom_target(gir-girs-${_gir_name} ALL DEPENDS ${_gir_girs})
- add_custom_target(gir-typelibs-${_gir_name} ALL DEPENDS ${_gir_typelibs})
+ add_custom_target(gir-girs-${_gir_name}
+ ALL
+ DEPENDS ${_gir_girs}
+ COMMENT "Target for the gobject introspection compiler"
+ )
+ add_custom_target(gir-typelibs-${_gir_name}
+ ALL
+ DEPENDS ${_gir_typelibs}
+ COMMENT "Target for the gobject introspection typelibs"
+ )
endmacro(gir_add_introspections)
diff --git a/cmake/modules/GtkDoc.cmake b/cmake/modules/GtkDoc.cmake
index d32d4b18..4234cbb0 100644
--- a/cmake/modules/GtkDoc.cmake
+++ b/cmake/modules/GtkDoc.cmake
@@ -30,13 +30,14 @@ if(NOT (GTKDOC_SCAN AND GTKDOC_MKDB AND GTKDOC_MKHTML AND GTKDOC_FIXXREF))
endif()
if(NOT TARGET gtkdocs)
- add_custom_target(gtkdocs ALL)
+ add_custom_target(gtkdocs ALL COMMENT "Target to run gtkdoc for all modules")
endif()
if(NOT TARGET gtkdoc-rebuild-sgmls)
- add_custom_target(gtkdoc-rebuild-sgmls)
+ add_custom_target(gtkdoc-rebuild-sgmls COMMENT "Target to rebuild sgml for all modules")
endif()
+# cmake-lint: disable=R0912,R0915
macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ignoreheadersvar)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in
@@ -55,7 +56,10 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign
if(APPLE)
if(NOT DEFINED ENV{XML_CATALOG_FILES})
- message(FATAL_ERROR "On OSX, please run \'export XML_CATALOG_FILES=/usr/local/etc/xml/catalog\' first; else the gtk entities cannot be located.")
+ message(FATAL_ERROR
+ "On OSX, please run \'export XML_CATALOG_FILES=/usr/local/etc/xml/catalog\' first; "
+ "else the gtk entities cannot be located."
+ )
endif()
endif()
@@ -69,7 +73,9 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign
if(TARGET ${opt})
set(_target_type)
get_target_property(_target_type ${opt} TYPE)
- if((_target_type STREQUAL "STATIC_LIBRARY") OR (_target_type STREQUAL "SHARED_LIBRARY") OR (_target_type STREQUAL "MODULE_LIBRARY"))
+ if((_target_type STREQUAL "STATIC_LIBRARY") OR
+ (_target_type STREQUAL "SHARED_LIBRARY") OR
+ (_target_type STREQUAL "MODULE_LIBRARY"))
set(_compile_options)
set(_link_libraries)
@@ -107,7 +113,9 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign
if(TARGET ${opt})
set(_target_type)
get_target_property(_target_type ${opt} TYPE)
- if((_target_type STREQUAL "STATIC_LIBRARY") OR (_target_type STREQUAL "SHARED_LIBRARY") OR (_target_type STREQUAL "MODULE_LIBRARY"))
+ if((_target_type STREQUAL "STATIC_LIBRARY") OR
+ (_target_type STREQUAL "SHARED_LIBRARY") OR
+ (_target_type STREQUAL "MODULE_LIBRARY"))
set(_output_name "")
get_target_property(_output_name ${opt} OUTPUT_NAME)
if(NOT _output_name)
@@ -181,7 +189,11 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/html"
- COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/html" ${GTKDOC_MKHTML} --path=.. ${_module} ../${_module}-docs.sgml
+ COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/html"
+ ${GTKDOC_MKHTML}
+ --path=..
+ ${_module}
+ ../${_module}-docs.sgml
COMMAND ${GTKDOC_FIXXREF}
--module=${_module}
@@ -197,6 +209,7 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign
add_custom_target(gtkdoc-${_module}
DEPENDS html/index.html
+ COMMENT "Target for running gtkdoc for module"
)
if(${_depsvar})
@@ -226,7 +239,9 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign
--rebuild-types
${_srcdirs}
- COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}" ${_scangobj_prefix} ${GTKDOC_SCANGOBJ}
+ COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}"
+ ${_scangobj_prefix}
+ ${GTKDOC_SCANGOBJ}
--module=${_module}
${_scangobj_cflags}
${_scangobj_ldflags}
@@ -240,9 +255,14 @@ macro(add_gtkdoc _module _namespace _deprecated_guards _srcdirsvar _depsvar _ign
--output-format=xml
${_srcdirs}
- COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/tmp/${_module}-docs.sgml ${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in
+ COMMAND ${CMAKE_COMMAND} -E rename
+ ${CMAKE_CURRENT_BINARY_DIR}/tmp/${_module}-docs.sgml
+ ${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in
- COMMAND ${CMAKE_COMMAND} -E echo "File '${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in' overwritten, make sure you replace generated strings with proper content before committing."
+ COMMAND ${CMAKE_COMMAND} -E echo
+ "File '${CMAKE_CURRENT_SOURCE_DIR}/${_module}-docs.sgml.in' overwritten, "
+ "make sure to replace generated strings with proper content before committing."
+ COMMENT "Target to rebuild the sgml for the specified module"
)
add_dependencies(gtkdoc-rebuild-sgmls gtkdoc-rebuild-${_module}-sgml)
diff --git a/cmake/modules/LibIcalMacrosInternal.cmake b/cmake/modules/LibIcalMacrosInternal.cmake
index ed197a15..bc527636 100644
--- a/cmake/modules/LibIcalMacrosInternal.cmake
+++ b/cmake/modules/LibIcalMacrosInternal.cmake
@@ -3,12 +3,14 @@
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
+# Call option() and then add_feature_info()
function(libical_option option description)
set(extra_option_arguments ${ARGN})
option(${option} "${description}" ${extra_option_arguments})
add_feature_info("Option ${option}" ${option} "${description}")
endfunction()
+# Warn about deprecated cmake options then call libical_option
function(libical_deprecated_option deprecated_option option description)
set(extra_option_arguments ${ARGN})
if(${deprecated_option})
@@ -18,6 +20,7 @@ function(libical_deprecated_option deprecated_option option description)
libical_option(${option} "${description}" ${extra_option_arguments})
endfunction()
+# If condition is True, append the specified value to each ARGN
function(libical_append_if condition value)
if(${condition})
foreach(variable ${ARGN})
@@ -26,11 +29,17 @@ function(libical_append_if condition value)
endif()
endfunction()
+# Create a variable C_SUPPORTS_<flag> with a boolean denoting
+# if the C compiler supports that flag; if so, append the flag
+# to the global CMAKE_C_FLAGS variable.
macro(libical_add_cflag flag name)
check_c_compiler_flag("${flag}" "C_SUPPORTS_${name}")
libical_append_if("C_SUPPORTS_${name}" "${flag}" CMAKE_C_FLAGS)
endmacro()
+# Create a variable CXX_SUPPORTS_<flag> with a boolean denoting
+# if the C++ compiler supports that flag; if so, append the flag
+# to the global CMAKE_CXX_FLAGS variable.
macro(libical_add_cxxflag flag name)
check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${name}")
libical_append_if("CXX_SUPPORTS_${name}" "${flag}" CMAKE_CXX_FLAGS)
diff --git a/cmake/run_test.cmake b/cmake/run_test.cmake
index db6c5c4d..157ae44d 100644
--- a/cmake/run_test.cmake
+++ b/cmake/run_test.cmake
@@ -16,7 +16,7 @@ if(NOT output_test)
endif()
# convert the space-separated string to a list
-separate_arguments(test_args)
+separate_arguments(test_args UNIX_COMMAND ${test_args})
execute_process(
COMMAND ${test_cmd} ${test_args}
@@ -40,5 +40,7 @@ execute_process(
)
if(test_not_successful)
- message(SEND_ERROR "Output does not match for ${output_blessed} and ${output_test}: ${err} : shell output: ${test_not_successful}!")
+ message(SEND_ERROR
+ "Output does not match for ${output_blessed} and ${output_test}: ${err} : shell output: ${test_not_successful}!"
+ )
endif()
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index e126e1ed..68b42cac 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -52,9 +52,11 @@ if(DOXYGEN_FOUND)
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
DEPENDS ${_all_hdrs} ${_dox_deps} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMENT "Run Doxygen"
)
add_custom_target(docs
DEPENDS ${CMAKE_BINARY_DIR}/apidocs/html/index.html
+ COMMENT "Target to build the documentation"
)
add_dependencies(docs ical icalss icalvcal)
if(WITH_CXX_BINDINGS)
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 8bba8747..77b85a9a 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -20,6 +20,7 @@ set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
set(TEST_DATADIR "\"${CMAKE_SOURCE_DIR}/test-data\"")
add_definitions(-DTEST_DATADIR=${TEST_DATADIR} -DTEST_ZONEDIR="${CMAKE_SOURCE_DIR}/zoneinfo")
+# Set properties for the test
macro(setprops _name)
if(UNIX)
set_tests_properties(${_name} PROPERTIES
@@ -72,6 +73,7 @@ macro(buildme _name _srcs)
endif()
endmacro()
+# Build the test and add the test, making sure the test properties are set
macro(testme _name _srcs)
buildme(${_name} "${_srcs}")
add_test(NAME ${_name} COMMAND ${_name})
@@ -112,10 +114,10 @@ set(parser_SRCS icaltestparser.c)
buildme(parser "${parser_SRCS}")
file(GLOB TEST_FILES ${CMAKE_SOURCE_DIR}/test-data/*.ics)
-foreach(TEST_FILE ${TEST_FILES})
- get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE)
- add_test(NAME parser-${TEST_NAME} COMMAND parser ${TEST_FILE})
- setprops(parser-${TEST_NAME})
+foreach(test_file ${TEST_FILES})
+ get_filename_component(test_name ${test_file} NAME_WE)
+ add_test(NAME parser-${test_name} COMMAND parser ${test_file})
+ setprops(parser-${test_name})
endforeach()
########### next target ###############
@@ -181,7 +183,8 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS 3.14)
set(CMAKE_COMPARE_FILES_IGNORE_EOL TRUE)
endif()
if(NOT WIN32 OR CMAKE_COMPARE_FILES_IGNORE_EOL)
- if(NOT CYGWIN AND NOT USE_32BIT_TIME_T) #ignore_eol doesn't work on Cygwin. tests for years greater than 2037 will fail
+ #ignore_eol doesn't work on Cygwin. testing years greater than 2037 will fail
+ if(NOT CYGWIN AND NOT USE_32BIT_TIME_T)
set(icalrecurtest_SRCS icalrecur_test.c)
add_executable(icalrecurtest ${icalrecurtest_SRCS})
target_link_libraries(icalrecurtest ical icalss icalvcal)