Skip to content

Commit

Permalink
style: reformat code with gersemi mode favour-expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
abdes committed Oct 21, 2024
1 parent 571ac3f commit f53e43d
Show file tree
Hide file tree
Showing 16 changed files with 230 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .gersemirc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ color: false
definitions: []
indent: 2
line_length: 130
list_expansion: favour-inlining
list_expansion: favour-expansion
quiet: false
unsafe: false
warn_about_unknown_commands: false
Expand Down
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ endforeach()
# ------------------------------------------------------------------------------

# Generate folders for IDE targets (e.g., VisualStudio solutions)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(
GLOBAL
PROPERTY
USE_FOLDERS
ON
)
set(IDE_FOLDER "${META_PROJECT_NAME}")

# Declare project
Expand All @@ -133,7 +138,9 @@ project(
VERSION ${META_VERSION}
DESCRIPTION ${META_PROJECT_DESCRIPTION}
HOMEPAGE_URL ${META_GITHUB_REPO}
LANGUAGES C CXX
LANGUAGES
C
CXX
)

# Set output directories
Expand Down Expand Up @@ -250,8 +257,14 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo"
CACHE
CMAKE_BUILD_TYPE
PROPERTY
STRINGS
"Debug"
"Release"
"MinSizeRel"
"RelWithDebInfo"
)
endif()

Expand Down
3 changes: 2 additions & 1 deletion cmake/AsapInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ if(${META_PROJECT_ID}_INSTALL)

# Install generated header files
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_ID_LOWER}
DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/include/${META_PROJECT_ID_LOWER}
DESTINATION ${ASAP_INSTALL_INCLUDE}
COMPONENT ${dev}
)
Expand Down
57 changes: 45 additions & 12 deletions cmake/AsapTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ function(_module_cmake_config_files)
${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${MODULE_TARGET_NAME}Config.cmake"
INSTALL_DESTINATION "${ASAP_INSTALL_CMAKE}/${META_MODULE_NAME}"
PATH_VARS META_MODULE_VERSION MODULE_TARGET_NAME
PATH_VARS
META_MODULE_VERSION
MODULE_TARGET_NAME
)

# generate the version file for the config file
Expand Down Expand Up @@ -115,7 +117,12 @@ macro(_add_common_compiler_options target warnings)
endmacro()

function(asap_add_library target)
set(argOption EXCEPTIONS RTTI WARNING)
set(
argOption
EXCEPTIONS
RTTI
WARNING
)
set(argSingle CONTRACTS)
set(argMulti)

Expand Down Expand Up @@ -148,18 +155,29 @@ function(asap_add_library target)
set_target_properties(
${target}
PROPERTIES
FOLDER "Libraries"
VERSION ${META_MODULE_VERSION}
SOVERSION ${META_MODULE_VERSION_MAJOR}
DEBUG_POSTFIX "d"
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN YES
FOLDER
"Libraries"
VERSION
${META_MODULE_VERSION}
SOVERSION
${META_MODULE_VERSION_MAJOR}
DEBUG_POSTFIX
"d"
CXX_VISIBILITY_PRESET
hidden
VISIBILITY_INLINES_HIDDEN
YES
)
endif()
endfunction()

function(asap_add_executable target)
set(argOption EXCEPTIONS RTTI WARNING)
set(
argOption
EXCEPTIONS
RTTI
WARNING
)
set(argSingle CONTRACTS)
set(argMulti)

Expand All @@ -179,15 +197,30 @@ function(asap_add_executable target)
asap_set_compile_definitions(${target} CONTRACTS ${x_CONTRACTS})
# Set common compiler options
asap_set_compile_options(${target} ${warning_flag})
set_target_properties(${target} PROPERTIES FOLDER "Executables")
set_target_properties(
${target}
PROPERTIES
FOLDER
"Executables"
)
endfunction()

