check: run pre-commit on all files

This commit is contained in:
Markus Hofbauer
2022-04-02 18:58:23 +02:00
parent 4c9ada5f93
commit cf7a7ed17a
26 changed files with 652 additions and 685 deletions

View File

@ -1,11 +1,7 @@
# Look for an executable called sphinx-build
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
DOC "Path to sphinx-build executable")
find_program(SPHINX_EXECUTABLE NAMES sphinx-build DOC "Path to sphinx-build executable")
include(FindPackageHandleStandardArgs)
# Handle standard arguments to find_package like REQUIRED and QUIET
find_package_handle_standard_args(Sphinx
"Failed to find sphinx-build executable"
SPHINX_EXECUTABLE)
find_package_handle_standard_args(Sphinx "Failed to find sphinx-build executable" SPHINX_EXECUTABLE)

View File

@ -134,7 +134,7 @@ function(enable_ccache)
endif()
if("${_ccache_version}" VERSION_LESS 3.3.0)
list(APPEND _ccacheEnv CCACHE_CPP2=1) # avoids spurious warnings with some compilers for ccache older than 3.3
list(APPEND _ccacheEnv CCACHE_CPP2=1) # avoids spurious warnings with some compilers for ccache older than 3.3
endif()
if(_enable_ccache_MODE STREQUAL DIRECT_DEPEND)
@ -188,25 +188,18 @@ function(enable_ccache)
if(CMAKE_GENERATOR MATCHES "Ninja|Makefiles")
foreach(_lang IN ITEMS C CXX OBJC OBJCXX CUDA)
set(CMAKE_${_lang}_COMPILER_LAUNCHER
${CMAKE_COMMAND} -E env
${_ccacheEnv} ${CCACHE_PATH}
PARENT_SCOPE
)
set(CMAKE_${_lang}_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env ${_ccacheEnv} ${CCACHE_PATH} PARENT_SCOPE)
endforeach()
elseif(CMAKE_GENERATOR STREQUAL Xcode)
# Each of the Xcode project variables allow specifying only a single value, but the ccache command line needs to have multiple options.
# A separate launch script needs to be written out and the project variables pointed at them.
foreach(_lang IN ITEMS C CXX)
set(launch${_lang} ${CMAKE_BINARY_DIR}/launch-${_lang})
file(WRITE ${launch${_lang}} "#!/bin/bash\n\n")
foreach(keyVal IN LISTS _ccacheEnv)
file(APPEND ${launch${_lang}} "export ${keyVal}\n")
endforeach()
file(APPEND ${launch${_lang}}
"exec \"${CCACHE_PROGRAM}\" "
"\"${CMAKE_${_lang}_COMPILER}\" \"$@\"\n"
)
set(launch${_lang} ${CMAKE_BINARY_DIR}/launch-${_lang})
file(WRITE ${launch${_lang}} "#!/bin/bash\n\n")
foreach(keyVal IN LISTS _ccacheEnv)
file(APPEND ${launch${_lang}} "export ${keyVal}\n")
endforeach()
file(APPEND ${launch${_lang}} "exec \"${CCACHE_PROGRAM}\" " "\"${CMAKE_${_lang}_COMPILER}\" \"$@\"\n")
execute_process(COMMAND chmod a+rx ${launch${_lang}})
endforeach()
set(CMAKE_XCODE_ATTRIBUTE_CC ${launchC} PARENT_SCOPE)

View File

