98

Is there any way to comment a block in CMake in notepad++ editor?

I have tried searching on Google, but couldn't find much.

Help is needed! Thanks,

thestar
  • 4,959
  • 2
  • 28
  • 22

4 Answers4

178

As of CMake 3.0 there is a special syntax for block comments which start with #[[ and ends with ]] at the end of block comment. See CMake documentation for further explanation.

You can also put a number of equal signs between the brackets as long as the number between the opening [[ and closing ]] are both the same. Ex.

#[===[
hello
]] <- this is not the closing
]===]
# ^ this is the closing

Some editors and IDEs do not support it yet.

starball
  • 20,030
  • 7
  • 43
  • 238
Amani
  • 16,245
  • 29
  • 103
  • 153
29
if(FALSE) # fake a block comment

endif()
Urkle
  • 1,520
  • 13
  • 12
  • 9
    While this works well for *commenting out* a block of valid CMake code, it doesn't allow you write plain text within the `if` block. – Fraser Oct 21 '14 at 20:20
  • 1
    No, it does not unfortunately.. The new cmake 3 syntax looks quite nice though. I really need to finish updating all my systems and build boxes to cmake 3+ – Urkle Jan 19 '15 at 14:46
11

Since CMake version 3.0 there are block comments.

Example from the CMake manual:

#[[This is a bracket comment.
It runs until the close bracket.]]
message("First Argument\n" #[[Bracket Comment]] "Second Argument")
MineLPPhynix
  • 121
  • 2
  • 5
5

There is no notion of a block comment in CMake syntax. However, to comment several lines at once, select the required lines and hit CTRL+Q.

If the file is a .txt file (e.g. CMakeLists.txt), you can either set Notepad++ to always treat .txt files as CMake files (in Settings -> Style configurator select CMakeFile and add " txt" to "User ext.") or for just that file you can set the Language to CMake.

Fraser
  • 74,704
  • 20
  • 238
  • 215