Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent clang-format to modify the CMake substitution strings?

Let be the file Version.h.in that we will "configure" in CMake :

configure_file("Version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/Version.h" @ONLY)

In this file I have CMake variables such as :

#define HELLO_VERSION_MAJOR @VERSION_MAJOR@

And clang-format puts a space before the last '@' :

#define HELLO_VERSION_MAJOR @VERSION_MAJOR @

What rule should I modify to prevent this ?

like image 915
Barth Avatar asked Oct 17 '25 10:10

Barth


1 Answers

clang-format can be told to skip code like this:

int formatted_code;
// clang-format off
    void    unformatted_code  ;
// clang-format on
void formatted_code_again;

This was added atleast 6 months ago. multi-line comments can be used too (and that way only a part of a line can be skipped)

int /* clang-format off */ a    /* clang-format on */ = 5;

see this for more options.

like image 176
onqtam Avatar answered Oct 22 '25 08:10

onqtam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!