@ -22,7 +22,8 @@
cmake_minimum_required(VERSION 3.5)
find_package(Doxygen MODULE REQUIRED) # TODO Switch to CONFIG when Conan will start supporting imported executables in CMakeDeps
find_package(Doxygen MODULE REQUIRED
)# TODO Switch to CONFIG when Conan will start supporting imported executables in CMakeDeps
find_package(Sphinx REQUIRED)
#
@ -80,16 +81,14 @@ function(add_documentation targetName)
set(_doxygenIndexFile "${DOXYGEN_OUTPUT_DIR}/xml/index.xml")
# Only regenerate Doxygen when the Doxyfile or given dependencies change
add_custom_command(OUTPUT "${_doxygenIndexFile}"
add_custom_command(
OUTPUT "${_doxygenIndexFile}"
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOXYGEN_OUTPUT_DIR}
COMMAND Doxygen::doxygen ARGS "${_doxyfile}"
MAIN_DEPENDENCY "${_doxyfileIn}"
DEPENDS
"${_doxyfile}"
"${_args_CODE_DEPENDS}"
DEPENDS "${_doxyfile}" "${_args_CODE_DEPENDS}"
COMMENT "Generating doxygen XML metadata"
USES_TERMINAL
VERBATIM
USES_TERMINAL VERBATIM
)
set(_sphinx_docs_dir "${CMAKE_CURRENT_BINARY_DIR}/sphinx")
@ -99,16 +98,16 @@ function(add_documentation targetName)
# - Doxygen has rerun
# - Our doc files have been updated
# - The Sphinx config has been updated
add_custom_command(OUTPUT "${_sphinx_index_file}"
COMMAND "${SPHINX_EXECUTABLE}" ARGS -b html -j auto "-Dbreathe_projects.${_args_BREATHE_PROJECT}=${DOXYGEN_OUTPUT_DIR}/xml" "${_args_DOCS_SOURCE_DIR}" "${_sphinx_docs_dir}"
add_custom_command(
OUTPUT "${_sphinx_index_file}"
COMMAND "${SPHINX_EXECUTABLE}" ARGS -b html -j auto
"-Dbreathe_projects.${_args_BREATHE_PROJECT}=${DOXYGEN_OUTPUT_DIR}/xml" "${_args_DOCS_SOURCE_DIR}"
"${_sphinx_docs_dir}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
MAIN_DEPENDENCY "${_args_DOCS_SOURCE_DIR}/conf.py"
DEPENDS
"${_doxygenIndexFile}"
"${_args_DOCS_DEPENDS}"
DEPENDS "${_doxygenIndexFile}" "${_args_DOCS_DEPENDS}"
COMMENT "Generating documentation with Sphinx"
USES_TERMINAL
VERBATIM
USES_TERMINAL VERBATIM
)
# Custom target
@ -118,7 +117,7 @@ function(add_documentation targetName)
add_custom_target(${targetName} ${_all} DEPENDS "${_sphinx_index_file}")
if(_args_INSTALL_DIR)
# Add an install step to install the docs
install(DIRECTORY ${_sphinx_docs_dir} TYPE DOC)
# Add an install step to install the docs
install(DIRECTORY ${_sphinx_docs_dir} TYPE DOC)
endif()
endfunction()

View File

@ -48,7 +48,17 @@ macro(_enable_iwyu_failed log_postfix)
endmacro()
macro(_process_iwyu_arguments offset log_postfix)
set(_options QUIET REQUIRED NO_DEFAULT_MAPPINGS PCH_IN_CODE TRANSITIVE_INCLUDES_ONLY NO_COMMENTS NO_FORWARD_DECLARATIONS CXX17_NAMESPACES QUOTED_INCLUDES_FIRST)
set(_options
QUIET
REQUIRED
NO_DEFAULT_MAPPINGS
PCH_IN_CODE
TRANSITIVE_INCLUDES_ONLY
NO_COMMENTS
NO_FORWARD_DECLARATIONS
CXX17_NAMESPACES
QUOTED_INCLUDES_FIRST
)
set(_one_value_args PROGRAM MAPPING_FILE MAX_LINE_LENGTH)
set(_multi_value_args KEEP)
cmake_parse_arguments(PARSE_ARGV ${offset} _enable_iwyu "${_options}" "${_one_value_args}" "${_multi_value_args}")
@ -160,7 +170,5 @@ endfunction()
#
function(enable_target_iwyu target)
_process_iwyu_arguments(1 " for '${target}'")
set_target_properties(${target} PROPERTIES
CXX_INCLUDE_WHAT_YOU_USE "${_iwyu_path};${_iwyu_args}"
)
set_target_properties(${target} PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "${_iwyu_path};${_iwyu_args}")
endfunction()

File diff suppressed because it is too large Load Diff

View File

@ -23,9 +23,11 @@
cmake_minimum_required(VERSION 3.4)
function(ensure_entry_point)
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "'${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt' is meant to be used only "
"as a CMake entry point and should not be included from other CMake files. "
"Include '${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt' directly instead.")
endif()
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR
"'${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt' is meant to be used only "
"as a CMake entry point and should not be included from other CMake files. "
"Include '${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt' directly instead."
)
endif()
endfunction()

View File

@ -70,9 +70,7 @@ macro(_set_flags)
-Wformat=2 # warn on security issues around functions that format output (ie printf)
)
set(CLANG_WARNINGS
${GCC_COMMON_WARNINGS}
)
set(CLANG_WARNINGS ${GCC_COMMON_WARNINGS})
set(GCC_WARNINGS
${GCC_COMMON_WARNINGS}