From 144036f2df5b584b8302742c7036545f90f08fdb Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Sun, 14 Nov 2021 04:38:28 +0300 Subject: [PATCH] [ci] fix CMakeLint errors related to function naming case (#4794) * Update CMakeLists.txt * Update CMakeLists.txt * Update static_analysis.yml * Update CMakeLists.txt * Update test.sh * Update CMakeLists.txt * Update static_analysis.yml --- .ci/test.sh | 2 +- CMakeLists.txt | 118 ++++++++++++++++++++++++------------------------- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/.ci/test.sh b/.ci/test.sh index 980b77f81999..9afd0a86a659 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -82,7 +82,7 @@ if [[ $TASK == "lint" ]]; then 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 cmake_files=$(find . -name CMakeLists.txt -o -path "*/cmake/*.cmake") - cmakelint --linelength=120 ${cmake_files} || true + cmakelint --linelength=120 --filter=-readability/wonkycase ${cmake_files} || true exit 0 fi diff --git a/CMakeLists.txt b/CMakeLists.txt index d3c128f14f42..5eac26a61764 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,13 @@ -OPTION(USE_MPI "Enable MPI-based distributed learning" OFF) -OPTION(USE_OPENMP "Enable OpenMP" ON) -OPTION(USE_GPU "Enable GPU-accelerated training" OFF) -OPTION(USE_SWIG "Enable SWIG to generate Java API" OFF) -OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF) -OPTION(USE_TIMETAG "Set to ON to output time costs" OFF) -OPTION(USE_CUDA "Enable CUDA-accelerated training (EXPERIMENTAL)" OFF) -OPTION(USE_DEBUG "Set to ON for Debug mode" OFF) -OPTION(USE_SANITIZER "Use santizer flags" OFF) -SET( +option(USE_MPI "Enable MPI-based distributed learning" OFF) +option(USE_OPENMP "Enable OpenMP" ON) +option(USE_GPU "Enable GPU-accelerated training" OFF) +option(USE_SWIG "Enable SWIG to generate Java API" OFF) +option(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF) +option(USE_TIMETAG "Set to ON to output time costs" OFF) +option(USE_CUDA "Enable CUDA-accelerated training (EXPERIMENTAL)" OFF) +option(USE_DEBUG "Set to ON for Debug mode" OFF) +option(USE_SANITIZER "Use santizer flags" OFF) +set( ENABLED_SANITIZERS "address" "leak" "undefined" CACHE @@ -15,13 +15,13 @@ SET( "Semicolon separated list of sanitizer names, e.g., 'address;leak'. \ Supported sanitizers are address, leak, undefined and thread." ) -OPTION(BUILD_CPP_TEST "Build C++ tests with Google Test" OFF) -OPTION(BUILD_STATIC_LIB "Build static library" OFF) -OPTION(__BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R package" OFF) -OPTION(__INTEGRATE_OPENCL "Set to ON if building LightGBM with the OpenCL ICD Loader and its dependencies included" OFF) +option(BUILD_CPP_TEST "Build C++ tests with Google Test" OFF) +option(BUILD_STATIC_LIB "Build static library" OFF) +option(__BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R package" OFF) +option(__INTEGRATE_OPENCL "Set to ON if building LightGBM with the OpenCL ICD Loader and its dependencies included" OFF) if(APPLE) - OPTION(APPLE_OUTPUT_DYLIB "Output dylib shared library" OFF) + option(APPLE_OUTPUT_DYLIB "Output dylib shared library" OFF) endif() if(__INTEGRATE_OPENCL) @@ -34,7 +34,7 @@ else() cmake_minimum_required(VERSION 3.0) endif() -PROJECT(lightgbm LANGUAGES C CXX) +project(lightgbm LANGUAGES C CXX) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") @@ -92,22 +92,22 @@ if(USE_SWIG) include_directories(JNI_INCLUDE_DIRS) include_directories($ENV{JAVA_HOME}/include) if(WIN32) - FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/windows/x86_64") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/windows/x86_64") include_directories($ENV{JAVA_HOME}/include/win32) elseif(APPLE) - FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/osx/x86_64") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/osx/x86_64") include_directories($ENV{JAVA_HOME}/include/darwin) else() - FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/linux/x86_64") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/com/microsoft/ml/lightgbm/linux/x86_64") include_directories($ENV{JAVA_HOME}/include/linux) endif() endif() -SET(EIGEN_DIR "${PROJECT_SOURCE_DIR}/external_libs/eigen") +set(EIGEN_DIR "${PROJECT_SOURCE_DIR}/external_libs/eigen") include_directories(${EIGEN_DIR}) # See https://gitlab.com/libeigen/eigen/-/blob/master/COPYING.README -ADD_DEFINITIONS(-DEIGEN_MPL2_ONLY) +add_definitions(-DEIGEN_MPL2_ONLY) if(__BUILD_FOR_R) find_package(LibR REQUIRED) @@ -115,41 +115,41 @@ if(__BUILD_FOR_R) message(STATUS "LIBR_INCLUDE_DIRS: ${LIBR_INCLUDE_DIRS}") message(STATUS "LIBR_CORE_LIBRARY: ${LIBR_CORE_LIBRARY}") include_directories(${LIBR_INCLUDE_DIRS}) - ADD_DEFINITIONS(-DLGB_R_BUILD) + add_definitions(-DLGB_R_BUILD) endif() if(USE_TIMETAG) - ADD_DEFINITIONS(-DTIMETAG) + add_definitions(-DTIMETAG) endif() if(USE_DEBUG) - ADD_DEFINITIONS(-DDEBUG) + add_definitions(-DDEBUG) endif() if(USE_MPI) find_package(MPI REQUIRED) - ADD_DEFINITIONS(-DUSE_MPI) + add_definitions(-DUSE_MPI) else() - ADD_DEFINITIONS(-DUSE_SOCKET) + add_definitions(-DUSE_SOCKET) endif() if(USE_CUDA) - SET(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}") + set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}") enable_language(CUDA) - SET(USE_OPENMP ON CACHE BOOL "CUDA requires OpenMP" FORCE) + set(USE_OPENMP ON CACHE BOOL "CUDA requires OpenMP" FORCE) endif() if(USE_OPENMP) find_package(OpenMP REQUIRED) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") endif() if(USE_GPU) - SET(BOOST_COMPUTE_HEADER_DIR ${PROJECT_SOURCE_DIR}/external_libs/compute/include) + set(BOOST_COMPUTE_HEADER_DIR ${PROJECT_SOURCE_DIR}/external_libs/compute/include) include_directories(${BOOST_COMPUTE_HEADER_DIR}) find_package(OpenCL REQUIRED) include_directories(${OpenCL_INCLUDE_DIRS}) - MESSAGE(STATUS "OpenCL include directory: " ${OpenCL_INCLUDE_DIRS}) + message(STATUS "OpenCL include directory: " ${OpenCL_INCLUDE_DIRS}) if(WIN32) set(Boost_USE_STATIC_LIBS ON) endif() @@ -159,13 +159,13 @@ if(USE_GPU) add_definitions(-DBOOST_ALL_NO_LIB) endif() include_directories(${Boost_INCLUDE_DIRS}) - ADD_DEFINITIONS(-DUSE_GPU) + add_definitions(-DUSE_GPU) endif() if(__INTEGRATE_OPENCL) if(WIN32) include(cmake/IntegratedOpenCL.cmake) - ADD_DEFINITIONS(-DUSE_GPU) + add_definitions(-DUSE_GPU) else() message(FATAL_ERROR "Integrated OpenCL build is available only for Windows") endif() @@ -188,18 +188,18 @@ if(USE_CUDA) endif() list(POP_BACK CUDA_ARCHS CUDA_LAST_SUPPORTED_ARCH) list(APPEND CUDA_ARCHS "${CUDA_LAST_SUPPORTED_ARCH}+PTX") - CUDA_SELECT_NVCC_ARCH_FLAGS(CUDA_ARCH_FLAGS ${CUDA_ARCHS}) + cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS ${CUDA_ARCHS}) string(REPLACE ";" " " CUDA_ARCH_FLAGS "${CUDA_ARCH_FLAGS}") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${CUDA_ARCH_FLAGS}") if(USE_DEBUG) - SET(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -g") + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -g") else() - SET(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -O3 -lineinfo") + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -O3 -lineinfo") endif() message(STATUS "CMAKE_CUDA_FLAGS: ${CMAKE_CUDA_FLAGS}") - ADD_DEFINITIONS(-DUSE_CUDA) + add_definitions(-DUSE_CUDA) if(NOT DEFINED CMAKE_CUDA_STANDARD) set(CMAKE_CUDA_STANDARD 11) set(CMAKE_CUDA_STANDARD_REQUIRED ON) @@ -255,8 +255,8 @@ if(USE_HDFS) find_path(HDFS_INCLUDE_DIR hdfs.h REQUIRED) find_library(HDFS_LIB NAMES hdfs REQUIRED) include_directories(${HDFS_INCLUDE_DIR}) - ADD_DEFINITIONS(-DUSE_HDFS) - SET(HDFS_CXX_LIBRARIES ${HDFS_LIB} ${JAVA_JVM_LIBRARY}) + add_definitions(-DUSE_HDFS) + set(HDFS_CXX_LIBRARIES ${HDFS_LIB} ${JAVA_JVM_LIBRARY}) endif() include(CheckCXXSourceCompiles) @@ -271,7 +271,7 @@ int main() { if(${MM_PREFETCH}) message(STATUS "Using _mm_prefetch") - ADD_DEFINITIONS(-DMM_PREFETCH) + add_definitions(-DMM_PREFETCH) endif() include(CheckCXXSourceCompiles) @@ -286,36 +286,36 @@ int main() { if(${MM_MALLOC}) message(STATUS "Using _mm_malloc") - ADD_DEFINITIONS(-DMM_MALLOC) + add_definitions(-DMM_MALLOC) endif() if(UNIX OR MINGW OR CYGWIN) - SET( + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -Wextra -Wall -Wno-ignored-attributes -Wno-unknown-pragmas -Wno-return-type" ) if(USE_DEBUG) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0") else() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") endif() if(USE_SWIG) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") endif() if(NOT USE_OPENMP) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas -Wno-unused-private-field") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas -Wno-unused-private-field") endif() if(__BUILD_FOR_R AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-function-type") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-cast-function-type") endif() endif() if(WIN32 AND MINGW) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++") endif() if(MSVC) - SET( + set( variables CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL @@ -326,33 +326,33 @@ if(MSVC) CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO ) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /MP") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /MP") if(USE_DEBUG) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Od") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Od") else() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2 /Oi /Ot /Oy") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2 /Oi /Ot /Oy") endif() else() if(NOT BUILD_STATIC_LIB) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") endif() if(NOT USE_DEBUG) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops") endif() endif() -SET(LightGBM_HEADER_DIR ${PROJECT_SOURCE_DIR}/include) +set(LightGBM_HEADER_DIR ${PROJECT_SOURCE_DIR}/include) -SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}) -SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}) +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}) +set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}) include_directories(${LightGBM_HEADER_DIR}) if(APPLE) if(APPLE_OUTPUT_DYLIB) - SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") else() - SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") endif() endif() @@ -403,7 +403,7 @@ endif() if(USE_SWIG) set_property(SOURCE swig/lightgbmlib.i PROPERTY CPLUSPLUS ON) - LIST(APPEND swig_options -package com.microsoft.ml.lightgbm) + list(APPEND swig_options -package com.microsoft.ml.lightgbm) set_property(SOURCE swig/lightgbmlib.i PROPERTY SWIG_FLAGS "${swig_options}") swig_add_module(_lightgbm_swig java swig/lightgbmlib.i) swig_link_libraries(_lightgbm_swig _lightgbm)