Skip to content

Commit

Permalink
CMake: add support for CMake files: CMakeCache.txt, CMakeLists.txt, c…
Browse files Browse the repository at this point in the history
…make
  • Loading branch information
emidoots committed May 9, 2018
1 parent 5d2fb86 commit ef91fef
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 0 deletions.
41 changes: 41 additions & 0 deletions CMake/CMake Cache.sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: CMake Cache
file_extensions:
- CMakeCache.txt
scope: source.cache.cmake
contexts:
main:
- include: comments
- include: assignation
assignation:
- match: '([a-zA-Z0-9_\-\d]+)(:)(STRING|FILE|FILEPATH|BOOL|INTERNAL|STATIC)(\=)(.*)'
scope: variable.other.cmake
captures:
1: variable.language.cache.cmake
2: keyword.other.argument-separator.cmake
3: constant.language.cache.cmake
4: keyword.operator.cmake
5: string.unquoted.cmake
comments:
- match: '(^[ \t]+)?(?=//|\#)'
captures:
1: punctuation.whitespace.comment.leading.cmake
push:
- match: (?!\G)
pop: true
- match: //
captures:
0: punctuation.definition.comment.cmake
push:
- meta_scope: comment.line.double-slash.cmake
- match: \n
pop: true
- match: '\#'
captures:
0: punctuation.definition.comment.cmake
push:
- meta_scope: comment.line.sign-line.cmake
- match: \n
pop: true
107 changes: 107 additions & 0 deletions CMake/CMake Listfile.sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: CMake Listfile
file_extensions:
- CMakeLists.txt
- cmake
scope: source.cmake
contexts:
main:
- match: (?i)^\s*(function|macro)\s*(\()
captures:
1: support.function.cmake
2: punctuation.definition.parameters.begin.command.cmake
push:
- meta_scope: meta.function-call.command.cmake
- meta_content_scope: meta.function-call.function.cmake
- match: (\))
captures:
1: punctuation.definition.parameters.end.command.cmake
pop: true
- include: argument-constants
- include: items
- match: |-
(?ix)
^\s* # Start of the line with optional preceding space
(?: # Either a control flow keyword
((?:end)?(?:(?:else)?if|while|foreach)|return|else)
| # Or a function
(s(tring|ite_name|ource_group|ubdir(s|_depends)|e(t(_(source_files_properties|t(ests_properties|arget_properties)|directory_properties|property))?|parate_arguments))|c(test_(s(tart|ubmit|leep)|co(nfigure|verage)|test|up(date|load)|empty_binary_directory|r(un_script|ead_custom_files)|memcheck|build)|on(tinue|figure_file)|reate_test_sourcelist|make_(host_system_information|policy|minimum_required))|t(arget_(sources|compile_(options|definitions|features)|include_directories|link_libraries)|ry_(compile|run))|i(n(stall(_(targets|programs|files))?|clude(_(directories|external_msproject|regular_expression))?)|f)|o(utput_required_files|ption)|define_property|u(se_mangled_mesa|nset|tility_source)|project|e(n(d(if|f(oreach|unction)|while|macro)|able_(testing|language))|lse(if)?|x(port(_library_dependencies)?|ec(ute_process|_program)))|variable_(watch|requires)|qt_wrap_(cpp|ui)|f(i(nd_(p(a(ckage|th)|rogram)|file|library)|le)|oreach|unction|ltk_wrap_ui)|w(hile|rite_file)|l(i(st|nk_(directories|libraries))|oad_c(ommand|ache))|a(dd_(subdirectory|c(ompile_options|ustom_(command|target))|test|de(pendencies|finitions)|executable|library)|ux_source_directory)|re(turn|move(_definitions)?)|get_(source_file_property|cmake_property|t(est_property|arget_property)|directory_property|property|filename_component)|m(essage|a(cro|th|ke_directory|rk_as_advanced))|b(uild_(name|command)|reak))
| # Or some function we don’t know about
(\w+)
)
\s*(\() # Finally, the opening parenthesis for the argument list
comment: |
The command list is simply generated with:
cmake --help-command-list | ruby /Library/Application\ Support/TextMate/Bundles/Objective-C.tmbundle/Support/list_to_regexp.rb | pbcopy
captures:
1: keyword.control.cmake
2: support.function.cmake
3: punctuation.definition.parameters.begin.command.cmake
push:
- meta_scope: meta.function-call.command.cmake
- match: (\))
captures:
1: punctuation.definition.parameters.end.command.cmake
pop: true
- include: argument-constants
- include: items
- include: items
argument-constants:
- match: \b(R(UN(_(RESULT_VAR|OUTPUT_VARIABLE)|TIME(_DIRECTORY)?)|E(G(ULAR_EXPRESSION|EX)|MOVE(_(RECURSE|ITEM|DUPLICATES|AT))?|S(OURCE|ULT(_VAR(IABLE)?)?)|NAME|T(RY_(COUNT|DELAY)|URN_VALUE)|PLACE|VERSE|QUIRED(_VARIABLE(1|2))?|L(EASE|ATIVE(_PATH)?)|AD(_WITH_PREFIX)?)|AN(GE|DOM(_SEED)?))|G(R(OUP_(READ|EXECUTE)|EATER)|U(ID|ARD)|E(NE(RATE|X_STRIP)|T)|LOB(_RECURSE|AL)?)|M(ODULE|D5|ESSAGE(_NEVER)?|A(COSX_BUNDLE|TCH(ES|ALL)?|IN_DEPENDENCY|KE_(C_IDENTIFIER|DIRECTORY)))|B(RIEF_DOCS|YPRODUCTS|U(NDLE|ILD(_(TESTING|INTERFACE))?)|EFORE)|S(HA(RED|1|2(24|56)|384|512)|YSTEM|C(RIPT|HEDULE_RANDOM)|T(R(GREATER|I(NGS|DE|P)|EQUAL|LESS)|OP_TIME|A(RT|TIC))|O(RT|URCE(S)?)|UBSTRING|ET)|H(INTS|EX)|N(NNN|O(_(MODULE|S(YSTEM_ENVIRONMENT_PATH|OURCE_PERMISSIONS)|CMAKE_(BUILDS_PATH|SYSTEM_PA(CKAGE_REGISTRY|TH)|PA(CKAGE_REGISTRY|TH)|ENVIRONMENT_PATH|FIND_ROOT_PATH)|DEFAULT_PATH|POLICY_SCOPE)|T(E(QUAL)?)?)|UMBER_(ERRORS|WARNINGS)|EW(_PROCESS|LINE_STYLE)?|AME(S(PACE)?|LINK_(SKIP|ONLY))?)|C(RLF|M(P(00(17|48))?|AKE_(MODULE_PATH|CURRENT_(BINARY_DIR|SOURCE_DIR)|F(IND_ROOT_PATH_BOTH|LAGS)))?|T(EST_(B(INARY_DIRECTORY|UILD_(COMMAND|TARGET))|SOURCE_DIRECTORY|PROJECT_NAME))?|O(M(M(ENT|AND(_NAME)?)|P(ILE_(RESULT_VAR|OUTPUT_VARIABLE|DEFINITIONS)|ONENT(S)?|ARE)?)|N(CAT|TENT|DITION|FIG(S|UR(E(_FILE)?|ATION(S)?))?)|DE|PY(_FILE(_ERROR)?|ONLY)?)|DASH_UPLOAD(_TYPE)?|VS|LEAR|ACHE(D_VARIABLE)?)|_(BAR|COMMAND|VERSION(_(M(INOR|AJOR)|TWEAK|PATCH))?|FOO)|T(RACK|YPE|IME(STAMP|OUT)|O(_(NATIVE_PATH|CMAKE_PATH)|UPPER|LOWER)|EST(_VARIABLE)?|ARGET(S|_(OBJECTS|FILE))?)|I(MP(ORTED(_(NO_SONAME|LOCATION(_)?)?)?|LICIT_DEPENDS)|S_(SYMLINK|NEWER_THAN|DIRECTORY|ABSOLUTE)|N(S(TALL(_INTERFACE)?|ERT)|HERITED|CLUDE(S|_(INTERNALS|DIRECTORIES|LABEL))?|_LIST|TERFACE(_)?|PUT(_FILE)?)?|TEMS|DE)|O(R|BJECT|N(LY(_CMAKE_FIND_ROOT_PATH)?)?|UTPUT(_(STRIP_TRAILING_WHITESPACE|DIRECTORY|VARIABLE|QUIET|FILE))?|PTION(S|AL(_COMPONENTS)?)|FF(SET)?|WNER_(READ|EXECUTE|WRITE)|LD)|D(BAR|IRECTORY(_PERMISSIONS)?|O(S|WNLOAD)|E(STINATION|PENDS|FIN(ITION|ED))|VAR|FOO)|U(SE(S_TERMINAL|_SOURCE_PERMISSIONS)|N(IX|KNOWN)|TC|UID|P(PER|LOAD))|P(R(IVATE(_HEADER)?|O(GRAM(S|_ARGS)?|CESS|JECT(_(NAME|VERSION(_(M(INOR|AJOR)|TWEAK|PATCH))?))?|PERT(Y|IES))|E(_(BUILD|INSTALL_SCRIPT|LINK)|ORDER))|O(ST_(BUILD|INSTALL_SCRIPT)|P|LICY)|U(BLIC(_HEADER)?|SH)|ERMISSIONS|LATFORM|A(R(TS|ENT_SCOPE|ALLEL_LEVEL)|CKAGE|T(H(S|_(SUFFIXES|TO_MESA))|TERN)))|E(RROR_(STRIP_TRAILING_WHITESPACE|VARIABLE|QUIET|FILE)|X(CLUDE(_(FROM_ALL|LABEL))?|TRA_INCLUDE|ISTS|P(R|ORT(_LINK_INTERFACE_LIBRARIES)?)|ACT)|SCAPE_QUOTES|N(D|V)|QUAL)|V(S|ER(BATIM|SION(_(GREATER|EQUAL|LESS))?)|A(R(2|IABLE)?|LUE))|QU(IET|ERY)|F(RAMEWORK|I(ND|LE(S(_MATCHING)?|_PERMISSIONS)?)|O(RCE|O_(STRING|ENABLE)|LLOW_SYMLINKS)|U(NCTION|LL_DOCS)|LAGS|ATAL_ERROR)|01|W(RITE|IN(32|DOWS)|ORKING_DIRECTORY)|L(I(MIT|BRARY|ST(S|_DIRECTORIES)|NK_(INTERFACE_LIBRARIES|DIRECTORIES|P(RIVATE|UBLIC)|LIBRARIES))|OCK|D_LIBRARY_PATH|E(SS|NGTH)|F|A(BELS|NGUAGES))|A(R(G(S|N|C|_VAR|V(1|2))|CHIVE)|SCII|ND|PPEND(_STRING)?|FTER|L(IAS|PHABET|L(_BUILD)?)))\b
comment: |
There is a script in bundle support for generating this list:
ruby arg_separators.rb | /Library/Application\ Support/TextMate/Bundles/Objective-C.tmbundle/Support/list_to_regexp.rb | pbcopy
scope: keyword.other.argument-separator.cmake
comments:
- match: '(^[ \t]+)?(?=#)'
captures:
1: punctuation.whitespace.comment.leading.cmake
push:
- match: (?!\G)
pop: true
- match: "#"
captures:
0: punctuation.definition.comment.cmake
push:
- meta_scope: comment.line.number-sign.cmake
- match: \n
pop: true
constants:
- match: (?i)\b(FALSE|OFF|NO|(\w+-)?NOTFOUND)\b
scope: constant.language.boolean.cmake
escapes:
- match: '\\["()#$^ \\]'
scope: constant.character.escape.cmake
items:
- include: comments
- include: constants
- include: strings
- include: variables
- include: escapes
strings:
- match: (?i)"(FALSE|OFF|NO|(.+-)?NOTFOUND)"
scope: string.quoted.double.cmake
captures:
1: constant.language.boolean.cmake
- match: '"'
push:
- meta_scope: string.quoted.double.cmake
- match: '"'
pop: true
- match: \\.
scope: constant.character.escape.cmake
- include: variables
variables:
- match: '\$(ENV)?\{'
captures:
0: punctuation.definition.variable.begin.cmake
push:
- meta_scope: variable.other.cmake
- match: '\}'
captures:
0: punctuation.definition.variable.end.cmake
pop: true
- include: variables
- match: \w+
1 change: 1 addition & 0 deletions CMake/SOURCE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/textmate/cmake.tmbundle
1 change: 1 addition & 0 deletions CMake/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1421c6ba47ba697742d615e92852cfe106e0879e

0 comments on commit ef91fef

Please sign in to comment.