CMake Multiple line comments - Block Comment

Cmake

Cmake Problem Overview


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,

Cmake Solutions


Solution 1 - Cmake

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. Some editors and IDEs do not support it yet.

Solution 2 - Cmake

if(FALSE) # fake a block comment

endif()

Solution 3 - Cmake

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")

Solution 4 - Cmake

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionthestarView Question on Stackoverflow
Solution 1 - CmakeAmaniView Answer on Stackoverflow
Solution 2 - CmakeUrkleView Answer on Stackoverflow
Solution 3 - CmakeMineLPPhynixView Answer on Stackoverflow
Solution 4 - CmakeFraserView Answer on Stackoverflow