diff --git a/CCache.cmake b/CCache.cmake new file mode 100644 index 0000000..b65bf62 --- /dev/null +++ b/CCache.cmake @@ -0,0 +1,12 @@ +option(SWIFT_ENABLE_CCACHE "Use ccache to speed up compilation process" OFF) + +if(SWIFT_ENABLE_CCACHE) + find_program(CCACHE_PATH ccache) + if(CCACHE_PATH) + message(STATUS "Using ccache at ${CCACHE_PATH}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PATH}) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PATH}) + else() + message(STATUS "Could not find ccache") + endif() +endif() diff --git a/ClangFormat.cmake b/ClangFormat.cmake new file mode 100644 index 0000000..54b0ec2 --- /dev/null +++ b/ClangFormat.cmake @@ -0,0 +1,208 @@ +# +# A module to create custom targets to format source and header files in a git repo +# +# The function swift_setup_clang_format will create several targets which will +# use clang-format to format source code according to a configuration file. 2 types +# of targets will be created, one for formatting all files in the repository and the +# other for formatting only the files which differ from master. The list of files to +# format is generated by git itself. +# +# The created targets have the names +# +# - clang-format-all-${PROJECT_NAME} - formats all files in the repo +# - clang-format-diff-${PROJECT_NAME} - formats only changed files +# +# In addition if the current project is at the top level of the working tree 2 more +# targets will be created +# +# - clang-format-all +# - clang-format-diff +# +# which are aliases for the namespaced targets. If every project in a working +# directory uses this module to create auto-formatting targets there will never be +# a name clash +# +# The parameter SCRIPT can be used to specify a custom formatting command instead +# of calling clang-format directly. This should be executable and will be called +# with a single argument of either 'all' or 'diff' according to the target +# +# clang-format-all-${PROJECT_NAME} will run `