Files
RedBear-OS/local/recipes/kde/kf6-syntaxhighlighting/source/autotests/folding/highlight.cmake.fold
T

134 lines
3.7 KiB
Plaintext

# This CMakeLists.txt doesn't do anything useful,
# but it shoudl demonstrate the cmake syntax highlighting
#
# Alex Turbov <i.zaufi@gmail.com>
#
<beginfold id='1'>#[[.rst:</beginfold id='1'>
Demo
----
This is an **RST** documentation.
<indentfold>::
# Sample code block
blah-blah
</indentfold>But we are about to test CMake here ;-)
<endfold id='1'>#]]</endfold id='1'>
cmake_policy(VERSION 3.11)
project(
Demo VERSION 1.0
DESCRIPTION "For unit testing purposes"
# NOTE that particular languages is a separate style
# to highlight "special" (well known values)
LANGUAGES C CXX
)
set(SOME_TRUE_OPTION TRUE) # `true` value
# `false` value and "internal" variable
set(_ANOTHER_FALSE_OPTION OFF CACHE INTERNAL "Internal option")
#BEGIN Message block
message(FATAL_ERROR "Ordinal message do ${VARIABLE_EXPANSION}")
message(AUTHOR_WARNING "... standard variables have a dedicated style")
message(SEND_ERROR "e.g. ${PROJECT_DESCRIPTION} or ${CMAKE_COMMAND}")
message(
STATUS <beginfold id='2'>[=[</beginfold id='2'>
Raw messages do not do ${VARIABLES_EXPANSION} or \n
escape symbols highlighting...
<endfold id='2'>]=]</endfold id='2'>
)
#END Message block
# ATTENTION Every command highlight only its own named keywords...
# Also, note aliased (most of the time imported) targets higlighted as well
add_library(Foo::foo IMPORTED GLOBAL)
set(KW_HL IMPORTED GLOBAL) # `IMPORTED` and `GLOBAL` are not highlighted here!
# Properties are separate ("special value") style
set_target_properties(Foo::foo PROPERTIES LOCATION "${FOO_LIBRARY}")
# Generator expressions
target_compile_definitions(
# NOTE Ok w/ CMake >= 3.11
Foo::foo
$<$<PLATFORM_ID:Windows>:WINDOWS_FOO>
$<$<PLATFORM_ID:Linux>:
LINUX_FOO
$<$<BOOL:${_has_foo}>:SOME_FOO_PATH=${PROJECT_BINARY_DIR}/foo>
>
)
<beginfold id='1'>#[=======================================================================[.rst:</beginfold id='1'>
.. cmake:command:: my_fun
*RST* documentation ``can`` refer to :cmake:command:`any_commands` or
:cmake:variable:`variables`...
<indentfold>.. code-block:: cmake
:caption: **Synopsys**
my_fun([ANYTHING...])
</indentfold><endfold id='1'>#]=======================================================================]</endfold id='1'>
<beginfold id='3'>function</beginfold id='3'>(my_fun)
# TODO Add implementation
<endfold id='3'>endfunction</endfold id='3'>()
my_fun(
# Custom functions do not highlight "standard" named args ...
PUBLIC LOCATION PARENT_SCOPE
# only some well-known values ...
smth-NOTFOUND ON
# and standard variables
PROJECT_VERSION
# or substitutions
$ENV{HOME} OR ${_internal_var_is_grey}
)
# I dont'recall exactly, but there was some bug with `if`...
<beginfold id='4'>if</beginfold id='4'>((A AND "${B}") OR C OR (var MATCHES "regex"))
# Anyway... it is Ok nowadays ;-)
elseif(POLICY CMP066)
add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cc)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
Qt5::Core
$<$<BOOL:${HAS_FOO}>:Foo::foo>
)
<endfold id='4'>endif</endfold id='4'>()
# In each function call below, all 3 named parameter lines should apply the same highlighting.
add_custom_command(
COMMAND true
COMMAND (true)
COMMAND true
)
add_custom_target(TargetName
WORKING_DIRECTORY somedir
COMMAND (true)
BYPRODUCTS somefile
)
execute_process(
COMMAND true
COMMAND (true)
COMMAND true
)
add_test(
NAME sometest
COMMAND (true)
WORKING_DIRECTORY somedir
)
# nested parentheses
<beginfold id='4'>if</beginfold id='4'>( true AND ( false OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") ) )
<endfold id='4'>endif</endfold id='4'>()