Unverified Commit c3b60c28 authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

[ci] Run cmakelint at CI and fix some errors (#4617)

parent b5557b6b
...@@ -71,7 +71,7 @@ if [[ $TASK == "lint" ]]; then ...@@ -71,7 +71,7 @@ if [[ $TASK == "lint" ]]; then
libxml2 \ libxml2 \
"r-xfun>=0.19" \ "r-xfun>=0.19" \
"r-lintr>=2.0" "r-lintr>=2.0"
pip install --user cpplint isort mypy pip install --user cmakelint cpplint isort mypy
echo "Linting Python code" echo "Linting Python code"
pycodestyle --ignore=E501,W503 --exclude=./.nuget,./external_libs . || exit -1 pycodestyle --ignore=E501,W503 --exclude=./.nuget,./external_libs . || exit -1
pydocstyle --convention=numpy --add-ignore=D105 --match-dir="^(?!^external_libs|test|example).*" --match="(?!^test_|setup).*\.py" . || exit -1 pydocstyle --convention=numpy --add-ignore=D105 --match-dir="^(?!^external_libs|test|example).*" --match="(?!^test_|setup).*\.py" . || exit -1
...@@ -81,6 +81,8 @@ if [[ $TASK == "lint" ]]; then ...@@ -81,6 +81,8 @@ if [[ $TASK == "lint" ]]; then
Rscript ${BUILD_DIRECTORY}/.ci/lint_r_code.R ${BUILD_DIRECTORY} || exit -1 Rscript ${BUILD_DIRECTORY}/.ci/lint_r_code.R ${BUILD_DIRECTORY} || exit -1
echo "Linting C++ code" echo "Linting C++ code"
cpplint --filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length --recursive ./src ./include ./R-package ./swig ./tests || exit -1 cpplint --filter=-build/c++11,-build/include_subdir,-build/header_guard,-whitespace/line_length --recursive ./src ./include ./R-package ./swig ./tests || exit -1
cmake_files=$(find . -name CMakeLists.txt -o -path "*/cmake/*.cmake")
cmakelint --linelength=120 ${cmake_files} || true
exit 0 exit 0
fi fi
......
...@@ -34,7 +34,7 @@ PROJECT(lightgbm LANGUAGES C CXX) ...@@ -34,7 +34,7 @@ PROJECT(lightgbm LANGUAGES C CXX)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
#-- Sanitizer #-- Sanitizer
if (USE_SANITIZER) if(USE_SANITIZER)
if(MSVC) if(MSVC)
message(FATAL_ERROR "Sanitizers are not supported with MSVC.") message(FATAL_ERROR "Sanitizers are not supported with MSVC.")
endif(MSVC) endif(MSVC)
...@@ -144,11 +144,11 @@ if(USE_GPU) ...@@ -144,11 +144,11 @@ if(USE_GPU)
find_package(OpenCL REQUIRED) find_package(OpenCL REQUIRED)
include_directories(${OpenCL_INCLUDE_DIRS}) include_directories(${OpenCL_INCLUDE_DIRS})
MESSAGE(STATUS "OpenCL include directory: " ${OpenCL_INCLUDE_DIRS}) MESSAGE(STATUS "OpenCL include directory: " ${OpenCL_INCLUDE_DIRS})
if (WIN32) if(WIN32)
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_LIBS ON)
endif() endif()
find_package(Boost 1.56.0 COMPONENTS filesystem system REQUIRED) find_package(Boost 1.56.0 COMPONENTS filesystem system REQUIRED)
if (WIN32) if(WIN32)
# disable autolinking in boost # disable autolinking in boost
add_definitions(-DBOOST_ALL_NO_LIB) add_definitions(-DBOOST_ALL_NO_LIB)
endif() endif()
...@@ -194,7 +194,7 @@ if(USE_CUDA) ...@@ -194,7 +194,7 @@ if(USE_CUDA)
message(STATUS "CMAKE_CUDA_FLAGS: ${CMAKE_CUDA_FLAGS}") message(STATUS "CMAKE_CUDA_FLAGS: ${CMAKE_CUDA_FLAGS}")
ADD_DEFINITIONS(-DUSE_CUDA) ADD_DEFINITIONS(-DUSE_CUDA)
if (NOT DEFINED CMAKE_CUDA_STANDARD) if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 11) set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED ON) set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif() endif()
...@@ -230,7 +230,7 @@ if(USE_CUDA) ...@@ -230,7 +230,7 @@ if(USE_CUDA)
) )
endfunction() endfunction()
foreach (hsize _16_64_256) foreach(hsize _16_64_256)
add_histogram("${hsize}" "_sp_const" "True" "1" "${BASE_DEFINES}") add_histogram("${hsize}" "_sp_const" "True" "1" "${BASE_DEFINES}")
add_histogram("${hsize}" "_sp" "True" "0" "${BASE_DEFINES}") add_histogram("${hsize}" "_sp" "True" "0" "${BASE_DEFINES}")
add_histogram("${hsize}" "-allfeats_sp_const" "False" "1" "${ALLFEATS_DEFINES}") add_histogram("${hsize}" "-allfeats_sp_const" "False" "1" "${ALLFEATS_DEFINES}")
...@@ -364,7 +364,7 @@ if(__BUILD_FOR_R) ...@@ -364,7 +364,7 @@ if(__BUILD_FOR_R)
list(APPEND SOURCES "src/lightgbm_R.cpp") list(APPEND SOURCES "src/lightgbm_R.cpp")
endif(__BUILD_FOR_R) endif(__BUILD_FOR_R)
if (BUILD_STATIC_LIB) if(BUILD_STATIC_LIB)
add_library(_lightgbm STATIC ${SOURCES}) add_library(_lightgbm STATIC ${SOURCES})
else() else()
add_library(_lightgbm SHARED ${SOURCES}) add_library(_lightgbm SHARED ${SOURCES})
......
...@@ -79,7 +79,7 @@ elseif(WIN32) ...@@ -79,7 +79,7 @@ elseif(WIN32)
endif() endif()
if (NOT LIBR_EXECUTABLE) if(NOT LIBR_EXECUTABLE)
find_program( find_program(
LIBR_EXECUTABLE LIBR_EXECUTABLE
NAMES R R.exe NAMES R R.exe
...@@ -99,7 +99,7 @@ if (NOT LIBR_EXECUTABLE) ...@@ -99,7 +99,7 @@ if (NOT LIBR_EXECUTABLE)
endif() endif()
# Find R executable unless it has been provided directly or already found # Find R executable unless it has been provided directly or already found
if (NOT LIBR_EXECUTABLE) if(NOT LIBR_EXECUTABLE)
if(APPLE) if(APPLE)
find_library(LIBR_LIBRARIES R) find_library(LIBR_LIBRARIES R)
...@@ -193,7 +193,7 @@ find_library( ...@@ -193,7 +193,7 @@ find_library(
# starting from CMake 3.17, find_library() will not find .dll files by default # starting from CMake 3.17, find_library() will not find .dll files by default
# https://cmake.org/cmake/help/v3.17/release/3.17.html#other-changes # https://cmake.org/cmake/help/v3.17/release/3.17.html#other-changes
if (WIN32 AND NOT LIBR_CORE_LIBRARY) if(WIN32 AND NOT LIBR_CORE_LIBRARY)
find_file( find_file(
LIBR_CORE_LIBRARY LIBR_CORE_LIBRARY
NAME R.dll NAME R.dll
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment