1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
# The line is too long and exceeds the default 80 character column limit enforced cmake-lint
# This line has trailing whitespace
# This line has the wrong line endings
function(BAD_FUNCTION_NAME badArgName good_arg_name)
# Function names should be lower case
endfunction()
#
macro(bad_macro_name badArgName good_arg_name)
# Macro names should be upper case
endmacro()
if(FOOBAR)
foreach(loopvar a b c d)
# cmake-lint: disable=C0103
foreach(LOOPVAR2 a b c d)
# pass
endforeach()
endforeach()
foreach(LOOPVAR3 a b c d)
# pass
endforeach()
endif()
if(TRUE)
message("Hello world")
endif()
if(TRUE)
message("Hello world")
endif()
if(TRUE)
message("Hello world")
endif()
# expect:
set(gtest_force_shared_crt ON # cmake-lint: disable=C0103
CACHE BOOL "See googletest/googletest/CMakeLists.txt")
set(VARNAME varvalue CACHE STRING)
cmake_minimum_required_version(VERSION 2.8.11 VERSION 3.16)
# expect:
install(
DIRECTORY foo bar/
DESTINATION some/path
PATTERN "CVS" EXCLUDE
PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ)
add_custom_command()
set(_form TARGET PRE_BUILD)
add_custom_command(
${form}
COMMAND echo "hello"
COMMENT "echo hello")
add_custom_command(
TARGRET PRE_BUILD
COMMAND echo "hello"
COMMENT "echo hello")
add_custom_command(OUTPUT foo)
file()
set(_form TOUCH)
file(${form} foo.py)
file(TOUCHE foo.py)
break()
continue()
# foo: docstring
function(foo)
foreach(arg ${ARGN})
if(arg STREQUAL "FOO")
# parse FOO
elseif(arg STREQUAL "BAR")
# parse BAR
elseif(arg MATCHES "BAZ.*")
# parse BAZ
endif()
endforeach()
endfunction()
set(_foo "hello") set(_bar "goodbye")
set(_foo "hello")
set(_bar "goodbye")
# foo: docstring
function(foo "arg-name")
# pass
endfunction()
# foo: docstring
function(foo arg arg)
# pass
endfunction()
# foo: docstring
function(foo arg ARG)
# pass
endfunction()
return()
message("This code is unreachable")
# cmake-lint: disable=E0109,C0321
# foo:docstring, too many arguments
function(foo a0 a1 a2 a3 a4 a5)
# Too many branches, too many returns
if(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
elseif(blah) return()
else() return()
endif()
# too many statements
message(foo) message(foo) message(foo) message(foo) message(foo) message(foo)
message(foo) message(foo) message(foo) message(foo) message(foo) message(foo)
message(foo) message(foo) message(foo) message(foo) message(foo) message(foo)
message(foo) message(foo) message(foo) message(foo) message(foo) message(foo)
message(foo) message(foo) message(foo) message(foo) message(foo) message(foo)
endfunction()
# cmake-lint: disable=C0111
# cache (global) variables should be upper snake
set(MyGlobalVar CACHE STRING "my var")
# internal variables are treated as private and should be upper snake with an
# underscore prefix
set(MY_INTERNAL_VAR CACHE INTERNAL "my var")
# directory-scope variables should be upper-snake (public) or lower-snake with
# underscore prefix
set(_INVALID_PRIVATE_NAME "foo")
set(invalid_public_name "foo")
function(foo)
set(INVALID_LOCAL_NAME "foo")
endfunction()
set(CMAKE_Cxx_STANDARD "11")
list(APPEND CMAKE_Cxx_STANDARD "11")
message("Using C++ standard ${CMAKE_Cxx_STANDARD}")
message("$CMAKE_INSTALL_PREFIX}")
message("{CMAKE_INSTALL_PREFIX}")
message("${CMAKE_INSTALL_PREFIX")
# This file is missing a final newline
|