Skip to content

Commit

Permalink
CPM linting changes and stub for CPM
Browse files Browse the repository at this point in the history
  • Loading branch information
vtangTT committed Oct 29, 2024
1 parent bfc1a3d commit 947db62
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gersemirc
Original file line number Diff line number Diff line change
@@ -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
23 changes: 10 additions & 13 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -106,11 +107,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)
Expand Down
2 changes: 2 additions & 0 deletions cmake/stubs/README.md
Original file line number Diff line number Diff line change
@@ -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.
44 changes: 44 additions & 0 deletions cmake/stubs/cpm-stubs.cmake
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 947db62

Please sign in to comment.