Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmakelint errors for some cmake files #43428

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 1 addition & 46 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,63 +84,33 @@ repos:
exclude: |
(?x)^(
CMakeLists.txt|
paddle/fluid/pybind/CMakeLists.txt|
python/paddle/fluid/tests/unittests/CMakeLists.txt|
paddle/fluid/eager/auto_code_generator/CMakeLists.txt|
paddle/fluid/framework/CMakeLists.txt|
paddle/fluid/eager/auto_code_generator/final_state_generator/CMakeLists.txt|
cmake/third_party.cmake|
python/paddle/fluid/tests/unittests/CMakeLists.txt|
paddle/fluid/inference/tests/infer_ut/CMakeLists.txt|
cmake/configure.cmake|
paddle/fluid/inference/api/demo_ci/CMakeLists.txt|
cmake/flags.cmake|
cmake/inference_lib.cmake|
cmake/external/protobuf.cmake|
cmake/system.cmake|
cmake/cudnn.cmake|
cmake/external/mkldnn.cmake|
cmake/unity_build.cmake|
paddle/fluid/framework/fleet/CMakeLists.txt|
paddle/fluid/inference/CMakeLists.txt|
paddle/fluid/inference/tests/api/CMakeLists.txt|
paddle/fluid/operators/CMakeLists.txt|
paddle/phi/api/lib/CMakeLists.txt|
cmake/external/gflags.cmake|
cmake/external/lite.cmake|
cmake/external/poplar.cmake|
cmake/python_module.cmake|
python/paddle/fluid/tests/unittests/asp/CMakeLists.txt|
cmake/cuda.cmake|
cmake/FindNumPy.cmake|
cmake/phi.cmake|
paddle/fluid/framework/ir/CMakeLists.txt|
paddle/fluid/platform/CMakeLists.txt|
python/paddle/fluid/tests/unittests/mlu/CMakeLists.txt|
python/paddle/tests/CMakeLists.txt|
cmake/ccache.cmake|
cmake/coveralls.cmake|
cmake/external/glog.cmake|
cmake/external/onnxruntime.cmake|
cmake/external/openblas.cmake|
cmake/external/xpu.cmake|
cmake/hip.cmake|
paddle/fluid/distributed/CMakeLists.txt|
paddle/fluid/framework/details/CMakeLists.txt|
paddle/fluid/imperative/CMakeLists.txt|
paddle/fluid/inference/analysis/ir_passes/CMakeLists.txt|
paddle/fluid/inference/api/CMakeLists.txt|
paddle/fluid/operators/controlflow/CMakeLists.txt|
python/paddle/fluid/tests/unittests/distributed_passes/CMakeLists.txt|
cmake/cblas.cmake|
cmake/coverallsGcovJsons.cmake|
cmake/external/brpc.cmake|
cmake/external/cryptopp.cmake|
cmake/external/gtest.cmake|
cmake/external/llvm.cmake|
cmake/external/utf8proc.cmake|
cmake/external/warpctc.cmake|
cmake/external/zlib.cmake|
cmake/FindGperftools.cmake|
cmake/operators.cmake|
cmake/tensorrt.cmake|
paddle/fluid/inference/api/details/CMakeLists.txt|
Expand All @@ -153,28 +123,13 @@ repos:
cmake/miopen.cmake|
cmake/nccl.cmake|
cmake/simd.cmake|
paddle/fluid/distributed/fleet_executor/CMakeLists.txt|
paddle/fluid/eager/api/generated/fluid_generated/forwards/CMakeLists.txt|
paddle/fluid/framework/io/CMakeLists.txt|
paddle/fluid/imperative/tests/CMakeLists.txt|
paddle/fluid/inference/analysis/CMakeLists.txt|
paddle/fluid/inference/tests/infer_ut/external-cmake/gtest-cpp.cmake|
paddle/fluid/memory/allocation/CMakeLists.txt|
paddle/fluid/memory/CMakeLists.txt|
paddle/fluid/operators/cinn/CMakeLists.txt|
paddle/fluid/operators/collective/CMakeLists.txt|
paddle/fluid/operators/ipu/CMakeLists.txt|
paddle/fluid/operators/jit/CMakeLists.txt|
paddle/fluid/operators/pscore/CMakeLists.txt|
paddle/fluid/platform/device/ipu/CMakeLists.txt|
paddle/fluid/platform/dynload/CMakeLists.txt|
paddle/infrt/external_kernels/CMakeLists.txt|
paddle/infrt/kernel/phi/CMakeLists.txt|
paddle/phi/backends/dynload/CMakeLists.txt|
paddle/phi/CMakeLists.txt|
paddle/phi/kernels/CMakeLists.txt|
paddle/phi/tests/core/CMakeLists.txt|
python/CMakeLists.txt|
python/paddle/fluid/contrib/slim/tests/CMakeLists.txt|
python/paddle/fluid/tests/unittests/autograd/CMakeLists.txt|
python/paddle/fluid/tests/unittests/distribution/CMakeLists.txt|
Expand Down
4 changes: 2 additions & 2 deletions cmake/ccache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if(NOT WIN32)
${cache_directory})
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PATH})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PATH})
endif(CCACHE_PATH)
endif()
elseif("${CMAKE_GENERATOR}" STREQUAL "Ninja")
# (Note:zhouwei25) Only Ninja Generator can support sccache now
find_program(SCCACHE_PATH sccache)
Expand All @@ -30,5 +30,5 @@ elseif("${CMAKE_GENERATOR}" STREQUAL "Ninja")
# (Note:zhouwei25) sccache for cuda compiler has bug so that it can't be hit
# refer to https://github.com/mozilla/sccache/issues/1017, so we fix it
set(CMAKE_CUDA_COMPILER_LAUNCHER ${SCCACHE_PATH})
endif(SCCACHE_PATH)
endif()
endif()
14 changes: 7 additions & 7 deletions cmake/coverallsGcovJsons.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ file(GLOB_RECURSE ALL_GCOV_FILES "${COV_PATH}" "*.gcov")
# Get only the filenames to use for filtering.
#set(COVERAGE_SRCS_NAMES "")
#foreach (COVSRC ${COVERAGE_SRCS})
# get_filename_component(COVSRC_NAME ${COVSRC} NAME)
# message("${COVSRC} -> ${COVSRC_NAME}")
# list(APPEND COVERAGE_SRCS_NAMES "${COVSRC_NAME}")
# get_filename_component(COVSRC_NAME ${COVSRC} NAME)
# message("${COVSRC} -> ${COVSRC_NAME}")
# list(APPEND COVERAGE_SRCS_NAMES "${COVSRC_NAME}")
#endforeach()

