4 changed files with 92 additions and 69 deletions
@ -0,0 +1,22 @@
|
||||
|
||||
include(CompileCheck) |
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "") |
||||
set(CMAKE_BUILD_TYPE "Release") |
||||
endif() |
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
||||
|
||||
add_definitions(-DDEBUG) |
||||
|
||||
check_compiler_flag(RESULT "-g3") |
||||
if(NOT RESULT STREQUAL "") |
||||
string(REGEX REPLACE "-g(|[0-9]|gdb)" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") |
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${RESULT}") |
||||
endif() |
||||
|
||||
check_compiler_flag(RESULT "-O0") |
||||
string(REGEX REPLACE "-O[0-9]" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") |
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${RESULT}") |
||||
|
||||
endif() |
||||
@ -0,0 +1,51 @@
|
||||
|
||||
find_package(PythonInterp) |
||||
|
||||
unset(STYLE_FILTER) |
||||
|
||||
# Complains about any c-style cast -> too annoying. |
||||
set(STYLE_FILTER ${STYLE_FILTER},-readability/casting) |
||||
|
||||
# Insists on including evrything in the .cpp file even if it is included in the header. |
||||
# This behaviour conflicts with orther tools. |
||||
set(STYLE_FILTER ${STYLE_FILTER},-build/include_what_you_use) |
||||
|
||||
# Too many false positives and not very helpful error messages. |
||||
set(STYLE_FILTER ${STYLE_FILTER},-build/include_order) |
||||
|
||||
# No thanks. |
||||
set(STYLE_FILTER ${STYLE_FILTER},-readability/streams) |
||||
|
||||
# Ugh! |
||||
set(STYLE_FILTER ${STYLE_FILTER},-whitespace/tab) |
||||
|
||||
# Yes it is! |
||||
set(STYLE_FILTER ${STYLE_FILTER},-whitespace/blank_line) |
||||
|
||||
# Suggessts excessive indentation. |
||||
set(STYLE_FILTER ${STYLE_FILTER},-whitespace/labels) |
||||
|
||||
# Don't tell me how to name my variables. |
||||
set(STYLE_FILTER ${STYLE_FILTER},-runtime/arrays) |
||||
|
||||
# Why? |
||||
set(STYLE_FILTER ${STYLE_FILTER},-whitespace/todo) |
||||
set(STYLE_FILTER ${STYLE_FILTER},-readability/todo) |
||||
|
||||
function(add_style_check_target TARGET_NAME SOURCES_LIST INCLUDES_LIST) |
||||
|
||||
if(PYTHONINTERP_FOUND) |
||||
|
||||
add_custom_target(${TARGET_NAME} |
||||
COMMAND cmake -E chdir |
||||
"${CMAKE_SOURCE_DIR}" |
||||
"${PYTHON_EXECUTABLE}" |
||||
"${CMAKE_MODULE_PATH}/cpplint.py" |
||||
"--filter=${STYLE_FILTER}" |
||||
${INCLUDES_LIST} |
||||
${INCLUDES_LIST} |
||||
) |
||||
|
||||
endif() |
||||
|
||||
endfunction(add_style_check_target) |
||||
Loading…
Reference in new issue