diff --git a/.gersemirc b/.gersemirc index 145d24c0..4d6ee9e8 100644 --- a/.gersemirc +++ b/.gersemirc @@ -1,6 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json -definitions: [cmake] +definitions: [cmake, cmake/stubs] indent: 4 line_length: 80 list_expansion: favour-expansion diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 1c381dc7..c1729e27 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -10,20 +10,21 @@ CPMAddPackage( GITHUB_REPOSITORY google/googletest GIT_TAG v1.13.0 VERSION 1.13.0 - OPTIONS "INSTALL_GTEST OFF" + OPTIONS + "INSTALL_GTEST OFF" ) ############################################################################################################################ # yaml-cpp ############################################################################################################################ CPMAddPackage( - NAME yaml-cpp - GITHUB_REPOSITORY jbeder/yaml-cpp - GIT_TAG 0.8.0 - OPTIONS - "YAML_CPP_BUILD_TESTS OFF" - "YAML_CPP_BUILD_TOOLS OFF" - "YAML_BUILD_SHARED_LIBS OFF" + NAME yaml-cpp + GITHUB_REPOSITORY jbeder/yaml-cpp + GIT_TAG 0.8.0 + OPTIONS + "YAML_CPP_BUILD_TESTS OFF" + "YAML_CPP_BUILD_TOOLS OFF" + "YAML_BUILD_SHARED_LIBS OFF" ) if(yaml-cpp_ADDED) @@ -102,11 +103,7 @@ CPMAddPackage( # fmt : https://github.com/fmtlib/fmt ############################################################################################################################ -CPMAddPackage( - NAME fmt - GITHUB_REPOSITORY fmtlib/fmt - GIT_TAG 11.0.1 -) +CPMAddPackage(NAME fmt GITHUB_REPOSITORY fmtlib/fmt GIT_TAG 11.0.1) ############################################################################################################################ # nanobench (for uBenchmarking) diff --git a/cmake/stubs/README.md b/cmake/stubs/README.md new file mode 100644 index 00000000..decb17fa --- /dev/null +++ b/cmake/stubs/README.md @@ -0,0 +1,2 @@ +This directory contains stubs of functions that we call directly, but whose definition we cannot easily +point the formatter (Gersemi) to. See https://github.com/BlankSpruce/gersemi?tab=readme-ov-file#lets-make-a-deal for more details. diff --git a/cmake/stubs/cpm-stubs.cmake b/cmake/stubs/cpm-stubs.cmake new file mode 100644 index 00000000..52e62b6c --- /dev/null +++ b/cmake/stubs/cpm-stubs.cmake @@ -0,0 +1,44 @@ +function(CPMAddPackage) + list(LENGTH ARGN argnLength) + if(argnLength EQUAL 1) + cpm_parse_add_package_single_arg("${ARGN}" ARGN) + + # The shorthand syntax implies EXCLUDE_FROM_ALL and SYSTEM + set(ARGN "${ARGN};EXCLUDE_FROM_ALL;YES;SYSTEM;YES;") + endif() + + set(oneValueArgs + NAME + FORCE + VERSION + GIT_TAG + DOWNLOAD_ONLY + GITHUB_REPOSITORY + GITLAB_REPOSITORY + BITBUCKET_REPOSITORY + GIT_REPOSITORY + SOURCE_DIR + FIND_PACKAGE_ARGUMENTS + NO_CACHE + SYSTEM + GIT_SHALLOW + EXCLUDE_FROM_ALL + SOURCE_SUBDIR + CUSTOM_CACHE_KEY + ) + + set(multiValueArgs + URL + OPTIONS + DOWNLOAD_COMMAND + PATCHES + ) + + cmake_parse_arguments( + CPM_ARGS + "" + "${oneValueArgs}" + "${multiValueArgs}" + "${ARGN}" + ) +endfunction()