function(asap_add_tool target)
asap_add_executable(${target} ${ARGN})
set_target_properties(${target} PROPERTIES FOLDER "Tools")
set_target_properties(
${target}
PROPERTIES
FOLDER
"Tools"
)
endfunction()

function(asap_add_tool_library target)
asap_add_library(${target} ${ARGN})
set_target_properties(${target} PROPERTIES FOLDER "Tool Libraries")
set_target_properties(
${target}
PROPERTIES
FOLDER
"Tool Libraries"
)
endfunction()
5 changes: 3 additions & 2 deletions cmake/ClangFormat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
function(asap_create_clang_format_targets)
include(common/ClangFormat)
swift_setup_clang_format(
CLANG_FORMAT_NAMES
CLANG_FORMAT_NAMES
clang-format
clang-format-19
clang-format-18
clang-format-17
clang-format-16
clang-format-15
clang-format-14
${ARGV})
${ARGV}
)
endfunction()
14 changes: 12 additions & 2 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@ if("${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang|GNU")
if("${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
# For clang we'll be using llvm-cov which expect regex as input for
# exclusions
set(STANDARD_EXCLUDES '.*/test/.*' '.*/\.cache/CPM/.*' '/usr/.*')
set(
STANDARD_EXCLUDES
'.*/test/.*'
'.*/\.cache/CPM/.*'
'/usr/.*'
)
else()
# For GNU however, we'll be using lcov which expects file patterns as
# input for excludions
set(STANDARD_EXCLUDES */test/* */.cache/CPM/* /usr/*)
set(
STANDARD_EXCLUDES
*/test/*
*/.cache/CPM/*
/usr/*
)
endif()
add_code_coverage_all_targets(EXCLUDE ${STANDARD_EXCLUDES} ${ARGV})
endfunction()
Expand Down
21 changes: 18 additions & 3 deletions cmake/CompileDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ include_guard(GLOBAL)
function(asap_set_compile_definitions target)
set(argOption "")
set(argSingle "CONTRACTS")
set(argMulti "ADD" "REMOVE")
set(
argMulti
"ADD"
"REMOVE"
)

unset(x_CONTRACTS)
unset(x_ADD)
Expand All @@ -67,9 +71,20 @@ function(asap_set_compile_definitions target)
list(APPEND all_definitions "$<$<CONFIG:Debug>:ASAP_IS_DEBUG_BUILD>")

if(MSVC)
list(APPEND all_definitions "NOMINMAX" "WIN32_LEAN_AND_MEAN=1" "_WIN32_WINNT=0x0600")
list(
APPEND
all_definitions
"NOMINMAX"
"WIN32_LEAN_AND_MEAN=1"
"_WIN32_WINNT=0x0600"
)
# Disabling warning for not using "secure-but-not-standard" STL algos
list(APPEND all_definitions "_CRT_SECURE_NO_WARNINGS" "_SCL_SECURE_NO_WARNINGS")
list(
APPEND
all_definitions
"_CRT_SECURE_NO_WARNINGS"
"_SCL_SECURE_NO_WARNINGS"
)
endif()

if(x_REMOVE)
Expand Down
8 changes: 7 additions & 1 deletion cmake/CompileOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ function(asap_set_compile_options)
set(targets ${x_UNPARSED_ARGUMENTS})

foreach(target ${targets})
target_compile_options(${target} PRIVATE /EHsc /MP /W4)
target_compile_options(
${target}
PRIVATE
/EHsc
/MP
/W4
)
if(NOT x_WARNING)
target_compile_options(${target} PRIVATE /WX)
endif()
Expand Down
5 changes: 4 additions & 1 deletion cmake/ComponentInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
# Execute cmake_install.cmake wrapper that allows to pass both DESTDIR and
# COMPONENT environment variable

execute_process(COMMAND ${CMAKE_COMMAND} -DCOMPONENT=$ENV{COMPONENT} -P cmake_install.cmake)
execute_process(
COMMAND
${CMAKE_COMMAND} -DCOMPONENT=$ENV{COMPONENT} -P cmake_install.cmake
)
35 changes: 27 additions & 8 deletions cmake/DoxGeneration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,24 @@ if(DOXYGEN_FOUND)
message(STATUS "[doxygen] Adding module doxygen target: ${MODULE_NAME}_dox")
add_custom_target(
${MODULE_NAME}_dox
COMMAND ${CMAKE_COMMAND} -E remove -f "${MODULE_NAME}_Doxyfile.out"
COMMAND ${CMAKE_COMMAND} -E copy "${MODULE_NAME}_Doxyfile" "${MODULE_NAME}_Doxyfile.out"
COMMAND ${DOXYGEN_EXECUTABLE} "${MODULE_NAME}_Doxyfile.out"
COMMAND ${CMAKE_COMMAND} -E remove -f "${MODULE_NAME}_Doxyfile.out"
COMMAND
${CMAKE_COMMAND} -E remove -f "${MODULE_NAME}_Doxyfile.out"
COMMAND
${CMAKE_COMMAND} -E copy "${MODULE_NAME}_Doxyfile" "${MODULE_NAME}_Doxyfile.out"
COMMAND
${DOXYGEN_EXECUTABLE} "${MODULE_NAME}_Doxyfile.out"
COMMAND
${CMAKE_COMMAND} -E remove -f "${MODULE_NAME}_Doxyfile.out"
WORKING_DIRECTORY "${DOXYGEN_BUILD_DIR}"
COMMENT "Generating doxygen documentation for \"${MODULE_NAME}\""
VERBATIM
)
set_target_properties(${MODULE_NAME}_dox PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(
${MODULE_NAME}_dox
PROPERTIES
EXCLUDE_FROM_ALL
TRUE
)
add_dependencies(dox ${MODULE_NAME}_dox)
endfunction()

Expand Down Expand Up @@ -132,7 +141,12 @@ if(DOXYGEN_FOUND)
add_custom_target(dox)
# We don't want it to be rebuilt everytime we build all. Need to explicitly
# request it to be built.
set_target_properties(dox PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(
dox
PROPERTIES
EXCLUDE_FROM_ALL
TRUE
)

# We'll make a special script to collect all doxygen warnings from
# submodules and print them at the end of the doxygen run. This mwill make
Expand Down Expand Up @@ -166,13 +180,18 @@ if(DOXYGEN_FOUND)
add_custom_command(
TARGET dox
POST_BUILD
COMMAND ${CMAKE_COMMAND} -P "${COLLECT_WARNINGS_SCRIPT}"
COMMAND
${CMAKE_COMMAND} -P "${COLLECT_WARNINGS_SCRIPT}"
WORKING_DIRECTORY "${DOXYGEN_BUILD_DIR}"
COMMENT "Running post-build command for dox"
)
endif()
else()
message(WARNING "`doxygen` is not available on this system! " "API documentation generation targets will not be added.")
message(
WARNING
"`doxygen` is not available on this system! "
"API documentation generation targets will not be added."
)

function(asap_with_doxygen)
endfunction()
Expand Down
6 changes: 5 additions & 1 deletion cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ find_program(SPHINX_EXECUTABLE NAMES sphinx-build DOC "Sphinx documentation gene

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE)
find_package_handle_standard_args(
Sphinx
DEFAULT_MSG
SPHINX_EXECUTABLE
)

mark_as_advanced(SPHINX_EXECUTABLE)
3 changes: 2 additions & 1 deletion cmake/GetGitRevisionDescription.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ function(git_describe _var)
endif()

execute_process(
COMMAND "${GIT_EXECUTABLE}" describe ${hash} ${ARGN}
COMMAND
"${GIT_EXECUTABLE}" describe ${hash} ${ARGN}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
Expand Down
Loading

0 comments on commit f53e43d

Please sign in to comment.