Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from wdigger/cmake
Changed: cpp linting with cmake
- Loading branch information
Showing
7 changed files
with
52 additions
and
11 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
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
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
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
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,35 @@ | ||
find_package(PythonInterp) | ||
|
||
if(PYTHONINTERP_FOUND AND NOT CPPLINT_FOUND) | ||
file(DOWNLOAD "https://github.com/google/styleguide/archive/gh-pages.zip" "${CMAKE_CURRENT_BINARY_DIR}/styleguide.zip") | ||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xz styleguide.zip | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
set(CPPLINT_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/styleguide-gh-pages/cpplint/cpplint.py" CACHE FILEPATH "CppLint commad") | ||
set(CPPLINT_FOUND ON CACHE BOOL "CppLint found") | ||
endif() | ||
|
||
function(enable_check_style) | ||
if(CPPLINT_FOUND) | ||
add_custom_target(check_style) | ||
endif() | ||
endfunction() | ||
|
||
function(target_check_style TARGET) | ||
if(CPPLINT_FOUND) | ||
get_target_property(TARGET_SOURCES ${TARGET} SOURCES) | ||
|
||
set(TARGET_NAME "check_style_${TARGET}") | ||
|
||
set(SOURCES_LIST) | ||
foreach(sourcefile ${TARGET_SOURCES}) | ||
if(sourcefile MATCHES \\.c$|\\.cxx$|\\.cpp$|\\.cc$|\\.h$|\\.hh$) | ||
list(APPEND SOURCES_LIST ${sourcefile}) | ||
endif() | ||
endforeach(sourcefile) | ||
|
||
add_custom_target(${TARGET_NAME} ${PYTHON_EXECUTABLE} ${CPPLINT_COMMAND} ${SOURCES_LIST} | ||
DEPENDS ${SOURCES_LIST} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | ||
add_dependencies(check_style ${TARGET_NAME}) | ||
endif() | ||
endfunction() |
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
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