Created
June 5, 2019 16:58
-
-
Save paddy74/169df63af5c66c505d684b1fe5d08474 to your computer and use it in GitHub Desktop.
Runs clang-format on all files in src/ and include/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ------------------------------------------------------------------------------ | |
| # Clang Format | |
| # ------------------------------------------------------------------------------ | |
| OPTION(ENABLE_FORMAT "Run clang-format on all files in src/ and include/" OFF) | |
| if(ENABLE_FORMAT) | |
| # Get all project files | |
| file(GLOB_RECURSE ALL_CXX_SOURCE_FILES | |
| ${PROJECT_SOURCE_DIR}/src/*.[chi]pp | |
| ${PROJECT_SOURCE_DIR}/src/*.[chi]xx | |
| ${PROJECT_SOURCE_DIR}/src/*.[chi]cc | |
| ${PROJECT_SOURCE_DIR}/src/*.[chi]hh | |
| ${PROJECT_SOURCE_DIR}/src/*.[chi]ii | |
| ${PROJECT_SOURCE_DIR}/src/*.[CHI] | |
| ${PROJECT_SOURCE_DIR}/include/*.[chi]pp | |
| ${PROJECT_SOURCE_DIR}/include/*.[chi]xx | |
| ${PROJECT_SOURCE_DIR}/include/*.[chi]cc | |
| ${PROJECT_SOURCE_DIR}/include/*.[chi]hh | |
| ${PROJECT_SOURCE_DIR}/include/*.[chi]ii | |
| ${PROJECT_SOURCE_DIR}/include/*.[CHI] | |
| ) | |
| # Add format target if executable is found | |
| find_program(CLANG_FORMAT "clang-format") | |
| if(CLANG_FORMAT) | |
| add_custom_target( | |
| format | |
| COMMAND /usr/bin/clang-format | |
| -i | |
| -style=file | |
| ${ALL_CXX_SOURCE_FILES} | |
| ) | |
| endif() | |
| endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment