diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 721ed22811f..8f2c897cb5e 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -148,6 +148,13 @@ if(APPLE) endif() endif() +if(WIN32 AND NOT MINGW) + # This is used to handle builds using e.g. clang in an MSVC setting. + set(MSVC_TOOLCHAIN TRUE) +else() + set(MSVC_TOOLCHAIN FALSE) +endif() + find_package(ClangTools) find_package(InferTools) if("$ENV{CMAKE_EXPORT_COMPILE_COMMANDS}" STREQUAL "1" OR CLANG_TIDY_FOUND OR INFER_FOUND) @@ -343,7 +350,7 @@ if(ARROW_PYTHON) set(ARROW_JSON ON) endif() -if(MSVC) +if(MSVC_TOOLCHAIN) # ORC doesn't build on windows set(ARROW_ORC OFF) # Plasma using glog is not fully tested on windows. @@ -741,7 +748,7 @@ add_dependencies(arrow_test_dependencies toolchain-tests) if(ARROW_STATIC_LINK_LIBS) add_dependencies(arrow_dependencies ${ARROW_STATIC_LINK_LIBS}) if(ARROW_ORC) - if(NOT MSVC) + if(NOT MSVC_TOOLCHAIN) list(APPEND ARROW_STATIC_LINK_LIBS ${CMAKE_DL_LIBS}) list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS}) endif() @@ -755,7 +762,7 @@ if(((ARROW_FLIGHT OR ARROW_S3) AND (ARROW_BUILD_TESTS OR ARROW_BUILD_INTEGRATION list(APPEND ARROW_TEST_LINK_LIBS ${BOOST_FILESYSTEM_LIBRARY} ${BOOST_SYSTEM_LIBRARY}) endif() -if(NOT MSVC) +if(NOT MSVC_TOOLCHAIN) list(APPEND ARROW_LINK_LIBS ${CMAKE_DL_LIBS}) list(APPEND ARROW_SHARED_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS}) endif() diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 58856c8f2f6..e59b4a38af0 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -440,7 +440,7 @@ function(ADD_ARROW_LIB LIB_NAME) target_include_directories(${LIB_NAME}_static PRIVATE ${ARG_PRIVATE_INCLUDES}) endif() - if(MSVC) + if(MSVC_TOOLCHAIN) set(LIB_NAME_STATIC ${LIB_NAME}_static) else() set(LIB_NAME_STATIC ${LIB_NAME}) diff --git a/cpp/cmake_modules/DefineOptions.cmake b/cpp/cmake_modules/DefineOptions.cmake index 92ee17ba2ff..64ec7fa28bd 100644 --- a/cpp/cmake_modules/DefineOptions.cmake +++ b/cpp/cmake_modules/DefineOptions.cmake @@ -360,7 +360,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") "Build with support for Unicode properties using the utf8proc library" ON) #---------------------------------------------------------------------- - if(MSVC) + if(MSVC_TOOLCHAIN) set_option_category("MSVC") define_option(MSVC_LINK_VERBOSE diff --git a/cpp/cmake_modules/FindArrow.cmake b/cpp/cmake_modules/FindArrow.cmake index 02fd9a15801..9c987665896 100644 --- a/cpp/cmake_modules/FindArrow.cmake +++ b/cpp/cmake_modules/FindArrow.cmake @@ -39,6 +39,13 @@ endif() include(FindPkgConfig) include(FindPackageHandleStandardArgs) +if(WIN32 AND NOT MINGW) + # This is used to handle builds using e.g. clang in an MSVC setting. + set(MSVC_TOOLCHAIN TRUE) +else() + set(MSVC_TOOLCHAIN FALSE) +endif() + set(ARROW_SEARCH_LIB_PATH_SUFFIXES) if(CMAKE_LIBRARY_ARCHITECTURE) list(APPEND ARROW_SEARCH_LIB_PATH_SUFFIXES "lib/${CMAKE_LIBRARY_ARCHITECTURE}") @@ -61,7 +68,7 @@ if(CMAKE_BUILD_TYPE) endif() if(NOT DEFINED ARROW_MSVC_STATIC_LIB_SUFFIX) - if(MSVC) + if(MSVC_TOOLCHAIN) set(ARROW_MSVC_STATIC_LIB_SUFFIX "_static") else() set(ARROW_MSVC_STATIC_LIB_SUFFIX "") @@ -147,7 +154,7 @@ macro(arrow_find_package_home) set(include_dir "${${prefix}_include_dir}") set(${prefix}_INCLUDE_DIR "${include_dir}" PARENT_SCOPE) - if(MSVC) + if(MSVC_TOOLCHAIN) set(CMAKE_SHARED_LIBRARY_SUFFIXES_ORIGINAL ${CMAKE_FIND_LIBRARY_SUFFIXES}) # .dll isn't found by find_library with MSVC because .dll isn't included in # CMAKE_FIND_LIBRARY_SUFFIXES. @@ -158,7 +165,7 @@ macro(arrow_find_package_home) PATHS "${home}" PATH_SUFFIXES ${ARROW_SEARCH_LIB_PATH_SUFFIXES} NO_DEFAULT_PATH) - if(MSVC) + if(MSVC_TOOLCHAIN) set(CMAKE_SHARED_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_ORIGINAL}) endif() set(shared_lib "${${prefix}_shared_lib}") diff --git a/cpp/cmake_modules/FindBoostAlt.cmake b/cpp/cmake_modules/FindBoostAlt.cmake index 8f16439bf86..300080d4fb1 100644 --- a/cpp/cmake_modules/FindBoostAlt.cmake +++ b/cpp/cmake_modules/FindBoostAlt.cmake @@ -52,7 +52,7 @@ endif() if(Boost_FOUND) set(BoostAlt_FOUND ON) - if(MSVC) + if(MSVC_TOOLCHAIN) # disable autolinking in boost add_definitions(-DBOOST_ALL_NO_LIB) if(ARROW_BOOST_USE_SHARED) diff --git a/cpp/cmake_modules/FindGTest.cmake b/cpp/cmake_modules/FindGTest.cmake index 4be2cf57046..8581d921b1c 100644 --- a/cpp/cmake_modules/FindGTest.cmake +++ b/cpp/cmake_modules/FindGTest.cmake @@ -171,7 +171,7 @@ if(NOT DEFINED GTEST_MSVC_SEARCH) endif() set(_gtest_libpath_suffixes lib) -if(MSVC) +if(MSVC_TOOLCHAIN) if(GTEST_MSVC_SEARCH STREQUAL "MD") list(APPEND _gtest_libpath_suffixes msvc/gtest-md/Debug @@ -198,7 +198,7 @@ find_path(GTEST_INCLUDE_DIR gtest/gtest.h ) mark_as_advanced(GTEST_INCLUDE_DIR) -if(MSVC AND GTEST_MSVC_SEARCH STREQUAL "MD") +if(MSVC_TOOLCHAIN AND GTEST_MSVC_SEARCH STREQUAL "MD") # The provided /MD project files for Google Test add -md suffixes to the # library names. __gtest_find_library(GTEST_LIBRARY gtest-md gtest) diff --git a/cpp/cmake_modules/FindLz4.cmake b/cpp/cmake_modules/FindLz4.cmake index dbc6c5f8d3b..7159f96f70f 100644 --- a/cpp/cmake_modules/FindLz4.cmake +++ b/cpp/cmake_modules/FindLz4.cmake @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -if(MSVC AND NOT DEFINED LZ4_MSVC_LIB_PREFIX) +if(MSVC_TOOLCHAIN AND NOT DEFINED LZ4_MSVC_LIB_PREFIX) set(LZ4_MSVC_LIB_PREFIX "lib") endif() set(LZ4_LIB_NAME_BASE "${LZ4_MSVC_LIB_PREFIX}lz4") diff --git a/cpp/cmake_modules/FindThrift.cmake b/cpp/cmake_modules/FindThrift.cmake index d266f02e29b..273d907ed07 100644 --- a/cpp/cmake_modules/FindThrift.cmake +++ b/cpp/cmake_modules/FindThrift.cmake @@ -39,7 +39,7 @@ function(EXTRACT_THRIFT_VERSION) endif() endfunction(EXTRACT_THRIFT_VERSION) -if(MSVC AND NOT DEFINED THRIFT_MSVC_LIB_SUFFIX) +if(MSVC_TOOLCHAIN AND NOT DEFINED THRIFT_MSVC_LIB_SUFFIX) if(NOT ARROW_THRIFT_USE_SHARED) if(ARROW_USE_STATIC_CRT) set(THRIFT_MSVC_LIB_SUFFIX "mt") @@ -133,7 +133,7 @@ if(Thrift_FOUND OR THRIFT_FOUND) set_target_properties(thrift::thrift PROPERTIES IMPORTED_LOCATION "${THRIFT_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${THRIFT_INCLUDE_DIR}") - if(WIN32 AND NOT MSVC) + if(WIN32 AND NOT MSVC_TOOLCHAIN) # We don't need this for Visual C++ because Thrift uses # "#pragma comment(lib, "Ws2_32.lib")" in # thrift/windows/config.h for Visual C++. diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 8b2a1dce930..0180ef912bb 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -552,7 +552,7 @@ endif() set(EP_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}}") set(EP_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${UPPERCASE_BUILD_TYPE}}") -if(NOT MSVC) +if(NOT MSVC_TOOLCHAIN) # Set -fPIC on all external projects set(EP_CXX_FLAGS "${EP_CXX_FLAGS} -fPIC") set(EP_C_FLAGS "${EP_C_FLAGS} -fPIC") @@ -1348,7 +1348,7 @@ if(ARROW_WITH_PROTOBUF) endif() resolve_dependency(Protobuf REQUIRED_VERSION ${ARROW_PROTOBUF_REQUIRED_VERSION}) - if(ARROW_PROTOBUF_USE_SHARED AND MSVC) + if(ARROW_PROTOBUF_USE_SHARED AND MSVC_TOOLCHAIN) add_definitions(-DPROTOBUF_USE_DLLS) endif() diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 26e16b56c22..f40fa3798b4 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -463,7 +463,7 @@ if(ARROW_ORC) list(APPEND ARROW_SRCS adapters/orc/adapter.cc adapters/orc/adapter_util.cc) endif() -if(NOT APPLE AND NOT MSVC) +if(NOT APPLE AND NOT MSVC_TOOLCHAIN) # Localize thirdparty symbols using a linker version script. This hides them # from the client application. The OS X linker does not support the # version-script option. diff --git a/cpp/src/arrow/python/type_traits.h b/cpp/src/arrow/python/type_traits.h index 2f704701ce6..cec9106a015 100644 --- a/cpp/src/arrow/python/type_traits.h +++ b/cpp/src/arrow/python/type_traits.h @@ -105,7 +105,7 @@ struct npy_traits { using TypeClass = FloatType; using BuilderClass = FloatBuilder; - static constexpr float na_sentinel = NAN; + static constexpr float na_sentinel = std::numeric_limits::quiet_NaN(); static constexpr bool supports_nulls = true; @@ -118,7 +118,7 @@ struct npy_traits { using TypeClass = DoubleType; using BuilderClass = DoubleBuilder; - static constexpr double na_sentinel = NAN; + static constexpr double na_sentinel = std::numeric_limits::quiet_NaN(); static constexpr bool supports_nulls = true; @@ -178,13 +178,13 @@ struct arrow_traits { typedef typename npy_traits::value_type T; }; -#define INT_DECL(TYPE) \ - template <> \ - struct arrow_traits { \ - static constexpr int npy_type = NPY_##TYPE; \ - static constexpr bool supports_nulls = false; \ - static constexpr double na_value = NAN; \ - typedef typename npy_traits::value_type T; \ +#define INT_DECL(TYPE) \ + template <> \ + struct arrow_traits { \ + static constexpr int npy_type = NPY_##TYPE; \ + static constexpr bool supports_nulls = false; \ + static constexpr double na_value = std::numeric_limits::quiet_NaN(); \ + typedef typename npy_traits::value_type T; \ }; INT_DECL(INT8); @@ -208,7 +208,7 @@ template <> struct arrow_traits { static constexpr int npy_type = NPY_FLOAT32; static constexpr bool supports_nulls = true; - static constexpr float na_value = NAN; + static constexpr float na_value = std::numeric_limits::quiet_NaN(); typedef typename npy_traits::value_type T; }; @@ -216,7 +216,7 @@ template <> struct arrow_traits { static constexpr int npy_type = NPY_FLOAT64; static constexpr bool supports_nulls = true; - static constexpr double na_value = NAN; + static constexpr double na_value = std::numeric_limits::quiet_NaN(); typedef typename npy_traits::value_type T; }; diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt index 85e8db60252..99c23f99cd9 100644 --- a/cpp/src/gandiva/CMakeLists.txt +++ b/cpp/src/gandiva/CMakeLists.txt @@ -106,7 +106,7 @@ endif() # set(GANDIVA_SHARED_LINK_FLAGS "${GANDIVA_SHARED_LINK_FLAGS} /EXPORT:${SYMBOL}") # endforeach() # endif() -if(NOT APPLE AND NOT MSVC) +if(NOT APPLE AND NOT MSVC_TOOLCHAIN) # Localize thirdparty symbols using a linker version script. This hides them # from the client application. The OS X linker does not support the # version-script option. diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index 481857a9205..2d2bcb5cc24 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -233,7 +233,7 @@ if(NOT PARQUET_MINIMAL_DEPENDENCY) endif(NOT PARQUET_MINIMAL_DEPENDENCY) -if(NOT APPLE AND NOT MSVC) +if(NOT APPLE AND NOT MSVC_TOOLCHAIN) # Localize thirdparty symbols using a linker version script. This hides them # from the client application. The OS X linker does not support the # version-script option. diff --git a/cpp/src/parquet/exception.h b/cpp/src/parquet/exception.h index 11efd8756f1..3f97c1e9267 100644 --- a/cpp/src/parquet/exception.h +++ b/cpp/src/parquet/exception.h @@ -122,9 +122,17 @@ class ParquetStatusException : public ParquetException { // This class exists for the purpose of detecting an invalid or corrupted file. class ParquetInvalidOrCorruptedFileException : public ParquetStatusException { public: - template - explicit ParquetInvalidOrCorruptedFileException(Args&&... args) - : ParquetStatusException(::arrow::Status::Invalid(std::forward(args)...)) {} + ParquetInvalidOrCorruptedFileException(const ParquetInvalidOrCorruptedFileException&) = + default; + + template ::value, + int>::type = 0, + typename... Args> + explicit ParquetInvalidOrCorruptedFileException(Arg arg, Args&&... args) + : ParquetStatusException(::arrow::Status::Invalid(std::forward(arg), + std::forward(args)...)) {} }; template diff --git a/cpp/src/plasma/CMakeLists.txt b/cpp/src/plasma/CMakeLists.txt index 43b3f033c83..16e4787baa1 100644 --- a/cpp/src/plasma/CMakeLists.txt +++ b/cpp/src/plasma/CMakeLists.txt @@ -61,7 +61,7 @@ if(ARROW_CUDA) add_definitions(-DPLASMA_CUDA) endif() -if(NOT APPLE AND NOT MSVC) +if(NOT APPLE AND NOT MSVC_TOOLCHAIN) # Localize thirdparty symbols using a linker version script. This hides them # from the client application. The OS X linker does not support the # version-script option.