[CMake] How to locate clang-format

Michi Henning michi.henning at canonical.com
Wed Jan 1 16:27:58 EST 2014


I would like to add a target to format my code with clang-format. However, clang-format isn't installed as "clang-format" (at least not on Ubuntu). Instead, it installs itself as "clang-format-3.4", "clang-format-3.5", etc.

Is there a reasonable way to locate the binary with the largest version number >= than some minimum version? For example, I'd like to find clang-format-3.5 or later (even if the next version happens to be "clang-format-4.0"), and then create a symlink in the build tree for other scripts to use.

I looked at find_program, but it doesn't appear to deal with this.

I'd appreciate any suggestions.

Thanks,

Michi.


More information about the CMake mailing list