-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cmake target for cmake-format & cmake-lint (#1909)
* Add cmake target for cmake-format Everybody likes clean CMake files... * cmake-lint, cleanup
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,6 +259,7 @@ if($ENV{ENABLE_GCOV_COVERAGE}) | |
endif() | ||
|
||
include(clang-tools) | ||
include(cmakelang-tools) | ||
|
||
set(AUTHORS "Fabian Froehlich, Jan Hasenauer, Daniel Weindl and Paul Stapor") | ||
set(AUTHOR_EMAIL "[email protected]") | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# --- Add targets for cmake-format https://cmake-format.readthedocs.io/ --- | ||
|
||
# Find all CMakeFiles files | ||
set(ALL_CMAKE_FILES | ||
CMakeLists.txt | ||
python/CMakeLists.txt | ||
swig/CMakeLists.txt | ||
tests/cpp/CMakeLists.txt | ||
tests/cpp/unittests/CMakeLists.txt | ||
${CMAKE_MODULE_PATH}/cmakelang-tools.cmake | ||
${CMAKE_MODULE_PATH}/clang-tools.cmake | ||
${CMAKE_MODULE_PATH}/version.cmake) | ||
list(JOIN ALL_CMAKE_FILES " " ALL_CMAKE_FILES) | ||
|
||
# --- cmake-format --- | ||
|
||
# Try to find cmake-format and add target if successful | ||
find_program(CMAKE_FORMAT "cmake-format") | ||
if(CMAKE_FORMAT) | ||
add_custom_target( | ||
cmake-format | ||
COMMAND bash -c "${CMAKE_FORMAT} -i ${ALL_CMAKE_FILES}" | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
COMMENT "Running cmake-format") | ||
else() | ||
message(STATUS "cmake-format was not found") | ||
endif() | ||
|
||
# --- cmake-lint --- | ||
|
||
# Try to find cmake-lint and add target if successful | ||
find_program(CMAKE_LINT "cmake-lint") | ||
if(CMAKE_LINT) | ||
add_custom_target( | ||
cmake-lint | ||
COMMAND bash -c "${CMAKE_LINT} ${ALL_CMAKE_FILES}" | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
COMMENT "Running cmake-lint") | ||
else() | ||
message(STATUS "cmake-lint was not found") | ||
endif() |