#
Expand All @@ -155,15 +155,15 @@ file(GLOB_RECURSE ALL_GCOV_FILES "${COV_PATH}" "*.gcov")
#
# Example:
# COVERAGE_SRCS =
# /path/to/project/root/subdir/the_file.c
# /path/to/project/root/subdir/the_file.c
#
# ALL_GCOV_FILES =
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
# /path/to/project/root/build/#path#to#project#root#subdir#other_file.c.gcov
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
# /path/to/project/root/build/#path#to#project#root#subdir#other_file.c.gcov
#
# Result should be:
# GCOV_FILES =
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
#
set(GCOV_FILES "")
#message("Look in coverage sources: ${COVERAGE_SRCS}")
Expand Down
10 changes: 5 additions & 5 deletions cmake/cudnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ endif()

if(WIN32)
set(CUDNN_ROOT ${CUDA_TOOLKIT_ROOT_DIR})
else(WIN32)
else()
set(CUDNN_ROOT
"/usr"
CACHE PATH "CUDNN ROOT")
endif(WIN32)
endif()

find_path(
CUDNN_INCLUDE_DIR cudnn.h
Expand Down Expand Up @@ -41,16 +41,16 @@ set(CUDNN_LIB_NAME "")

if(LINUX)
set(CUDNN_LIB_NAME "libcudnn.so")
endif(LINUX)
endif()

if(WIN32)
# only support cudnn7
set(CUDNN_LIB_NAME "cudnn.lib" "cudnn64_7.dll")
endif(WIN32)
endif()

if(APPLE)
set(CUDNN_LIB_NAME "libcudnn.dylib" "libcudnn.so")
endif(APPLE)
endif()

find_library(
CUDNN_LIBRARY
Expand Down
4 changes: 2 additions & 2 deletions cmake/external/cryptopp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ if(WIN32)
${CMAKE_COMMAND} -E copy_if_different
"${PADDLE_SOURCE_DIR}/patches/cryptopp/CMakeLists.txt" "<SOURCE_DIR>/")
endif()
else(WIN32)
else()
set(CRYPTOPP_LIBRARIES
"${CRYPTOPP_INSTALL_DIR}/lib/libcryptopp.a"
CACHE FILEPATH "cryptopp library." FORCE)
endif(WIN32)
endif()

if(APPLE AND WITH_ARM)
set(CMAKE_CXX_FLAGS "-DCRYPTOPP_ARM_CRC32_AVAILABLE=0")
Expand Down
8 changes: 4 additions & 4 deletions cmake/external/gflags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ if(WIN32)
set(GFLAGS_LIBRARIES
"${GFLAGS_INSTALL_DIR}/lib/gflags_static.lib"
CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE)
else(WIN32)
else()
set(GFLAGS_LIBRARIES
"${GFLAGS_INSTALL_DIR}/lib/libgflags.a"
CACHE FILEPATH "GFLAGS_LIBRARIES" FORCE)
set(BUILD_COMMAND $(MAKE) --silent)
set(INSTALL_COMMAND $(MAKE) install)
endif(WIN32)
endif()

include_directories(${GFLAGS_INCLUDE_DIR})

Expand Down Expand Up @@ -101,5 +101,5 @@ if(WIN32)
check_include_file_cxx("shlwapi.h" HAVE_SHLWAPI)
if(HAVE_SHLWAPI)
set_property(GLOBAL PROPERTY OS_DEPENDENCY_MODULES shlwapi.lib)
endif(HAVE_SHLWAPI)
endif(WIN32)
endif()
endif()
4 changes: 2 additions & 2 deletions cmake/external/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if(WIN32)
string(REPLACE "/w " "" GTEST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/W0 " "" GTEST_CMAKE_C_FLAGS "${GTEST_CMAKE_C_FLAGS}")
string(REPLACE "/W0 " "" GTEST_CMAKE_CXX_FLAGS "${GTEST_CMAKE_CXX_FLAGS}")
else(WIN32)
else()
set(GTEST_LIBRARIES
"${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libgtest.a"
CACHE FILEPATH "gtest libraries." FORCE)
Expand All @@ -51,7 +51,7 @@ else(WIN32)
CACHE FILEPATH "gtest main libraries." FORCE)
set(GTEST_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(GTEST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif(WIN32)
endif()

if(WITH_MKLML)
# wait for mklml downloading completed
Expand Down
6 changes: 3 additions & 3 deletions cmake/external/mkldnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ else()
set(MKLDNN_LIB
"${MKLDNN_INSTALL_DIR}/bin/mkldnn.lib"
CACHE FILEPATH "mkldnn library." FORCE)
endif(NOT WIN32)
endif()

ExternalProject_Add(
${MKLDNN_PROJECT}
Expand Down Expand Up @@ -121,7 +121,7 @@ if(WIN32)
DEPENDS ${MKLDNN_PROJECT}
VERBATIM)
add_custom_target(mkldnn_cmd ALL DEPENDS ${MKLDNN_LIB})
else(WIN32)
else()
set(MKLDNN_SHARED_LIB ${MKLDNN_INSTALL_DIR}/libmkldnn.so.0)
set(MKLDNN_SHARED_LIB_1 ${MKLDNN_INSTALL_DIR}/libdnnl.so.1)
set(MKLDNN_SHARED_LIB_2 ${MKLDNN_INSTALL_DIR}/libdnnl.so.2)
Expand All @@ -132,7 +132,7 @@ else(WIN32)
COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_LIB} ${MKLDNN_SHARED_LIB_2}
DEPENDS ${MKLDNN_PROJECT})
add_custom_target(mkldnn_cmd ALL DEPENDS ${MKLDNN_SHARED_LIB_2})
endif(WIN32)
endif()

# generate a static dummy target to track mkldnn dependencies
# for cc_library(xxx SRCS xxx.c DEPS mkldnn)
Expand Down
4 changes: 2 additions & 2 deletions cmake/external/utf8proc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ set(UTF8PROC_TAG v2.6.1)
if(WIN32)
set(UTF8PROC_LIBRARIES "${UTF8PROC_INSTALL_DIR}/lib/utf8proc_static.lib")
add_definitions(-DUTF8PROC_STATIC)
else(WIN32)
else()
set(UTF8PROC_LIBRARIES "${UTF8PROC_INSTALL_DIR}/lib/libutf8proc.a")
endif(WIN32)
endif()

include_directories(${UTF8PROC_INSTALL_DIR}/include)

Expand Down
4 changes: 2 additions & 2 deletions cmake/external/warpctc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ if(WIN32)
set(WARPCTC_LIBRARIES
"${WARPCTC_INSTALL_DIR}/bin/warpctc${CMAKE_SHARED_LIBRARY_SUFFIX}"
CACHE FILEPATH "Warp-ctc Library" FORCE)
else(WIN32)
else()
set(WARPCTC_LIBRARIES
"${WARPCTC_INSTALL_DIR}/lib/libwarpctc${CMAKE_SHARED_LIBRARY_SUFFIX}"
CACHE FILEPATH "Warp-ctc Library" FORCE)
endif(WIN32)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
Expand Down
4 changes: 2 additions & 2 deletions cmake/external/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ if(WIN32)
set(ZLIB_LIBRARIES
"${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib"
CACHE FILEPATH "zlib library." FORCE)
else(WIN32)
else()
set(ZLIB_LIBRARIES
"${ZLIB_INSTALL_DIR}/lib/libz.a"
CACHE FILEPATH "zlib library." FORCE)
endif(WIN32)
endif()

ExternalProject_Add(
extern_zlib
Expand Down
12 changes: 8 additions & 4 deletions cmake/generic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ endfunction()
function(check_coverage_opt TARGET_NAME SRCS)
if(WITH_COVERAGE AND WITH_INCREMENTAL_COVERAGE)
# if pybind.cc add '-g -O0 -fprofile-arcs -ftest-coverage' only, some testcase will fail.
if((NOT ("$ENV{PADDLE_GIT_DIFF_CC_FILE}" MATCHES "pybind.cc"))
AND "$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL "")
if("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL ""
AND (NOT ("$ENV{PADDLE_GIT_DIFF_CC_FILE}" MATCHES "pybind.cc")))
if(NOT ("$ENV{PADDLE_GIT_DIFF_CC_FILE}" STREQUAL ""))
string(REPLACE "," ";" CC_FILE_LIST $ENV{PADDLE_GIT_DIFF_CC_FILE})
set(use_coverage_opt FALSE)
Expand Down Expand Up @@ -779,8 +779,12 @@ function(hip_test TARGET_NAME)
FLAGS_init_allocated_mem=true)
set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT
FLAGS_cudnn_deterministic=true)
set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=\
${CMAKE_BINARY_DIR}/python/paddle/libs:$LD_LIBRARY_PATH")
set_property(
TEST ${TARGET_NAME}
PROPERTY
ENVIRONMENT
"LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/python/paddle/libs:$LD_LIBRARY_PATH"
)
endif()
endfunction()

Expand Down
14 changes: 7 additions & 7 deletions cmake/system.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
if(UNIX AND NOT APPLE)
# except apple from nix*Os family
set(LINUX TRUE)
endif(UNIX AND NOT APPLE)
endif()

if(WIN32)
set(HOST_SYSTEM "win32")
else(WIN32)
else()
if(APPLE)
set(HOST_SYSTEM "macosx")
exec_program(
Expand All @@ -45,7 +45,7 @@ else(WIN32)
)
endif()
set(CMAKE_EXE_LINKER_FLAGS "-framework CoreFoundation -framework Security")
else(APPLE)
else()

if(EXISTS "/etc/issue")
file(READ "/etc/issue" LINUX_ISSUE)
Expand All @@ -63,21 +63,21 @@ else(WIN32)

string(REGEX MATCH "(([0-9]+)\\.)+([0-9]+)" HOST_SYSTEM_VERSION
"${LINUX_ISSUE}")
endif(EXISTS "/etc/issue")
endif()

if(EXISTS "/etc/redhat-release")
file(READ "/etc/redhat-release" LINUX_ISSUE)
if(LINUX_ISSUE MATCHES "CentOS")
set(HOST_SYSTEM "centos")
endif()
endif(EXISTS "/etc/redhat-release")
endif()

if(NOT HOST_SYSTEM)
set(HOST_SYSTEM ${CMAKE_SYSTEM_NAME})
endif()

endif(APPLE)
endif(WIN32)
endif()
endif()

# query number of logical cores
cmake_host_system_information(RESULT CPU_CORES QUERY NUMBER_OF_LOGICAL_CORES)
Expand Down
Loading