diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e70eaceaf4176..5746ec3b6e254 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,9 +40,11 @@ repos: - id: cmake-format name: CMake Format language: python - entry: bash -c "pip install cmake-format && python run-cmake-format.py --check" - entry: echo - files: ^(.*/CMakeLists.txt|.*.cmake)$ + entry: python run-cmake-format.py + types: [cmake] + pass_filenames: false + additional_dependencies: + - cmake_format==0.5.2 - id: hadolint name: Docker Format language: docker_image diff --git a/cpp/cmake_modules/FindBoostAlt.cmake b/cpp/cmake_modules/FindBoostAlt.cmake index 300080d4fb1b0..f35278bf4bac0 100644 --- a/cpp/cmake_modules/FindBoostAlt.cmake +++ b/cpp/cmake_modules/FindBoostAlt.cmake @@ -38,16 +38,14 @@ if(ARROW_BOOST_USE_SHARED) set(BUILD_SHARED_LIBS_KEEP ${BUILD_SHARED_LIBS}) set(BUILD_SHARED_LIBS ON) - find_package(Boost ${BoostAlt_FIND_VERSION_OPTIONS} - COMPONENTS regex system filesystem) + find_package(Boost ${BoostAlt_FIND_VERSION_OPTIONS} COMPONENTS regex system filesystem) set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_KEEP}) unset(BUILD_SHARED_LIBS_KEEP) else() # Find static boost headers and libs # TODO Differentiate here between release and debug builds set(Boost_USE_STATIC_LIBS ON) - find_package(Boost ${BoostAlt_FIND_VERSION_OPTIONS} - COMPONENTS regex system filesystem) + find_package(Boost ${BoostAlt_FIND_VERSION_OPTIONS} COMPONENTS regex system filesystem) endif() if(Boost_FOUND) diff --git a/cpp/cmake_modules/FindNumPy.cmake b/cpp/cmake_modules/FindNumPy.cmake index c3daba149fd04..99c6312122426 100644 --- a/cpp/cmake_modules/FindNumPy.cmake +++ b/cpp/cmake_modules/FindNumPy.cmake @@ -42,24 +42,23 @@ # FindPython3Alt.cmake. if(NOT PYTHONINTERP_FOUND) - set(NUMPY_FOUND FALSE) - return() + set(NUMPY_FOUND FALSE) + return() endif() execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import numpy as n; print(n.__version__); print(n.get_include());" - RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS - OUTPUT_VARIABLE _NUMPY_VALUES_OUTPUT - ERROR_VARIABLE _NUMPY_ERROR_VALUE - OUTPUT_STRIP_TRAILING_WHITESPACE) + "import numpy as n; print(n.__version__); print(n.get_include());" + RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS + OUTPUT_VARIABLE _NUMPY_VALUES_OUTPUT + ERROR_VARIABLE _NUMPY_ERROR_VALUE + OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) - if(NumPy_FIND_REQUIRED) - message(FATAL_ERROR - "NumPy import failure:\n${_NUMPY_ERROR_VALUE}") - endif() - set(NUMPY_FOUND FALSE) - return() + if(NumPy_FIND_REQUIRED) + message(FATAL_ERROR "NumPy import failure:\n${_NUMPY_ERROR_VALUE}") + endif() + set(NUMPY_FOUND FALSE) + return() endif() # Convert the process output into a list @@ -70,11 +69,13 @@ list(GET _NUMPY_VALUES 1 NUMPY_INCLUDE_DIRS) string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" _VER_CHECK "${NUMPY_VERSION}") if("${_VER_CHECK}" STREQUAL "") - # The output from Python was unexpected. Raise an error always - # here, because we found NumPy, but it appears to be corrupted somehow. - message(FATAL_ERROR - "Requested version and include path from NumPy, got instead:\n${_NUMPY_VALUES_OUTPUT}\n") - return() + # The output from Python was unexpected. Raise an error always + # here, because we found NumPy, but it appears to be corrupted somehow. + message( + FATAL_ERROR + "Requested version and include path from NumPy, got instead:\n${_NUMPY_VALUES_OUTPUT}\n" + ) + return() endif() # Make sure all directory separators are '/' @@ -86,11 +87,13 @@ list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR) list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR) list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH) string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH}) -math(EXPR NUMPY_VERSION_DECIMAL - "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}") +math( + EXPR NUMPY_VERSION_DECIMAL + "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}" + ) find_package_message(NUMPY - "Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}" - "${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") + "Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}" + "${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") set(NUMPY_FOUND TRUE) diff --git a/cpp/cmake_modules/FindORC.cmake b/cpp/cmake_modules/FindORC.cmake index 1be149c93b2a4..061a0df2e9e2c 100644 --- a/cpp/cmake_modules/FindORC.cmake +++ b/cpp/cmake_modules/FindORC.cmake @@ -44,10 +44,9 @@ if(ORC_STATIC_LIB AND ORC_INCLUDE_DIR) add_library(orc::liborc STATIC IMPORTED) set_target_properties(orc::liborc PROPERTIES IMPORTED_LOCATION "${ORC_STATIC_LIB}" - INTERFACE_INCLUDE_DIRECTORIES - "${ORC_INCLUDE_DIR}") + INTERFACE_INCLUDE_DIRECTORIES "${ORC_INCLUDE_DIR}") else() - if (ORC_FIND_REQUIRED) + if(ORC_FIND_REQUIRED) message(FATAL_ERROR "ORC library was required in toolchain and unable to locate") endif() set(ORC_FOUND FALSE) diff --git a/cpp/cmake_modules/FindPythonLibsNew.cmake b/cpp/cmake_modules/FindPythonLibsNew.cmake index 581bba9d4caaa..686954313731c 100644 --- a/cpp/cmake_modules/FindPythonLibsNew.cmake +++ b/cpp/cmake_modules/FindPythonLibsNew.cmake @@ -62,14 +62,14 @@ # Use the Python interpreter to find the libs. if(PythonLibsNew_FIND_REQUIRED) - find_package(PythonInterp REQUIRED) + find_package(PythonInterp REQUIRED) else() - find_package(PythonInterp) + find_package(PythonInterp) endif() if(NOT PYTHONINTERP_FOUND) - set(PYTHONLIBS_FOUND FALSE) - return() + set(PYTHONLIBS_FOUND FALSE) + return() endif() # According to http://stackoverflow.com/questions/646518/python-how-to-detect-debug-interpreter @@ -82,7 +82,7 @@ endif() # The config var LIBPL is for Linux, and helps on Debian Jessie where the # addition of multi-arch support shuffled things around. execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" - "from distutils import sysconfig as s;import sys;import struct; + "from distutils import sysconfig as s;import sys;import struct; print('.'.join(str(v) for v in sys.version_info)); print(sys.prefix); print(s.get_python_inc(plat_specific=True)); @@ -94,17 +94,16 @@ print(s.get_config_var('LDVERSION') or s.get_config_var('VERSION')); print(s.get_config_var('LIBPL')); print(s.get_config_var('LIBS') or ''); " - RESULT_VARIABLE _PYTHON_SUCCESS - OUTPUT_VARIABLE _PYTHON_VALUES - ERROR_VARIABLE _PYTHON_ERROR_VALUE) + RESULT_VARIABLE _PYTHON_SUCCESS + OUTPUT_VARIABLE _PYTHON_VALUES + ERROR_VARIABLE _PYTHON_ERROR_VALUE) if(NOT _PYTHON_SUCCESS MATCHES 0) - if(PythonLibsNew_FIND_REQUIRED) - message(FATAL_ERROR - "Python config failure:\n${_PYTHON_ERROR_VALUE}") - endif() - set(PYTHONLIBS_FOUND FALSE) - return() + if(PythonLibsNew_FIND_REQUIRED) + message(FATAL_ERROR "Python config failure:\n${_PYTHON_ERROR_VALUE}") + endif() + set(PYTHONLIBS_FOUND FALSE) + return() endif() # Convert the process output into a list @@ -124,15 +123,14 @@ list(GET _PYTHON_VALUES 9 PYTHON_OTHER_LIBS) # Make sure the Python has the same pointer-size as the chosen compiler # Skip the check on OS X, it doesn't consistently have CMAKE_SIZEOF_VOID_P defined if((NOT APPLE) AND (NOT "${PYTHON_SIZEOF_VOID_P}" STREQUAL "${CMAKE_SIZEOF_VOID_P}")) - if(PythonLibsNew_FIND_REQUIRED) - math(EXPR _PYTHON_BITS "${PYTHON_SIZEOF_VOID_P} * 8") - math(EXPR _CMAKE_BITS "${CMAKE_SIZEOF_VOID_P} * 8") - message(FATAL_ERROR - "Python config failure: Python is ${_PYTHON_BITS}-bit, " - "chosen compiler is ${_CMAKE_BITS}-bit") - endif() - set(PYTHONLIBS_FOUND FALSE) - return() + if(PythonLibsNew_FIND_REQUIRED) + math(EXPR _PYTHON_BITS "${PYTHON_SIZEOF_VOID_P} * 8") + math(EXPR _CMAKE_BITS "${CMAKE_SIZEOF_VOID_P} * 8") + message(FATAL_ERROR "Python config failure: Python is ${_PYTHON_BITS}-bit, " + "chosen compiler is ${_CMAKE_BITS}-bit") + endif() + set(PYTHONLIBS_FOUND FALSE) + return() endif() # The built-in FindPython didn't always give the version numbers @@ -149,119 +147,111 @@ string(REGEX REPLACE "\\\\" "/" PYTHON_SITE_PACKAGES ${PYTHON_SITE_PACKAGES}) if(CMAKE_HOST_WIN32) # Appease CMP0054 if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(PYTHON_LIBRARY - "${PYTHON_PREFIX}/libs/Python${PYTHON_LIBRARY_SUFFIX}.lib") + set(PYTHON_LIBRARY "${PYTHON_PREFIX}/libs/Python${PYTHON_LIBRARY_SUFFIX}.lib") else() find_library(PYTHON_LIBRARY - NAMES "python${PYTHON_LIBRARY_SUFFIX}" - PATHS "${PYTHON_PREFIX}" NO_DEFAULT_PATH - PATH_SUFFIXES "lib" "libs") + NAMES "python${PYTHON_LIBRARY_SUFFIX}" + PATHS "${PYTHON_PREFIX}" + NO_DEFAULT_PATH + PATH_SUFFIXES "lib" "libs") endif() elseif(APPLE) set(PYTHON_LIBRARY "${PYTHON_PREFIX}/lib/libpython${PYTHON_LIBRARY_SUFFIX}.dylib") - if (NOT EXISTS ${PYTHON_LIBRARY}) + if(NOT EXISTS ${PYTHON_LIBRARY}) # In some cases libpythonX.X.dylib is not part of the PYTHON_PREFIX and we # need to call `python-config --prefix` to determine the correct location. - find_program(PYTHON_CONFIG python-config - NO_CMAKE_SYSTEM_PATH) - if (PYTHON_CONFIG) - execute_process( - COMMAND "${PYTHON_CONFIG}" "--prefix" - OUTPUT_VARIABLE PYTHON_CONFIG_PREFIX - OUTPUT_STRIP_TRAILING_WHITESPACE) - set(PYTHON_LIBRARY "${PYTHON_CONFIG_PREFIX}/lib/libpython${PYTHON_LIBRARY_SUFFIX}.dylib") + find_program(PYTHON_CONFIG python-config NO_CMAKE_SYSTEM_PATH) + if(PYTHON_CONFIG) + execute_process(COMMAND "${PYTHON_CONFIG}" "--prefix" + OUTPUT_VARIABLE PYTHON_CONFIG_PREFIX + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(PYTHON_LIBRARY + "${PYTHON_CONFIG_PREFIX}/lib/libpython${PYTHON_LIBRARY_SUFFIX}.dylib") endif() endif() else() - if(${PYTHON_SIZEOF_VOID_P} MATCHES 8) - set(_PYTHON_LIBS_SEARCH "${PYTHON_PREFIX}/lib64" "${PYTHON_PREFIX}/lib" "${PYTHON_LIBRARY_PATH}") - else() - set(_PYTHON_LIBS_SEARCH "${PYTHON_PREFIX}/lib" "${PYTHON_LIBRARY_PATH}") - endif() - message(STATUS "Searching for Python libs in ${_PYTHON_LIBS_SEARCH}") - message(STATUS "Looking for python${PYTHON_LIBRARY_SUFFIX}") - # Probably this needs to be more involved. It would be nice if the config - # information the python interpreter itself gave us were more complete. - find_library(PYTHON_LIBRARY - NAMES "python${PYTHON_LIBRARY_SUFFIX}" - PATHS ${_PYTHON_LIBS_SEARCH} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - message(STATUS "Found Python lib ${PYTHON_LIBRARY}") + if(${PYTHON_SIZEOF_VOID_P} MATCHES 8) + set(_PYTHON_LIBS_SEARCH "${PYTHON_PREFIX}/lib64" "${PYTHON_PREFIX}/lib" + "${PYTHON_LIBRARY_PATH}") + else() + set(_PYTHON_LIBS_SEARCH "${PYTHON_PREFIX}/lib" "${PYTHON_LIBRARY_PATH}") + endif() + message(STATUS "Searching for Python libs in ${_PYTHON_LIBS_SEARCH}") + message(STATUS "Looking for python${PYTHON_LIBRARY_SUFFIX}") + # Probably this needs to be more involved. It would be nice if the config + # information the python interpreter itself gave us were more complete. + find_library(PYTHON_LIBRARY + NAMES "python${PYTHON_LIBRARY_SUFFIX}" + PATHS ${_PYTHON_LIBS_SEARCH} + NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + message(STATUS "Found Python lib ${PYTHON_LIBRARY}") endif() # For backward compatibility, set PYTHON_INCLUDE_PATH, but make it internal. -SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL - "Path to where Python.h is found (deprecated)") +set(PYTHON_INCLUDE_PATH + "${PYTHON_INCLUDE_DIR}" + CACHE INTERNAL "Path to where Python.h is found (deprecated)") -MARK_AS_ADVANCED( - PYTHON_LIBRARY - PYTHON_INCLUDE_DIR -) +mark_as_advanced(PYTHON_LIBRARY PYTHON_INCLUDE_DIR) # We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the # cache entries because they are meant to specify the location of a single # library. We now set the variables listed by the documentation for this # module. -SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") -SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") -SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") - +set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") +set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") +set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") # Don't know how to get to this directory, just doing something simple :P #INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) #FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) -find_package_message(PYTHON - "Found PythonLibs: ${PYTHON_LIBRARY}" - "${PYTHON_EXECUTABLE}${PYTHON_VERSION}") - +find_package_message(PYTHON "Found PythonLibs: ${PYTHON_LIBRARY}" + "${PYTHON_EXECUTABLE}${PYTHON_VERSION}") # PYTHON_ADD_MODULE( src1 src2 ... srcN) is used to build modules for python. -FUNCTION(PYTHON_ADD_MODULE _NAME ) - GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS - GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) - OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) - OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED - "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS}) +function(PYTHON_ADD_MODULE _NAME) + get_property(_TARGET_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) + option(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) + option(PYTHON_MODULE_${_NAME}_BUILD_SHARED "Add module ${_NAME} shared" + ${_TARGET_SUPPORTS_SHARED_LIBS}) # Mark these options as advanced - MARK_AS_ADVANCED(PYTHON_ENABLE_MODULE_${_NAME} - PYTHON_MODULE_${_NAME}_BUILD_SHARED) + mark_as_advanced(PYTHON_ENABLE_MODULE_${_NAME} PYTHON_MODULE_${_NAME}_BUILD_SHARED) - IF(PYTHON_ENABLE_MODULE_${_NAME}) - IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - SET(PY_MODULE_TYPE MODULE) - ELSE(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - SET(PY_MODULE_TYPE STATIC) - SET_PROPERTY(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME}) - ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + if(PYTHON_ENABLE_MODULE_${_NAME}) + if(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + set(PY_MODULE_TYPE MODULE) + else(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + set(PY_MODULE_TYPE STATIC) + set_property(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME}) + endif(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - SET_PROPERTY(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME}) - ADD_LIBRARY(${_NAME} ${PY_MODULE_TYPE} ${ARGN}) - IF(APPLE) + set_property(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME}) + add_library(${_NAME} ${PY_MODULE_TYPE} ${ARGN}) + if(APPLE) # On OS X, linking against the Python libraries causes # segfaults, so do this dynamic lookup instead. - SET_TARGET_PROPERTIES(${_NAME} PROPERTIES LINK_FLAGS - "-undefined dynamic_lookup") - ELSEIF(MSVC) + set_target_properties(${_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") + elseif(MSVC) target_link_libraries(${_NAME} ${PYTHON_LIBRARIES}) - ELSE() + else() # In general, we should not link against libpython as we do not embed the # Python interpreter. The python binary itself can then define where the # symbols should loaded from. For being manylinux1 compliant, one is not # allowed to link to libpython. Partly because not all systems ship it, # also because the interpreter ABI/API was not stable between patch # releases for Python < 3.5. - SET_TARGET_PROPERTIES(${_NAME} PROPERTIES LINK_FLAGS - "-Wl,-undefined,dynamic_lookup") - ENDIF() - IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) - SET_TARGET_PROPERTIES(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}") - SET_TARGET_PROPERTIES(${_NAME} PROPERTIES SUFFIX "${PYTHON_MODULE_EXTENSION}") - ELSE() - ENDIF() + set_target_properties(${_NAME} + PROPERTIES LINK_FLAGS "-Wl,-undefined,dynamic_lookup") + endif() + if(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + set_target_properties(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}") + set_target_properties(${_NAME} PROPERTIES SUFFIX "${PYTHON_MODULE_EXTENSION}") + else() + + endif() - ENDIF(PYTHON_ENABLE_MODULE_${_NAME}) -ENDFUNCTION(PYTHON_ADD_MODULE) + endif(PYTHON_ENABLE_MODULE_${_NAME}) +endfunction(PYTHON_ADD_MODULE) diff --git a/cpp/cmake_modules/FindSnappy.cmake b/cpp/cmake_modules/FindSnappy.cmake index 5784cf592200b..26cccb786c531 100644 --- a/cpp/cmake_modules/FindSnappy.cmake +++ b/cpp/cmake_modules/FindSnappy.cmake @@ -26,9 +26,13 @@ if(ARROW_SNAPPY_USE_SHARED) else() set(SNAPPY_STATIC_LIB_NAME_BASE "snappy") if(MSVC) - set(SNAPPY_STATIC_LIB_NAME_BASE "${SNAPPY_STATIC_LIB_NAME_BASE}${SNAPPY_MSVC_STATIC_LIB_SUFFIX}") + set(SNAPPY_STATIC_LIB_NAME_BASE + "${SNAPPY_STATIC_LIB_NAME_BASE}${SNAPPY_MSVC_STATIC_LIB_SUFFIX}") endif() - set(SNAPPY_LIB_NAMES "${CMAKE_STATIC_LIBRARY_PREFIX}${SNAPPY_STATIC_LIB_NAME_BASE}${CMAKE_STATIC_LIBRARY_SUFFIX}") + set( + SNAPPY_LIB_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}${SNAPPY_STATIC_LIB_NAME_BASE}${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) endif() if(Snappy_ROOT) @@ -44,7 +48,9 @@ if(Snappy_ROOT) PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) else() find_library(Snappy_LIB NAMES ${SNAPPY_LIB_NAMES}) - find_path(Snappy_INCLUDE_DIR NAMES snappy.h PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) + find_path(Snappy_INCLUDE_DIR + NAMES snappy.h + PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) endif() find_package_handle_standard_args(Snappy REQUIRED_VARS Snappy_LIB Snappy_INCLUDE_DIR) diff --git a/cpp/cmake_modules/Findutf8proc.cmake b/cpp/cmake_modules/Findutf8proc.cmake index 560321df5db40..edea73b8daecb 100644 --- a/cpp/cmake_modules/Findutf8proc.cmake +++ b/cpp/cmake_modules/Findutf8proc.cmake @@ -29,37 +29,40 @@ else() endif() set(utf8proc_STATIC_LIB_SUFFIX "${utf8proc_MSVC_STATIC_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - set(utf8proc_LIB_NAMES "${CMAKE_STATIC_LIBRARY_PREFIX}utf8proc${utf8proc_STATIC_LIB_SUFFIX}") + set(utf8proc_LIB_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}utf8proc${utf8proc_STATIC_LIB_SUFFIX}") endif() if(utf8proc_ROOT) - find_library( - utf8proc_LIB - NAMES ${utf8proc_LIB_NAMES} - PATHS ${utf8proc_ROOT} - PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES} - NO_DEFAULT_PATH) + find_library(utf8proc_LIB + NAMES ${utf8proc_LIB_NAMES} + PATHS ${utf8proc_ROOT} + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES} + NO_DEFAULT_PATH) find_path(utf8proc_INCLUDE_DIR NAMES utf8proc.h PATHS ${utf8proc_ROOT} NO_DEFAULT_PATH PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) else() - find_library( - utf8proc_LIB - NAMES ${utf8proc_LIB_NAMES} - PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES}) - find_path(utf8proc_INCLUDE_DIR NAMES utf8proc.h PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) + find_library(utf8proc_LIB + NAMES ${utf8proc_LIB_NAMES} + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES}) + find_path(utf8proc_INCLUDE_DIR + NAMES utf8proc.h + PATH_SUFFIXES ${ARROW_INCLUDE_PATH_SUFFIXES}) endif() -find_package_handle_standard_args(utf8proc REQUIRED_VARS utf8proc_LIB utf8proc_INCLUDE_DIR) +find_package_handle_standard_args(utf8proc REQUIRED_VARS utf8proc_LIB + utf8proc_INCLUDE_DIR) if(utf8proc_FOUND) set(utf8proc_FOUND TRUE) add_library(utf8proc::utf8proc UNKNOWN IMPORTED) - set_target_properties(utf8proc::utf8proc - PROPERTIES IMPORTED_LOCATION "${utf8proc_LIB}" - INTERFACE_INCLUDE_DIRECTORIES "${utf8proc_INCLUDE_DIR}") + set_target_properties( + utf8proc::utf8proc + PROPERTIES IMPORTED_LOCATION "${utf8proc_LIB}" INTERFACE_INCLUDE_DIRECTORIES + "${utf8proc_INCLUDE_DIR}") if(NOT ARROW_UTF8PROC_USE_SHARED) set_target_properties(utf8proc::utf8proc PROPERTIES INTERFACE_COMPILER_DEFINITIONS "UTF8PROC_STATIC") diff --git a/cpp/examples/arrow/CMakeLists.txt b/cpp/examples/arrow/CMakeLists.txt index 00eff7ae03b91..b014745b1982c 100644 --- a/cpp/examples/arrow/CMakeLists.txt +++ b/cpp/examples/arrow/CMakeLists.txt @@ -15,17 +15,16 @@ # specific language governing permissions and limitations # under the License. -ADD_ARROW_EXAMPLE(row-wise-conversion-example) +add_arrow_example(row-wise-conversion-example) -if (ARROW_PARQUET AND ARROW_DATASET) - if (ARROW_BUILD_SHARED) +if(ARROW_PARQUET AND ARROW_DATASET) + if(ARROW_BUILD_SHARED) set(DATASET_EXAMPLES_LINK_LIBS arrow_dataset_shared) else() set(DATASET_EXAMPLES_LINK_LIBS arrow_dataset_static) endif() - ADD_ARROW_EXAMPLE(dataset-parquet-scan-example - EXTRA_LINK_LIBS - ${DATASET_EXAMPLES_LINK_LIBS}) + add_arrow_example(dataset-parquet-scan-example EXTRA_LINK_LIBS + ${DATASET_EXAMPLES_LINK_LIBS}) add_dependencies(dataset-parquet-scan-example parquet) endif() diff --git a/cpp/examples/minimal_build/CMakeLists.txt b/cpp/examples/minimal_build/CMakeLists.txt index 9fc20c70fe0d2..d3eea7ba0f08c 100644 --- a/cpp/examples/minimal_build/CMakeLists.txt +++ b/cpp/examples/minimal_build/CMakeLists.txt @@ -31,7 +31,7 @@ message(STATUS "Arrow SO version: ${ARROW_FULL_SO_VERSION}") add_executable(arrow_example example.cc) -if (ARROW_LINK_SHARED) +if(ARROW_LINK_SHARED) target_link_libraries(arrow_example PRIVATE arrow_shared) else() set(THREADS_PREFER_PTHREAD_FLAG ON) diff --git a/cpp/examples/parquet/CMakeLists.txt b/cpp/examples/parquet/CMakeLists.txt index cc8f5a98150b5..14c15621b7dd2 100644 --- a/cpp/examples/parquet/CMakeLists.txt +++ b/cpp/examples/parquet/CMakeLists.txt @@ -23,33 +23,33 @@ target_include_directories(parquet-low-level-example PRIVATE low-level-api/) target_include_directories(parquet-low-level-example2 PRIVATE low-level-api/) # The variables in these files are for illustration purposes -set(PARQUET_EXAMPLES_WARNING_SUPPRESSIONS - low-level-api/reader-writer.cc - low-level-api/reader-writer2.cc) +set(PARQUET_EXAMPLES_WARNING_SUPPRESSIONS low-level-api/reader-writer.cc + low-level-api/reader-writer2.cc) -if (PARQUET_REQUIRE_ENCRYPTION) +if(PARQUET_REQUIRE_ENCRYPTION) add_executable(parquet-encryption-example low-level-api/encryption-reader-writer.cc) - add_executable(parquet-encryption-example-all-crypto-options low-level-api/encryption-reader-writer-all-crypto-options.cc) + add_executable(parquet-encryption-example-all-crypto-options + low-level-api/encryption-reader-writer-all-crypto-options.cc) target_include_directories(parquet-encryption-example PRIVATE low-level-api/) - target_include_directories(parquet-encryption-example-all-crypto-options PRIVATE low-level-api/) + target_include_directories(parquet-encryption-example-all-crypto-options + PRIVATE low-level-api/) set(PARQUET_EXAMPLES_WARNING_SUPPRESSIONS - ${PARQUET_EXAMPLES_WARNING_SUPPRESSIONS} - low-level-api/encryption-reader-writer.cc - low-level-api/encryption-reader-writer-all-crypto-options.cc) + ${PARQUET_EXAMPLES_WARNING_SUPPRESSIONS} low-level-api/encryption-reader-writer.cc + low-level-api/encryption-reader-writer-all-crypto-options.cc) endif() if(UNIX) foreach(FILE ${PARQUET_EXAMPLES_WARNING_SUPPRESSIONS}) set_property(SOURCE ${FILE} - APPEND_STRING - PROPERTY COMPILE_FLAGS "-Wno-unused-variable") + APPEND_STRING + PROPERTY COMPILE_FLAGS "-Wno-unused-variable") endforeach() endif() # Prefer shared linkage but use static if shared build is deactivated -if (ARROW_BUILD_SHARED) +if(ARROW_BUILD_SHARED) set(PARQUET_EXAMPLE_LINK_LIBS parquet_shared) else() set(PARQUET_EXAMPLE_LINK_LIBS parquet_static) @@ -62,17 +62,17 @@ target_link_libraries(parquet-stream-api-example ${PARQUET_EXAMPLE_LINK_LIBS}) if(PARQUET_REQUIRE_ENCRYPTION) target_link_libraries(parquet-encryption-example ${PARQUET_EXAMPLE_LINK_LIBS}) - target_link_libraries(parquet-encryption-example-all-crypto-options ${PARQUET_EXAMPLE_LINK_LIBS}) + target_link_libraries(parquet-encryption-example-all-crypto-options + ${PARQUET_EXAMPLE_LINK_LIBS}) endif() add_dependencies(parquet - parquet-low-level-example - parquet-low-level-example2 - parquet-arrow-example - parquet-stream-api-example) + parquet-low-level-example + parquet-low-level-example2 + parquet-arrow-example + parquet-stream-api-example) -if (PARQUET_REQUIRE_ENCRYPTION) - add_dependencies(parquet - parquet-encryption-example - parquet-encryption-example-all-crypto-options) +if(PARQUET_REQUIRE_ENCRYPTION) + add_dependencies(parquet parquet-encryption-example + parquet-encryption-example-all-crypto-options) endif() diff --git a/go/arrow/math/_lib/CMakeLists.txt b/go/arrow/math/_lib/CMakeLists.txt index ec1558b25fbed..050bd40804fc0 100644 --- a/go/arrow/math/_lib/CMakeLists.txt +++ b/go/arrow/math/_lib/CMakeLists.txt @@ -20,5 +20,3 @@ project(math-func) set(CMAKE_C_STANDARD 99) add_library(memory STATIC float64.c int64.c uint64.c) - - diff --git a/go/arrow/memory/_lib/CMakeLists.txt b/go/arrow/memory/_lib/CMakeLists.txt index f6815302de1a3..6126acd7c67f0 100644 --- a/go/arrow/memory/_lib/CMakeLists.txt +++ b/go/arrow/memory/_lib/CMakeLists.txt @@ -20,5 +20,3 @@ project(memory-func) set(CMAKE_C_STANDARD 99) add_library(memory STATIC memory.c) - - diff --git a/java/adapter/orc/CMakeLists.txt b/java/adapter/orc/CMakeLists.txt index c6facacf4656b..e2d4655d79e75 100644 --- a/java/adapter/orc/CMakeLists.txt +++ b/java/adapter/orc/CMakeLists.txt @@ -30,14 +30,14 @@ include(FindJNI) message("generating headers to ${JNI_HEADERS_DIR}") -add_jar( - arrow_orc_java +add_jar(arrow_orc_java src/main/java/org/apache/arrow/adapter/orc/OrcReaderJniWrapper.java src/main/java/org/apache/arrow/adapter/orc/OrcStripeReaderJniWrapper.java src/main/java/org/apache/arrow/adapter/orc/OrcMemoryJniWrapper.java src/main/java/org/apache/arrow/adapter/orc/OrcJniUtils.java src/main/java/org/apache/arrow/adapter/orc/OrcRecordBatch.java src/main/java/org/apache/arrow/adapter/orc/OrcFieldNode.java - GENERATE_NATIVE_HEADERS arrow_orc_java-native - DESTINATION ${JNI_HEADERS_DIR} -) + GENERATE_NATIVE_HEADERS + arrow_orc_java-native + DESTINATION + ${JNI_HEADERS_DIR}) diff --git a/matlab/CMakeLists.txt b/matlab/CMakeLists.txt old mode 100755 new mode 100644 index 993497006e130..110022f82d3af --- a/matlab/CMakeLists.txt +++ b/matlab/CMakeLists.txt @@ -19,8 +19,7 @@ cmake_minimum_required(VERSION 3.2) set(CMAKE_CXX_STANDARD 11) set(MLARROW_VERSION "3.0.0-SNAPSHOT") -string(REGEX MATCH - "^[0-9]+\\.[0-9]+\\.[0-9]+" MLARROW_BASE_VERSION "${MLARROW_VERSION}") +string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" MLARROW_BASE_VERSION "${MLARROW_VERSION}") project(mlarrow VERSION "${MLARROW_BASE_VERSION}") @@ -33,23 +32,29 @@ endif() ## Arrow is Required find_package(Arrow REQUIRED) -## MATLAB is required to be installed to build MEX interfaces +## MATLAB is required to be installed to build MEX interfaces set(MATLAB_ADDITIONAL_VERSIONS "R2018a=9.4") find_package(Matlab REQUIRED MX_LIBRARY) # Build featherread mex file based on the arrow shared library -matlab_add_mex(NAME featherreadmex - SRC src/featherreadmex.cc - src/feather_reader.cc - src/util/handle_status.cc - src/util/unicode_conversion.cc - LINK_TO ${ARROW_SHARED_LIB}) +matlab_add_mex(NAME + featherreadmex + SRC + src/featherreadmex.cc + src/feather_reader.cc + src/util/handle_status.cc + src/util/unicode_conversion.cc + LINK_TO + ${ARROW_SHARED_LIB}) target_include_directories(featherreadmex PRIVATE ${ARROW_INCLUDE_DIR}) # Build featherwrite mex file based on the arrow shared library -matlab_add_mex(NAME featherwritemex - SRC src/featherwritemex.cc - src/feather_writer.cc - src/util/handle_status.cc - LINK_TO ${ARROW_SHARED_LIB}) +matlab_add_mex(NAME + featherwritemex + SRC + src/featherwritemex.cc + src/feather_writer.cc + src/util/handle_status.cc + LINK_TO + ${ARROW_SHARED_LIB}) target_include_directories(featherwritemex PRIVATE ${ARROW_INCLUDE_DIR}) diff --git a/run-cmake-format.py b/run-cmake-format.py index 415b9bc19decb..80ee8ec5db674 100755 --- a/run-cmake-format.py +++ b/run-cmake-format.py @@ -22,57 +22,21 @@ import subprocess import sys - -patterns = [ - 'cpp/CMakeLists.txt', - # Keep an explicit list of files to format as we don't want to reformat - # files we imported from other location. - 'cpp/cmake_modules/BuildUtils.cmake', - 'cpp/cmake_modules/DefineOptions.cmake', - 'cpp/cmake_modules/FindArrow.cmake', - 'cpp/cmake_modules/FindArrowCUDA.cmake', - 'cpp/cmake_modules/FindArrowDataset.cmake', - 'cpp/cmake_modules/FindArrowFlight.cmake', - 'cpp/cmake_modules/FindArrowFlightTesting.cmake', - 'cpp/cmake_modules/FindArrowPython.cmake', - 'cpp/cmake_modules/FindArrowPythonFlight.cmake', - 'cpp/cmake_modules/FindArrowTesting.cmake', - 'cpp/cmake_modules/FindBrotli.cmake', - 'cpp/cmake_modules/FindClangTools.cmake', - 'cpp/cmake_modules/FindFlatbuffersAlt.cmake', - 'cpp/cmake_modules/FindGLOG.cmake', - 'cpp/cmake_modules/FindGandiva.cmake', - 'cpp/cmake_modules/FindInferTools.cmake', - 'cpp/cmake_modules/FindLLVMAlt.cmake', - 'cpp/cmake_modules/FindLz4.cmake', - 'cpp/cmake_modules/FindParquet.cmake', - 'cpp/cmake_modules/FindPlasma.cmake', - 'cpp/cmake_modules/FindPython3Alt.cmake', - 'cpp/cmake_modules/FindRE2.cmake', - 'cpp/cmake_modules/FindRapidJSONAlt.cmake', - 'cpp/cmake_modules/FindSnappyAlt.cmake', - 'cpp/cmake_modules/FindThrift.cmake', - 'cpp/cmake_modules/FindZSTD.cmake', - 'cpp/cmake_modules/Findc-aresAlt.cmake', - 'cpp/cmake_modules/FindgRPCAlt.cmake', - 'cpp/cmake_modules/FindgflagsAlt.cmake', - 'cpp/cmake_modules/Findjemalloc.cmake', - 'cpp/cmake_modules/SetupCxxFlags.cmake', - 'cpp/cmake_modules/ThirdpartyToolchain.cmake', - 'cpp/cmake_modules/san-config.cmake', +# Keep an explicit list of files to format as we don't want to reformat +# files we imported from other location. +PATTERNS = ['cpp/cmake_modules/*.cmake', '*CMakeLists.txt'] +EXCLUDE = [ + 'cpp/cmake_modules/FindNumPy.cmake', + 'cpp/cmake_modules/FindPythonLibsNew.cmake', 'cpp/cmake_modules/UseCython.cmake', - 'cpp/src/**/CMakeLists.txt', - 'cpp/tools/**/CMakeLists.txt', - 'java/gandiva/CMakeLists.txt', - 'python/CMakeLists.txt', ] here = pathlib.Path(__file__).parent def find_cmake_files(): - for pat in patterns: - yield from here.glob(pat) + for pat in PATTERNS: + yield from here.rglob(pat) def run_cmake_format(paths): @@ -118,7 +82,8 @@ def check_cmake_format(paths): if __name__ == "__main__": - paths = list(find_cmake_files()) + paths = find_cmake_files() + paths = [i for i in paths if i not in EXCLUDE] if "--check" in sys.argv: check_cmake_format(paths) else: