Warning, /frameworks/syntax-highlighting/autotests/folding/highlight.cmake.fold is written in an unsupported language. File is not indexed.
0001 # This CMakeLists.txt doesn't do anything useful, 0002 # but it shoudl demonstrate the cmake syntax highlighting 0003 # 0004 # Alex Turbov <i.zaufi@gmail.com> 0005 # 0006 0007 <beginfold id='1'>#[[.rst:</beginfold id='1'> 0008 Demo 0009 ---- 0010 0011 This is an **RST** documentation. 0012 0013 <indentfold>:: 0014 0015 # Sample code block 0016 blah-blah 0017 0018 </indentfold>But we are about to test CMake here ;-) 0019 0020 <endfold id='1'>#]]</endfold id='1'> 0021 0022 cmake_policy(VERSION 3.11) 0023 0024 project( 0025 Demo VERSION 1.0 0026 DESCRIPTION "For unit testing purposes" 0027 # NOTE that particular languages is a separate style 0028 # to highlight "special" (well known values) 0029 LANGUAGES C CXX 0030 ) 0031 0032 set(SOME_TRUE_OPTION TRUE) # `true` value 0033 # `false` value and "internal" variable 0034 set(_ANOTHER_FALSE_OPTION OFF CACHE INTERNAL "Internal option") 0035 0036 #BEGIN Message block 0037 message(FATAL_ERROR "Ordinal message do ${VARIABLE_EXPANSION}") 0038 message(AUTHOR_WARNING "... standard variables have a dedicated style") 0039 message(SEND_ERROR "e.g. ${PROJECT_DESCRIPTION} or ${CMAKE_COMMAND}") 0040 message( 0041 STATUS <beginfold id='2'>[=[</beginfold id='2'> 0042 Raw messages do not do ${VARIABLES_EXPANSION} or \n 0043 escape symbols highlighting... 0044 <endfold id='2'>]=]</endfold id='2'> 0045 ) 0046 #END Message block 0047 0048 # ATTENTION Every command highlight only its own named keywords... 0049 # Also, note aliased (most of the time imported) targets higlighted as well 0050 add_library(Foo::foo IMPORTED GLOBAL) 0051 set(KW_HL IMPORTED GLOBAL) # `IMPORTED` and `GLOBAL` are not highlighted here! 0052 0053 # Properties are separate ("special value") style 0054 set_target_properties(Foo::foo PROPERTIES LOCATION "${FOO_LIBRARY}") 0055 0056 # Generator expressions 0057 target_compile_definitions( 0058 # NOTE Ok w/ CMake >= 3.11 0059 Foo::foo 0060 $<$<PLATFORM_ID:Windows>:WINDOWS_FOO> 0061 $<$<PLATFORM_ID:Linux>: 0062 LINUX_FOO 0063 $<$<BOOL:${_has_foo}>:SOME_FOO_PATH=${PROJECT_BINARY_DIR}/foo> 0064 > 0065 ) 0066 0067 <beginfold id='1'>#[=======================================================================[.rst:</beginfold id='1'> 0068 .. cmake:command:: my_fun 0069 0070 *RST* documentation ``can`` refer to :cmake:command:`any_commands` or 0071 :cmake:variable:`variables`... 0072 0073 <indentfold>.. code-block:: cmake 0074 :caption: **Synopsys** 0075 0076 my_fun([ANYTHING...]) 0077 0078 </indentfold><endfold id='1'>#]=======================================================================]</endfold id='1'> 0079 <beginfold id='3'>function</beginfold id='3'>(my_fun) 0080 # TODO Add implementation 0081 <endfold id='3'>endfunction</endfold id='3'>() 0082 0083 my_fun( 0084 # Custom functions do not highlight "standard" named args ... 0085 PUBLIC LOCATION PARENT_SCOPE 0086 # only some well-known values ... 0087 smth-NOTFOUND ON 0088 # and standard variables 0089 PROJECT_VERSION 0090 # or substitutions 0091 $ENV{HOME} OR ${_internal_var_is_grey} 0092 ) 0093 0094 # I dont'recall exactly, but there was some bug with `if`... 0095 <beginfold id='4'>if</beginfold id='4'>((A AND "${B}") OR C OR (var MATCHES "regex")) 0096 # Anyway... it is Ok nowadays ;-) 0097 0098 elseif(POLICY CMP066) 0099 add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cc) 0100 target_link_libraries( 0101 ${PROJECT_NAME} 0102 PRIVATE 0103 Qt5::Core 0104 $<$<BOOL:${HAS_FOO}>:Foo::foo> 0105 ) 0106 0107 <endfold id='4'>endif</endfold id='4'>() 0108 0109 # In each function call below, all 3 named parameter lines should apply the same highlighting. 0110 add_custom_command( 0111 COMMAND true 0112 COMMAND (true) 0113 COMMAND true 0114 ) 0115 add_custom_target(TargetName 0116 WORKING_DIRECTORY somedir 0117 COMMAND (true) 0118 BYPRODUCTS somefile 0119 ) 0120 execute_process( 0121 COMMAND true 0122 COMMAND (true) 0123 COMMAND true 0124 ) 0125 add_test( 0126 NAME sometest 0127 COMMAND (true) 0128 WORKING_DIRECTORY somedir 0129 ) 0130 0131 # nested parentheses 0132 <beginfold id='4'>if</beginfold id='4'>( true AND ( false OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") ) ) 0133 <endfold id='4'>endif</endfold id='4'>()