cmake version 4.1.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
The exact error I get with the simple message is this one:
CMake Error at RGFramework/CMakeLists.txt:772:
Parse error. Expected a command name, got right paren with text ")".
Interestingly both samples worked when I placed them in a simple top-level CMakeLists.txt
However, when I put them in my project; deep down some nested CMakeLists.txt and nested if()/else() branches and it fails.
I’ll try to create a very simple reproducible project and come back.
If you look at the Bracket Comment definition closely enough, you will see that it opens by #[[ and closes by ]] (optionally with same number of = signs between the brackets). So in your case, the comment was closed by the ]]) line, hence ) being reported as an error. There is no indication that #]] should close the comment.
If you want to comment out a block of code like this, use a unique number of = signs. This would have worked: