Skip to content

Commit

Permalink
Fix/relax CMake linter rules (pytorch#35574)
Browse files Browse the repository at this point in the history
Summary:
Ignore mixed upper-case/lower-case style for now
Fix space between function and its arguments violation
Pull Request resolved: pytorch#35574

Test Plan: CI

Differential Revision: D20712969

Pulled By: malfet

fbshipit-source-id: 0012d430aed916b4518599a0b535e82d15721f78
  • Loading branch information
malfet authored and facebook-github-bot committed Mar 27, 2020
1 parent 96eec95 commit b9adbb5
Show file tree
Hide file tree
Showing 25 changed files with 201 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .cmakelintrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
filter=-convention/filename,-linelength,-package/consistency,-readability/logic,+readability/mixedcase,-readability/wonkycase,-syntax,-whitespace/eol,+whitespace/extra,-whitespace/indent,-whitespace/mismatch,-whitespace/newline,-whitespace/tabs
filter=-convention/filename,-linelength,-package/consistency,-readability/logic,-readability/mixedcase,-readability/wonkycase,-syntax,-whitespace/eol,+whitespace/extra,-whitespace/indent,-whitespace/mismatch,-whitespace/newline,-whitespace/tabs
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ if(NOT MSVC)
endif()
endif()
if((APPLE AND (NOT ("${CLANG_VERSION_STRING}" VERSION_LESS "9.0")))
OR (CMAKE_COMPILER_IS_GNUCXX
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0 AND NOT APPLE)))
OR(CMAKE_COMPILER_IS_GNUCXX
AND(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0 AND NOT APPLE)))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new")
endif()
if(WERROR)
Expand All @@ -504,19 +504,19 @@ if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
endif()
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -O0")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -O0")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-math-errno")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -O0")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-math-errno")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math")
check_cxx_compiler_flag("-Werror=format" HAS_WERROR_FORMAT)
if(HAS_WERROR_FORMAT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=format")
endif()
endif()

if(USE_ASAN)
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} -fsanitize=address")
endif()

if(APPLE)
Expand Down
8 changes: 4 additions & 4 deletions android/pytorch_android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ endif()

set(pytorch_android_DIR ${CMAKE_CURRENT_LIST_DIR}/src/main/cpp)

if (ANDROID_ABI)
if(ANDROID_ABI)
set(libtorch_include_DIR ${pytorch_android_DIR}/libtorch_include/${ANDROID_ABI})
set(BUILD_SUBDIR ${ANDROID_ABI})
elseif(BUILD_LIBTORCH_WITH_JNI)
# Don't need LIBTORCH_HOME if we're building from within PyTorch.
else()
# Building against a pre-built libtorch.
if (NOT LIBTORCH_HOME)
if(NOT LIBTORCH_HOME)
message(FATAL_ERROR
"pytorch_android requires LIBTORCH_HOME to be defined for non-Android builds.")
endif()
Expand All @@ -48,7 +48,7 @@ add_library(pytorch_jni SHARED
${pytorch_android_SOURCES}
)

if (APPLE)
if(APPLE)
# Need to add rpath so dlopen can find dependencies.
add_custom_command(TARGET pytorch_jni
POST_BUILD COMMAND
Expand All @@ -69,7 +69,7 @@ set(fbjni_BUILD_DIR ${CMAKE_BINARY_DIR}/fbjni/${BUILD_SUBDIR})

add_subdirectory(${fbjni_DIR} ${fbjni_BUILD_DIR})

if (ANDROID_ABI)
if(ANDROID_ABI)

function(import_static_lib name)
add_library(${name} STATIC IMPORTED)
Expand Down
6 changes: 3 additions & 3 deletions aten/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
if (NOT INTERN_BUILD_ATEN_OPS)
if(NOT INTERN_BUILD_ATEN_OPS)
return()
endif()

# Find modules
if (NOT INTERN_BUILD_MOBILE)
if(NOT INTERN_BUILD_MOBILE)
list(APPEND CMAKE_MODULE_PATH /usr/lib/x86_64-linux-gnu/)
list(APPEND CMAKE_LIBRARY_PATH /usr/lib/x86_64-linux-gnu/ /usr/lib/aarch64-linux-gnu/)
endif()
Expand Down Expand Up @@ -53,7 +53,7 @@ list(APPEND ATen_CPU_INCLUDE ${TH_CPU_INCLUDE})
# Find the HIP package, set the HIP paths, load the HIP CMake.
IF(USE_ROCM)
include(LoadHIP)
if (NOT PYTORCH_FOUND_HIP)
if(NOT PYTORCH_FOUND_HIP)
set(USE_ROCM OFF)
endif()
ENDIF()
Expand Down
18 changes: 9 additions & 9 deletions aten/src/ATen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ENDIF()

# this flag is used in Config but set externally, we must normalize it
# to 0/1 otherwise `#if ON` will be evaluated to false.
if (CAFFE2_STATIC_LINK_CUDA)
if(CAFFE2_STATIC_LINK_CUDA)
set(CAFFE2_STATIC_LINK_CUDA_INT 1)
else()
set(CAFFE2_STATIC_LINK_CUDA_INT 0)
Expand Down Expand Up @@ -128,14 +128,14 @@ list(APPEND ATen_CPU_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/..)
# so the build can find the generated header files
list(APPEND ATen_CPU_INCLUDE ${CMAKE_CURRENT_BINARY_DIR})

IF (USE_TBB)
IF(USE_TBB)
message("ATen is compiled with TBB (${TBB_ROOT_DIR})")
list(APPEND ATen_CPU_INCLUDE ${TBB_ROOT_DIR}/include)
list(APPEND ATen_CPU_DEPENDENCY_LIBS tbb)
ENDIF()

IF(BLAS_FOUND)
IF ($ENV{TH_BINARY_BUILD})
IF($ENV{TH_BINARY_BUILD})
MESSAGE(STATUS "TH_BINARY_BUILD detected. Enabling special linkage.")
list(APPEND ATen_CPU_DEPENDENCY_LIBS
"${BLAS_LIBRARIES};${BLAS_LIBRARIES};${BLAS_LIBRARIES}")
Expand All @@ -147,15 +147,15 @@ IF(BLAS_FOUND)
list(APPEND ATen_HIP_DEPENDENCY_LIBS
"${BLAS_LIBRARIES};${BLAS_LIBRARIES};${BLAS_LIBRARIES}")
endif()
ELSE ($ENV{TH_BINARY_BUILD})
ELSE($ENV{TH_BINARY_BUILD})
list(APPEND ATen_CPU_DEPENDENCY_LIBS ${BLAS_LIBRARIES})
if(USE_CUDA)
list(APPEND ATen_CUDA_DEPENDENCY_LIBS "${BLAS_LIBRARIES}")
endif()
if(USE_ROCM)
list(APPEND ATen_HIP_DEPENDENCY_LIBS "${BLAS_LIBRARIES}")
endif()
ENDIF ($ENV{TH_BINARY_BUILD})
ENDIF($ENV{TH_BINARY_BUILD})
ENDIF(BLAS_FOUND)

IF(LAPACK_FOUND)
Expand All @@ -176,7 +176,7 @@ IF(LAPACK_FOUND)
endif()
ENDIF(LAPACK_FOUND)

IF (UNIX AND NOT APPLE)
IF(UNIX AND NOT APPLE)
INCLUDE(CheckLibraryExists)
# https://github.com/libgit2/libgit2/issues/2128#issuecomment-35649830
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
Expand Down Expand Up @@ -275,7 +275,7 @@ if(NOT MSVC AND NOT EMSCRIPTEN AND NOT INTERN_BUILD_MOBILE)
endif()

IF(USE_CUDA AND NOT USE_ROCM)
IF ($ENV{ATEN_STATIC_CUDA})
IF($ENV{ATEN_STATIC_CUDA})
# CuFFT has a complicated static story (especially around CUDA < 9) because it has device callback support
# we first have to build a fake lib that links with no device callbacks,
# and then we link against this object file.
Expand Down Expand Up @@ -330,12 +330,12 @@ IF(USE_CUDA AND NOT USE_ROCM)

IF(USE_MAGMA)
list(APPEND ATen_CUDA_DEPENDENCY_LIBS ${MAGMA_LIBRARIES})
IF ($ENV{TH_BINARY_BUILD})
IF($ENV{TH_BINARY_BUILD})
list(APPEND ATen_CUDA_DEPENDENCY_LIBS
"${BLAS_LIBRARIES};${BLAS_LIBRARIES};${BLAS_LIBRARIES}")
ENDIF($ENV{TH_BINARY_BUILD})
ENDIF(USE_MAGMA)
IF ($ENV{ATEN_STATIC_CUDA})
IF($ENV{ATEN_STATIC_CUDA})
list(APPEND ATen_CUDA_DEPENDENCY_LIBS "${CUDA_TOOLKIT_ROOT_DIR}/lib64/libculibos.a")
list(APPEND ATen_CUDA_DEPENDENCY_LIBS "${CUDA_TOOLKIT_ROOT_DIR}/lib64/libcudart_static.a")
ENDIF($ENV{ATEN_STATIC_CUDA})
Expand Down
48 changes: 24 additions & 24 deletions aten/src/ATen/cpu/tbb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Based on https://github.com/wjakob/tbb/blob/master/CMakeLists.txt
# All credit goes to Wenzel Jakob!

cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
project (tbb CXX)
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
project(tbb CXX)

include(CheckCXXCompilerFlag)
include(CheckCXXSourceRuns)
Expand Down Expand Up @@ -119,25 +119,25 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

if(UNIX)
add_definitions (-DUSE_PTHREAD)
add_definitions(-DUSE_PTHREAD)

check_cxx_compiler_flag ("-std=c++14" SUPPORTS_STDCXX14)
check_cxx_compiler_flag("-std=c++14" SUPPORTS_STDCXX14)
if(SUPPORTS_STDCXX14)
set (CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
endif()

check_cxx_compiler_flag ("-mrtm -Werror" SUPPORTS_MRTM)
check_cxx_compiler_flag("-mrtm -Werror" SUPPORTS_MRTM)
if(SUPPORTS_MRTM)
set (CMAKE_CXX_FLAGS "-mrtm ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-mrtm ${CMAKE_CXX_FLAGS}")
endif()

elseif(WIN32)
if(MSVC)
cmake_minimum_required (VERSION 3.1)
cmake_minimum_required(VERSION 3.1)
enable_language(ASM_MASM)
set(CMAKE_CXX_FLAGS "/GS- /Zc:wchar_t /Zc:forScope /DUSE_WINTHREAD ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "/D_CRT_SECURE_NO_DEPRECATE /D_WIN32_WINNT=0x0600 ${CMAKE_CXX_FLAGS}")
check_cxx_compiler_flag ("/volatile:iso" SUPPORTS_VOLATILE_FLAG)
check_cxx_compiler_flag("/volatile:iso" SUPPORTS_VOLATILE_FLAG)
if(SUPPORTS_VOLATILE_FLAG)
set(CMAKE_CXX_FLAGS "/volatile:iso ${CMAKE_CXX_FLAGS}")
endif()
Expand Down Expand Up @@ -191,19 +191,19 @@ endif()
##-------

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
check_cxx_compiler_flag ("-flifetime-dse=1" SUPPORTS_FLIFETIME)
check_cxx_compiler_flag("-flifetime-dse=1" SUPPORTS_FLIFETIME)
if(SUPPORTS_FLIFETIME)
add_definitions(-flifetime-dse=1)
endif()
endif()

# Linker export definitions
if(APPLE)
set (ARCH_PREFIX "mac")
set(ARCH_PREFIX "mac")
elseif(WIN32)
set (ARCH_PREFIX "win")
set(ARCH_PREFIX "win")
else()
set (ARCH_PREFIX "lin")
set(ARCH_PREFIX "lin")
endif()

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
Expand All @@ -213,9 +213,9 @@ else()
endif()

if(MINGW)
set (ARCH_PREFIX "${ARCH_PREFIX}-gcc")
set(ARCH_PREFIX "${ARCH_PREFIX}-gcc")
# there's no win32-gcc-tbb-export.def, use lin32-tbb-export.def
execute_process (COMMAND ${CMAKE_COMMAND} -E copy ${TBB_ROOT_DIR}/src/tbb/lin32-tbb-export.def ${TBB_ROOT_DIR}/src/tbb/win32-gcc-tbb-export.def)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${TBB_ROOT_DIR}/src/tbb/lin32-tbb-export.def ${TBB_ROOT_DIR}/src/tbb/win32-gcc-tbb-export.def)
endif()

if(MSVC)
Expand Down Expand Up @@ -377,15 +377,15 @@ install(DIRECTORY "${TBB_ROOT_DIR}/include/tbb" DESTINATION ${TBB_INSTALL_INCLUD

# version_string.ver
if(UNIX)
execute_process (COMMAND date "+%a, %d %b %Y %H:%M:%S %z"
OUTPUT_VARIABLE _configure_date
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND date "+%a, %d %b %Y %H:%M:%S %z"
OUTPUT_VARIABLE _configure_date
OUTPUT_STRIP_TRAILING_WHITESPACE)
elseif(WIN32)
execute_process (COMMAND cmd " /C date /T"
OUTPUT_VARIABLE _configure_date
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND cmd " /C date /T"
OUTPUT_VARIABLE _configure_date
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set (_configure_date "Unknown")
set(_configure_date "Unknown")
endif()
include_directories (${CMAKE_BINARY_DIR})
configure_file (extra/version_string.ver.in version_string.ver @ONLY)
include_directories(${CMAKE_BINARY_DIR})
configure_file(extra/version_string.ver.in version_string.ver @ONLY)
6 changes: 3 additions & 3 deletions aten/src/ATen/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IF (MSVC)
IF (MSVC_VERSION LESS 1911)
IF(MSVC)
IF(MSVC_VERSION LESS 1911)
return()
ENDIF()
ENDIF(MSVC)
Expand Down Expand Up @@ -49,7 +49,7 @@ list(APPEND ATen_CUDA_TEST_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/cuda_tensor_interop_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cuda_vectorized_test.cu
${CMAKE_CURRENT_SOURCE_DIR}/cuda_generator_test.cu)
if (CAFFE2_USE_CUDNN)
if(CAFFE2_USE_CUDNN)
list(APPEND ATen_CUDA_TEST_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/cuda_cudnn_test.cpp)
endif()
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/test/test_install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ find_package(ATen REQUIRED)
include_directories(${ATEN_INCLUDE_DIR})

# C++14
if (not MSVC)
if(not MSVC)
set(CMAKE_CXX_FLAGS "--std=c++14 ${CMAKE_CXX_FLAGS}")
endif()
add_executable(main main.cpp)
Expand Down
24 changes: 12 additions & 12 deletions binaries/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if (INTERN_BUILD_MOBILE)
if (BUILD_CAFFE2_MOBILE)
if(INTERN_BUILD_MOBILE)
if(BUILD_CAFFE2_MOBILE)
caffe2_binary_target("predictor_verifier.cc")
caffe2_binary_target("speed_benchmark.cc")
else()
Expand Down Expand Up @@ -33,36 +33,36 @@ caffe2_binary_target("split_db.cc")

caffe2_binary_target("db_throughput.cc")

if (BUILD_TEST)
if(BUILD_TEST)
# Core overhead benchmark
caffe2_binary_target("core_overhead_benchmark.cc")
target_link_libraries(core_overhead_benchmark benchmark)
endif()

if (USE_CUDA)
if(USE_CUDA)
caffe2_binary_target("inspect_gpu.cc")
target_link_libraries(inspect_gpu ${CUDA_LIBRARIES})
caffe2_binary_target("print_core_object_sizes_gpu.cc")

if (BUILD_TEST)
if(BUILD_TEST)
# Core overhead benchmark
caffe2_binary_target("core_overhead_benchmark_gpu.cc")
target_link_libraries(core_overhead_benchmark_gpu benchmark ${CUDA_curand_LIBRARY})
endif()
endif()

if (USE_ROCM)
if(USE_ROCM)
caffe2_hip_binary_target("hip/inspect_gpu.cc")
caffe2_hip_binary_target("hip/print_core_object_sizes_gpu.cc")

if (BUILD_TEST)
if(BUILD_TEST)
# Core overhead benchmark
caffe2_hip_binary_target("hip/core_overhead_benchmark_gpu.cc")
target_link_libraries(core_overhead_benchmark_gpu benchmark)
endif()
endif()

if (USE_ZMQ)
if(USE_ZMQ)
caffe2_binary_target("zmq_feeder.cc")
target_link_libraries(zmq_feeder ${ZMQ_LIBRARIES})
endif()
Expand All @@ -72,25 +72,25 @@ if(USE_MPI)
target_link_libraries(run_plan_mpi ${MPI_CXX_LIBRARIES})
endif()

if (USE_OPENCV AND USE_LEVELDB)
if(USE_OPENCV AND USE_LEVELDB)
caffe2_binary_target("convert_encoded_to_raw_leveldb.cc")
target_link_libraries(
convert_encoded_to_raw_leveldb
${OpenCV_LIBS} ${LevelDB_LIBRARIES} ${Snappy_LIBRARIES})
endif()

if (USE_OPENCV)
if(USE_OPENCV)
caffe2_binary_target("make_image_db.cc")
target_link_libraries(make_image_db ${OpenCV_LIBS})
caffe2_binary_target("convert_image_to_tensor.cc")
target_link_libraries(convert_image_to_tensor ${OpenCV_LIBS})
endif()

if (USE_OBSERVERS)
if(USE_OBSERVERS)
caffe2_binary_target(caffe2_benchmark "caffe2_benchmark.cc" "benchmark_helper.cc")
endif()

if (USE_OBSERVERS AND USE_OPENCV)
if(USE_OBSERVERS AND USE_OPENCV)
caffe2_binary_target("convert_and_benchmark.cc")
target_link_libraries(convert_and_benchmark ${OpenCV_LIBS})
endif()
Expand Down
Loading

0 comments on commit b9adbb5

Please sign in to comment.