From c83c7d63305f959981a9dbf1c521131c0d294ae0 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Thu, 23 May 2019 08:47:20 -0500 Subject: [PATCH 1/5] Use gtest shared lib Use gtest shared library, handle Windows-related quirks with EP build Always build bundled gtest on MSVC Fix up build on Linux Passing GTest_SOURCE=BUNDLED no longer needed on MSVC Try passing CMAKE_CXX_FLAGS as string in MSVC build Try something else ninja weirdness Use different RUNTIME_OUTPUT_DIRECTORY for Ninja build generator Fix up CMake args for googletest Try slightly different incantation cmake-format --- ci/cpp-msvc-build-main.bat | 4 +- cpp/CMakeLists.txt | 73 +++++++++------- cpp/cmake_modules/BuildUtils.cmake | 2 +- cpp/cmake_modules/FindBrotli.cmake | 6 +- cpp/cmake_modules/FindDoubleConversion.cmake | 2 +- cpp/cmake_modules/FindFlatbuffersAlt.cmake | 2 +- cpp/cmake_modules/FindGLOG.cmake | 2 +- cpp/cmake_modules/FindLLVM.cmake | 2 +- cpp/cmake_modules/FindLz4.cmake | 2 +- cpp/cmake_modules/FindRE2.cmake | 2 +- cpp/cmake_modules/FindSnappyAlt.cmake | 2 +- cpp/cmake_modules/FindZSTD.cmake | 2 +- cpp/cmake_modules/Findc-aresAlt.cmake | 2 +- cpp/cmake_modules/FindgRPCAlt.cmake | 8 +- cpp/cmake_modules/FindgflagsAlt.cmake | 2 +- cpp/cmake_modules/SetupCxxFlags.cmake | 4 - cpp/cmake_modules/ThirdpartyToolchain.cmake | 87 ++++++++++++++------ cpp/src/gandiva/precompiled/CMakeLists.txt | 2 +- docs/source/developers/cpp.rst | 9 +- 19 files changed, 125 insertions(+), 90 deletions(-) diff --git a/ci/cpp-msvc-build-main.bat b/ci/cpp-msvc-build-main.bat index 74eac7266dea..b3ac9bbf7ea0 100644 --- a/ci/cpp-msvc-build-main.bat +++ b/ci/cpp-msvc-build-main.bat @@ -22,12 +22,10 @@ set ARROW_HOME=%CONDA_PREFIX%\Library set CMAKE_ARGS=-DARROW_VERBOSE_THIRDPARTY_BUILD=OFF if "%JOB%" == "Toolchain" ( - @rem Toolchain gtest does not currently work with Visual Studio 2015 set CMAKE_ARGS=^ %CMAKE_ARGS% ^ -DARROW_WITH_BZ2=ON ^ - -DARROW_DEPENDENCY_SOURCE=CONDA ^ - -DGTest_SOURCE=BUNDLED + -DARROW_DEPENDENCY_SOURCE=CONDA ) else ( @rem We're in a conda enviroment but don't want to use it for the dependencies set CMAKE_ARGS=%CMAKE_ARGS% -DARROW_DEPENDENCY_SOURCE=AUTO diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 6fa7fb5005f7..853ff7a1d42d 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -24,6 +24,11 @@ string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" ARROW_BASE_VERSION "${ARROW_VERSI project(arrow VERSION "${ARROW_BASE_VERSION}") +# if no build build type is specified, default to release builds +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif(NOT CMAKE_BUILD_TYPE) + set(ARROW_VERSION_MAJOR "${arrow_VERSION_MAJOR}") set(ARROW_VERSION_MINOR "${arrow_VERSION_MINOR}") set(ARROW_VERSION_PATCH "${arrow_VERSION_PATCH}") @@ -309,6 +314,42 @@ endif() include(SetupCxxFlags) +# +# Build output directory +# + +# set compile output directory +string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_SUBDIR_NAME) + +# If build in-source, create the latest symlink. If build out-of-source, which is +# preferred, simply output the binaries in the build folder +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) + set(BUILD_OUTPUT_ROOT_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/build/${BUILD_SUBDIR_NAME}/") + # Link build/latest to the current build directory, to avoid developers + # accidentally running the latest debug build when in fact they're building + # release builds. + file(MAKE_DIRECTORY ${BUILD_OUTPUT_ROOT_DIRECTORY}) + if(NOT APPLE) + set(MORE_ARGS "-T") + endif() + execute_process(COMMAND ln ${MORE_ARGS} -sf ${BUILD_OUTPUT_ROOT_DIRECTORY} + ${CMAKE_CURRENT_BINARY_DIR}/build/latest) +else() + set(BUILD_OUTPUT_ROOT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SUBDIR_NAME}/") +endif() + +# where to put generated archives (.a files) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}") +set(ARCHIVE_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}") + +# where to put generated libraries (.so files) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}") +set(LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}") + +# where to put generated binaries +set(EXECUTABLE_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}") + # # Dependencies # @@ -348,38 +389,6 @@ endif() message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") -# set compile output directory -string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_SUBDIR_NAME) - -# If build in-source, create the latest symlink. If build out-of-source, which is -# preferred, simply output the binaries in the build folder -if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) - set(BUILD_OUTPUT_ROOT_DIRECTORY - "${CMAKE_CURRENT_BINARY_DIR}/build/${BUILD_SUBDIR_NAME}/") - # Link build/latest to the current build directory, to avoid developers - # accidentally running the latest debug build when in fact they're building - # release builds. - file(MAKE_DIRECTORY ${BUILD_OUTPUT_ROOT_DIRECTORY}) - if(NOT APPLE) - set(MORE_ARGS "-T") - endif() - execute_process(COMMAND ln ${MORE_ARGS} -sf ${BUILD_OUTPUT_ROOT_DIRECTORY} - ${CMAKE_CURRENT_BINARY_DIR}/build/latest) -else() - set(BUILD_OUTPUT_ROOT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${BUILD_SUBDIR_NAME}/") -endif() - -# where to put generated archives (.a files) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}") -set(ARCHIVE_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}") - -# where to put generated libraries (.so files) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}") -set(LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}") - -# where to put generated binaries -set(EXECUTABLE_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}") - include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) include_directories(src) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 45cff6e9cca5..c80f21f34a23 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -179,7 +179,7 @@ function(ADD_ARROW_LIB LIB_NAME) else() # Otherwise, generate a single "objlib" from all C++ modules and link # that "objlib" into each library kind, to avoid compiling twice - add_library(${LIB_NAME}_objlib OBJECT ${ARG_SOURCES}) + add_library(${LIB_NAME}_objlib ${ARG_SOURCES} OBJECT) # Necessary to make static linking into other shared libraries work properly set_property(TARGET ${LIB_NAME}_objlib PROPERTY POSITION_INDEPENDENT_CODE 1) if(ARG_DEPENDENCIES) diff --git a/cpp/cmake_modules/FindBrotli.cmake b/cpp/cmake_modules/FindBrotli.cmake index 4170c59b6afc..e23e36880bb1 100644 --- a/cpp/cmake_modules/FindBrotli.cmake +++ b/cpp/cmake_modules/FindBrotli.cmake @@ -115,15 +115,15 @@ find_package_handle_standard_args(Brotli BROTLI_INCLUDE_DIR) if(Brotli_FOUND OR BROTLI_FOUND) set(Brotli_FOUND TRUE) - add_library(Brotli::brotlicommon UNKNOWN IMPORTED) + add_library(Brotli::brotlicommon IMPORTED UNKNOWN) set_target_properties(Brotli::brotlicommon PROPERTIES IMPORTED_LOCATION "${BROTLI_COMMON_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}") - add_library(Brotli::brotlienc UNKNOWN IMPORTED) + add_library(Brotli::brotlienc IMPORTED UNKNOWN) set_target_properties(Brotli::brotlienc PROPERTIES IMPORTED_LOCATION "${BROTLI_ENC_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}") - add_library(Brotli::brotlidec UNKNOWN IMPORTED) + add_library(Brotli::brotlidec IMPORTED UNKNOWN) set_target_properties(Brotli::brotlidec PROPERTIES IMPORTED_LOCATION "${BROTLI_DEC_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindDoubleConversion.cmake b/cpp/cmake_modules/FindDoubleConversion.cmake index d5d20355cec6..1900e1bb9ecc 100644 --- a/cpp/cmake_modules/FindDoubleConversion.cmake +++ b/cpp/cmake_modules/FindDoubleConversion.cmake @@ -37,7 +37,7 @@ find_package_handle_standard_args(DoubleConversion REQUIRED_VARS DoubleConversio DoubleConversion_INCLUDE_DIR) if(DoubleConversion_FOUND) - add_library(double-conversion::double-conversion UNKNOWN IMPORTED) + add_library(double-conversion::double-conversion IMPORTED UNKNOWN) set_target_properties(double-conversion::double-conversion PROPERTIES IMPORTED_LOCATION "${DoubleConversion_LIB}" INTERFACE_INCLUDE_DIRECTORIES diff --git a/cpp/cmake_modules/FindFlatbuffersAlt.cmake b/cpp/cmake_modules/FindFlatbuffersAlt.cmake index c551c1c55825..06c1193fed63 100644 --- a/cpp/cmake_modules/FindFlatbuffersAlt.cmake +++ b/cpp/cmake_modules/FindFlatbuffersAlt.cmake @@ -46,7 +46,7 @@ find_package_handle_standard_args(FlatbuffersAlt FLATC) if(FlatbuffersAlt_FOUND) - add_library(flatbuffers::flatbuffers UNKNOWN IMPORTED) + add_library(flatbuffers::flatbuffers IMPORTED UNKNOWN) set_target_properties(flatbuffers::flatbuffers PROPERTIES IMPORTED_LOCATION "${FLATBUFFERS_LIB}" INTERFACE_INCLUDE_DIRECTORIES diff --git a/cpp/cmake_modules/FindGLOG.cmake b/cpp/cmake_modules/FindGLOG.cmake index c5aa11bc575d..460aa3a764d3 100644 --- a/cpp/cmake_modules/FindGLOG.cmake +++ b/cpp/cmake_modules/FindGLOG.cmake @@ -44,7 +44,7 @@ endif() find_package_handle_standard_args(GLOG REQUIRED_VARS GLOG_INCLUDE_DIR GLOG_LIB) if(GLOG_FOUND) - add_library(GLOG::glog UNKNOWN IMPORTED) + add_library(GLOG::glog IMPORTED UNKNOWN) set_target_properties(GLOG::glog PROPERTIES IMPORTED_LOCATION "${GLOG_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindLLVM.cmake b/cpp/cmake_modules/FindLLVM.cmake index bef45085de89..13989f2b5d09 100644 --- a/cpp/cmake_modules/FindLLVM.cmake +++ b/cpp/cmake_modules/FindLLVM.cmake @@ -78,7 +78,7 @@ else() endif() endif() -add_library(LLVM::LLVM_INTERFACE INTERFACE IMPORTED) +add_library(LLVM::LLVM_INTERFACE IMPORTED INTERFACE) set_target_properties(LLVM::LLVM_INTERFACE PROPERTIES INTERFACE_INCLUDE_DIRECTORIES diff --git a/cpp/cmake_modules/FindLz4.cmake b/cpp/cmake_modules/FindLz4.cmake index 8410916432ac..67dcaebada5f 100644 --- a/cpp/cmake_modules/FindLz4.cmake +++ b/cpp/cmake_modules/FindLz4.cmake @@ -62,7 +62,7 @@ find_package_handle_standard_args(Lz4 REQUIRED_VARS LZ4_LIB LZ4_INCLUDE_DIR) # CMake 3.2 does uppercase the FOUND variable if(Lz4_FOUND OR LZ4_FOUND) set(Lz4_FOUND TRUE) - add_library(LZ4::lz4 UNKNOWN IMPORTED) + add_library(LZ4::lz4 IMPORTED UNKNOWN) set_target_properties(LZ4::lz4 PROPERTIES IMPORTED_LOCATION "${LZ4_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindRE2.cmake b/cpp/cmake_modules/FindRE2.cmake index 8fab995f8467..c52008faa00f 100644 --- a/cpp/cmake_modules/FindRE2.cmake +++ b/cpp/cmake_modules/FindRE2.cmake @@ -62,7 +62,7 @@ endif() find_package_handle_standard_args(RE2 REQUIRED_VARS RE2_LIB RE2_INCLUDE_DIR) if(RE2_FOUND) - add_library(RE2::re2 UNKNOWN IMPORTED) + add_library(RE2::re2 IMPORTED UNKNOWN) set_target_properties(RE2::re2 PROPERTIES IMPORTED_LOCATION "${RE2_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${RE2_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindSnappyAlt.cmake b/cpp/cmake_modules/FindSnappyAlt.cmake index 019c8794f18a..dd7bedb9a1b1 100644 --- a/cpp/cmake_modules/FindSnappyAlt.cmake +++ b/cpp/cmake_modules/FindSnappyAlt.cmake @@ -34,7 +34,7 @@ endif() find_package_handle_standard_args(SnappyAlt REQUIRED_VARS Snappy_LIB Snappy_INCLUDE_DIR) if(SnappyAlt_FOUND) - add_library(Snappy::snappy UNKNOWN IMPORTED) + add_library(Snappy::snappy IMPORTED UNKNOWN) set_target_properties(Snappy::snappy PROPERTIES IMPORTED_LOCATION "${Snappy_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${Snappy_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindZSTD.cmake b/cpp/cmake_modules/FindZSTD.cmake index 8e47086e86a0..ca7611b905e8 100644 --- a/cpp/cmake_modules/FindZSTD.cmake +++ b/cpp/cmake_modules/FindZSTD.cmake @@ -61,7 +61,7 @@ endif() find_package_handle_standard_args(ZSTD REQUIRED_VARS ZSTD_LIB ZSTD_INCLUDE_DIR) if(ZSTD_FOUND) - add_library(ZSTD::zstd UNKNOWN IMPORTED) + add_library(ZSTD::zstd IMPORTED UNKNOWN) set_target_properties(ZSTD::zstd PROPERTIES IMPORTED_LOCATION "${ZSTD_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/Findc-aresAlt.cmake b/cpp/cmake_modules/Findc-aresAlt.cmake index a769fb533ee7..6f921ff26af6 100644 --- a/cpp/cmake_modules/Findc-aresAlt.cmake +++ b/cpp/cmake_modules/Findc-aresAlt.cmake @@ -34,7 +34,7 @@ endif() find_package_handle_standard_args(c-aresAlt REQUIRED_VARS CARES_INCLUDE_DIR CARES_LIB) if(c-aresAlt_FOUND) - add_library(c-ares::cares UNKNOWN IMPORTED) + add_library(c-ares::cares IMPORTED UNKNOWN) set_target_properties(c-ares::cares PROPERTIES IMPORTED_LOCATION "${CARES_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${CARES_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindgRPCAlt.cmake b/cpp/cmake_modules/FindgRPCAlt.cmake index 5d0ec84f14c6..906fdbf1f04f 100644 --- a/cpp/cmake_modules/FindgRPCAlt.cmake +++ b/cpp/cmake_modules/FindgRPCAlt.cmake @@ -81,24 +81,24 @@ find_package_handle_standard_args(gRPCAlt GRPC_CPP_PLUGIN) if(gRPCAlt_FOUND) - add_library(gRPC::gpr UNKNOWN IMPORTED) + add_library(gRPC::gpr IMPORTED UNKNOWN) set_target_properties(gRPC::gpr PROPERTIES IMPORTED_LOCATION "${GRPC_GPR_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}") - add_library(gRPC::grpc UNKNOWN IMPORTED) + add_library(gRPC::grpc IMPORTED UNKNOWN) set_target_properties(gRPC::grpc PROPERTIES IMPORTED_LOCATION "${GRPC_GRPC_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}") - add_library(gRPC::grpc++ UNKNOWN IMPORTED) + add_library(gRPC::grpc++ IMPORTED UNKNOWN) set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_LOCATION "${GRPC_GRPCPP_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}") if(GRPC_ADDRESS_SORTING_LIB) # Address sorting is optional and not always requird. - add_library(gRPC::address_sorting UNKNOWN IMPORTED) + add_library(gRPC::address_sorting IMPORTED UNKNOWN) set_target_properties(gRPC::address_sorting PROPERTIES IMPORTED_LOCATION "${GRPC_ADDRESS_SORTING_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindgflagsAlt.cmake b/cpp/cmake_modules/FindgflagsAlt.cmake index dfd64f8eef2d..d0abf0290cec 100644 --- a/cpp/cmake_modules/FindgflagsAlt.cmake +++ b/cpp/cmake_modules/FindgflagsAlt.cmake @@ -36,7 +36,7 @@ endif() find_package_handle_standard_args(gflagsAlt REQUIRED_VARS gflags_LIB GFLAGS_INCLUDE_DIR) if(gflagsAlt_FOUND) - add_library(gflags::gflags UNKNOWN IMPORTED) + add_library(gflags::gflags IMPORTED UNKNOWN) set_target_properties(gflags::gflags PROPERTIES IMPORTED_LOCATION "${gflags_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GFLAGS_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake index 97d6383b8954..7c7e7b59dfe1 100644 --- a/cpp/cmake_modules/SetupCxxFlags.cmake +++ b/cpp/cmake_modules/SetupCxxFlags.cmake @@ -38,10 +38,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # shared libraries set(CMAKE_POSITION_INDEPENDENT_CODE ON) -# if no build build type is specified, default to debug builds -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -endif(NOT CMAKE_BUILD_TYPE) string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) # compiler flags that are common across debug/release builds diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 56e049ced341..8204cc876a54 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -59,6 +59,14 @@ set(ARROW_THIRDPARTY_DEPENDENCIES ZLIB ZSTD) +# TODO(wesm): External GTest shared libraries are not currently +# supported when building with MSVC because of the way that +# conda-forge packages have 4 variants of the libraries packaged +# together +if(MSVC) + set(GTest_SOURCE "BUNDLED") +endif() + message(STATUS "Using ${ARROW_DEPENDENCY_SOURCE} approach to find dependencies") # TODO: double-conversion check fails for conda, it should not @@ -1072,7 +1080,7 @@ if(ARROW_WITH_PROTOBUF) # Old CMake versions don't define the targets if(NOT TARGET protobuf::libprotobuf) - add_library(protobuf::libprotobuf UNKNOWN IMPORTED) + add_library(protobuf::libprotobuf IMPORTED UNKNOWN) set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_LOCATION "${PROTOBUF_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES @@ -1086,7 +1094,7 @@ if(ARROW_WITH_PROTOBUF) if(NOT Protobuf_PROTOC_LIBRARY) message(FATAL_ERROR "libprotoc was set to ${Protobuf_PROTOC_LIBRARY}") endif() - add_library(protobuf::libprotoc UNKNOWN IMPORTED) + add_library(protobuf::libprotoc IMPORTED UNKNOWN) set_target_properties(protobuf::libprotoc PROPERTIES IMPORTED_LOCATION "${Protobuf_PROTOC_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES @@ -1183,24 +1191,55 @@ macro(build_gtest) -Wno-unused-value -Wno-ignored-attributes) endif() + if(MSVC) + set(GTEST_CMAKE_CXX_FLAGS "${GTEST_CMAKE_CXX_FLAGS} -DGTEST_CREATE_SHARED_LIBRARY=1") + endif() + set(GTEST_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/googletest_ep-prefix/src/googletest_ep") set(GTEST_INCLUDE_DIR "${GTEST_PREFIX}/include") + + if(MSVC) + set(_GTEST_IMPORTED_TYPE IMPORTED_IMPLIB) + set(_GTEST_LIBRARY_SUFFIX + "${CMAKE_GTEST_DEBUG_EXTENSION}${CMAKE_IMPORT_LIBRARY_SUFFIX}") + else() + set(_GTEST_IMPORTED_TYPE IMPORTED_LOCATION) + set(_GTEST_LIBRARY_SUFFIX + "${CMAKE_GTEST_DEBUG_EXTENSION}${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + + set(GTEST_SHARED_LIB + "${GTEST_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}gtest${_GTEST_LIBRARY_SUFFIX}") + set(GMOCK_SHARED_LIB + "${GTEST_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}gmock${_GTEST_LIBRARY_SUFFIX}") set( - GTEST_STATIC_LIB - "${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_GTEST_DEBUG_EXTENSION}${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - set( - GTEST_MAIN_STATIC_LIB - "${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_GTEST_DEBUG_EXTENSION}${CMAKE_STATIC_LIBRARY_SUFFIX}" + GTEST_MAIN_SHARED_LIB + + "${GTEST_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}gtest_main${_GTEST_LIBRARY_SUFFIX}" ) - set(GTEST_CMAKE_ARGS ${EP_COMMON_CMAKE_ARGS} "-DCMAKE_INSTALL_PREFIX=${GTEST_PREFIX}" - "-DCMAKE_INSTALL_LIBDIR=lib" - -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS}) + set(GTEST_CMAKE_ARGS + ${EP_COMMON_TOOLCHAIN} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + "-DCMAKE_INSTALL_PREFIX=${GTEST_PREFIX}" + "-DCMAKE_INSTALL_LIBDIR=lib" + -DBUILD_SHARED_LIBS=ON + -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS} + -DCMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}=${GTEST_CMAKE_CXX_FLAGS}) set(GMOCK_INCLUDE_DIR "${GTEST_PREFIX}/include") - set( - GMOCK_STATIC_LIB - "${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_GTEST_DEBUG_EXTENSION}${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) + + if(MSVC) + if("${CMAKE_GENERATOR}" STREQUAL "Ninja") + set(_GTEST_LIBRARY_DIR ${BUILD_OUTPUT_ROOT_DIRECTORY}) + else() + set(_GTEST_LIBRARY_DIR ${BUILD_OUTPUT_ROOT_DIRECTORY}/${CMAKE_BUILD_TYPE}) + endif() + + set(GTEST_CMAKE_ARGS + ${GTEST_CMAKE_ARGS} "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${_GTEST_LIBRARY_DIR}" + "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE}=${_GTEST_LIBRARY_DIR}") + endif() + + add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) if(MSVC AND NOT ARROW_USE_STATIC_CRT) set(GTEST_CMAKE_ARGS ${GTEST_CMAKE_ARGS} -Dgtest_force_shared_crt=ON) @@ -1208,26 +1247,26 @@ macro(build_gtest) externalproject_add(googletest_ep URL ${GTEST_SOURCE_URL} - BUILD_BYPRODUCTS ${GTEST_STATIC_LIB} ${GTEST_MAIN_STATIC_LIB} - ${GMOCK_STATIC_LIB} + BUILD_BYPRODUCTS ${GTEST_SHARED_LIB} ${GTEST_MAIN_SHARED_LIB} + ${GMOCK_SHARED_LIB} CMAKE_ARGS ${GTEST_CMAKE_ARGS} ${EP_LOG_OPTIONS}) # The include directory must exist before it is referenced by a target. file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}") - add_library(GTest::GTest STATIC IMPORTED) + add_library(GTest::GTest SHARED IMPORTED) set_target_properties(GTest::GTest - PROPERTIES IMPORTED_LOCATION "${GTEST_STATIC_LIB}" + PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}") - add_library(GTest::Main STATIC IMPORTED) + add_library(GTest::Main SHARED IMPORTED) set_target_properties(GTest::Main - PROPERTIES IMPORTED_LOCATION "${GTEST_MAIN_STATIC_LIB}" + PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}") - add_library(GTest::GMock STATIC IMPORTED) + add_library(GTest::GMock SHARED IMPORTED) set_target_properties(GTest::GMock - PROPERTIES IMPORTED_LOCATION "${GMOCK_STATIC_LIB}" + PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GMOCK_SHARED_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}") add_dependencies(toolchain-tests googletest_ep) add_dependencies(GTest::GTest googletest_ep) @@ -1717,7 +1756,7 @@ if(ARROW_WITH_BZ2) resolve_dependency(BZip2) if(NOT TARGET BZip2::BZip2) - add_library(BZip2::BZip2 UNKNOWN IMPORTED) + add_library(BZip2::BZip2 IMPORTED UNKNOWN) set_target_properties(BZip2::BZip2 PROPERTIES IMPORTED_LOCATION "${BZIP2_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIR}") diff --git a/cpp/src/gandiva/precompiled/CMakeLists.txt b/cpp/src/gandiva/precompiled/CMakeLists.txt index cfd1e88a894e..178e2c08cf58 100644 --- a/cpp/src/gandiva/precompiled/CMakeLists.txt +++ b/cpp/src/gandiva/precompiled/CMakeLists.txt @@ -104,7 +104,7 @@ function(add_precompiled_unit_test REL_TEST_NAME) set(TEST_NAME "gandiva-precompiled-${TEST_NAME}") - add_executable(${TEST_NAME} ${REL_TEST_NAME} ${ARGN}) + add_executable(${TEST_NAME} ${ARGN} ${REL_TEST_NAME}) target_include_directories(${TEST_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src) target_link_libraries(${TEST_NAME} PRIVATE ${ARROW_TEST_LINK_LIBS} RE2::re2) target_compile_definitions(${TEST_NAME} diff --git a/docs/source/developers/cpp.rst b/docs/source/developers/cpp.rst index 3a63ee264ec0..f95981a1712c 100644 --- a/docs/source/developers/cpp.rst +++ b/docs/source/developers/cpp.rst @@ -696,16 +696,9 @@ an out of source build by generating a MSVC solution: mkdir build cd build cmake .. -G "Visual Studio 14 2015 Win64" ^ - -DARROW_BUILD_TESTS=ON ^ - -DGTest_SOURCE=BUNDLED + -DARROW_BUILD_TESTS=ON cmake --build . --config Release -.. note:: - - Currently building the unit tests does not work properly with googletest - from conda-forge, so we must use the ``BUNDLED`` source for building that - dependency - Building with Ninja and clcache ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From ac73ae370ab397c457d759844670bdd97af63c98 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 27 May 2019 13:11:00 -0500 Subject: [PATCH 2/5] Disable static CRT build --- appveyor.yml | 5 +++-- ci/appveyor-cpp-build.bat | 4 ++++ cpp/cmake_modules/BuildUtils.cmake | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f4c587733df7..74c68df9c19e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -66,8 +66,9 @@ environment: GENERATOR: Visual Studio 14 2015 Win64 CONFIGURATION: "Release" ARROW_BUILD_GANDIVA: "ON" - - JOB: "Static_Crt_Build" - GENERATOR: Ninja + # NOTE: Since ARROW-5403 we have disabled the static CRT build + # - JOB: "Static_Crt_Build" + # GENERATOR: Ninja - JOB: "Build_Debug" GENERATOR: Ninja CONFIGURATION: "Debug" diff --git a/ci/appveyor-cpp-build.bat b/ci/appveyor-cpp-build.bat index 0320db9c4d7b..54f947ae1de7 100644 --- a/ci/appveyor-cpp-build.bat +++ b/ci/appveyor-cpp-build.bat @@ -26,6 +26,10 @@ if "%JOB%" == "Static_Crt_Build" ( @rem the Arrow DLL and the tests end up using a different instance of @rem the CRT, which wreaks havoc. + @rem ARROW-5403(wesm): Since changing to using gtest DLLs we can no + @rem longer run the unit tests because gtest.dll and the unit test + @rem executables have different static copies of the CRT + mkdir cpp\build-debug pushd cpp\build-debug diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index c80f21f34a23..45cff6e9cca5 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -179,7 +179,7 @@ function(ADD_ARROW_LIB LIB_NAME) else() # Otherwise, generate a single "objlib" from all C++ modules and link # that "objlib" into each library kind, to avoid compiling twice - add_library(${LIB_NAME}_objlib ${ARG_SOURCES} OBJECT) + add_library(${LIB_NAME}_objlib OBJECT ${ARG_SOURCES}) # Necessary to make static linking into other shared libraries work properly set_property(TARGET ${LIB_NAME}_objlib PROPERTY POSITION_INDEPENDENT_CODE 1) if(ARG_DEPENDENCIES) From c88d125d4c1162c2344a1347a05fd8236faec5e0 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 27 May 2019 13:14:45 -0500 Subject: [PATCH 3/5] Revert unwanted cmake-format changes --- cpp/cmake_modules/FindBrotli.cmake | 6 +++--- cpp/cmake_modules/FindDoubleConversion.cmake | 2 +- cpp/cmake_modules/FindFlatbuffersAlt.cmake | 2 +- cpp/cmake_modules/FindGLOG.cmake | 2 +- cpp/cmake_modules/FindLz4.cmake | 2 +- cpp/cmake_modules/FindRE2.cmake | 2 +- cpp/cmake_modules/FindSnappyAlt.cmake | 2 +- cpp/cmake_modules/FindZSTD.cmake | 2 +- cpp/cmake_modules/Findc-aresAlt.cmake | 2 +- cpp/cmake_modules/FindgRPCAlt.cmake | 8 ++++---- cpp/cmake_modules/FindgflagsAlt.cmake | 2 +- cpp/cmake_modules/ThirdpartyToolchain.cmake | 6 +++--- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cpp/cmake_modules/FindBrotli.cmake b/cpp/cmake_modules/FindBrotli.cmake index e23e36880bb1..4170c59b6afc 100644 --- a/cpp/cmake_modules/FindBrotli.cmake +++ b/cpp/cmake_modules/FindBrotli.cmake @@ -115,15 +115,15 @@ find_package_handle_standard_args(Brotli BROTLI_INCLUDE_DIR) if(Brotli_FOUND OR BROTLI_FOUND) set(Brotli_FOUND TRUE) - add_library(Brotli::brotlicommon IMPORTED UNKNOWN) + add_library(Brotli::brotlicommon UNKNOWN IMPORTED) set_target_properties(Brotli::brotlicommon PROPERTIES IMPORTED_LOCATION "${BROTLI_COMMON_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}") - add_library(Brotli::brotlienc IMPORTED UNKNOWN) + add_library(Brotli::brotlienc UNKNOWN IMPORTED) set_target_properties(Brotli::brotlienc PROPERTIES IMPORTED_LOCATION "${BROTLI_ENC_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}") - add_library(Brotli::brotlidec IMPORTED UNKNOWN) + add_library(Brotli::brotlidec UNKNOWN IMPORTED) set_target_properties(Brotli::brotlidec PROPERTIES IMPORTED_LOCATION "${BROTLI_DEC_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindDoubleConversion.cmake b/cpp/cmake_modules/FindDoubleConversion.cmake index 1900e1bb9ecc..d5d20355cec6 100644 --- a/cpp/cmake_modules/FindDoubleConversion.cmake +++ b/cpp/cmake_modules/FindDoubleConversion.cmake @@ -37,7 +37,7 @@ find_package_handle_standard_args(DoubleConversion REQUIRED_VARS DoubleConversio DoubleConversion_INCLUDE_DIR) if(DoubleConversion_FOUND) - add_library(double-conversion::double-conversion IMPORTED UNKNOWN) + add_library(double-conversion::double-conversion UNKNOWN IMPORTED) set_target_properties(double-conversion::double-conversion PROPERTIES IMPORTED_LOCATION "${DoubleConversion_LIB}" INTERFACE_INCLUDE_DIRECTORIES diff --git a/cpp/cmake_modules/FindFlatbuffersAlt.cmake b/cpp/cmake_modules/FindFlatbuffersAlt.cmake index 06c1193fed63..c551c1c55825 100644 --- a/cpp/cmake_modules/FindFlatbuffersAlt.cmake +++ b/cpp/cmake_modules/FindFlatbuffersAlt.cmake @@ -46,7 +46,7 @@ find_package_handle_standard_args(FlatbuffersAlt FLATC) if(FlatbuffersAlt_FOUND) - add_library(flatbuffers::flatbuffers IMPORTED UNKNOWN) + add_library(flatbuffers::flatbuffers UNKNOWN IMPORTED) set_target_properties(flatbuffers::flatbuffers PROPERTIES IMPORTED_LOCATION "${FLATBUFFERS_LIB}" INTERFACE_INCLUDE_DIRECTORIES diff --git a/cpp/cmake_modules/FindGLOG.cmake b/cpp/cmake_modules/FindGLOG.cmake index 460aa3a764d3..c5aa11bc575d 100644 --- a/cpp/cmake_modules/FindGLOG.cmake +++ b/cpp/cmake_modules/FindGLOG.cmake @@ -44,7 +44,7 @@ endif() find_package_handle_standard_args(GLOG REQUIRED_VARS GLOG_INCLUDE_DIR GLOG_LIB) if(GLOG_FOUND) - add_library(GLOG::glog IMPORTED UNKNOWN) + add_library(GLOG::glog UNKNOWN IMPORTED) set_target_properties(GLOG::glog PROPERTIES IMPORTED_LOCATION "${GLOG_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindLz4.cmake b/cpp/cmake_modules/FindLz4.cmake index 67dcaebada5f..8410916432ac 100644 --- a/cpp/cmake_modules/FindLz4.cmake +++ b/cpp/cmake_modules/FindLz4.cmake @@ -62,7 +62,7 @@ find_package_handle_standard_args(Lz4 REQUIRED_VARS LZ4_LIB LZ4_INCLUDE_DIR) # CMake 3.2 does uppercase the FOUND variable if(Lz4_FOUND OR LZ4_FOUND) set(Lz4_FOUND TRUE) - add_library(LZ4::lz4 IMPORTED UNKNOWN) + add_library(LZ4::lz4 UNKNOWN IMPORTED) set_target_properties(LZ4::lz4 PROPERTIES IMPORTED_LOCATION "${LZ4_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindRE2.cmake b/cpp/cmake_modules/FindRE2.cmake index c52008faa00f..8fab995f8467 100644 --- a/cpp/cmake_modules/FindRE2.cmake +++ b/cpp/cmake_modules/FindRE2.cmake @@ -62,7 +62,7 @@ endif() find_package_handle_standard_args(RE2 REQUIRED_VARS RE2_LIB RE2_INCLUDE_DIR) if(RE2_FOUND) - add_library(RE2::re2 IMPORTED UNKNOWN) + add_library(RE2::re2 UNKNOWN IMPORTED) set_target_properties(RE2::re2 PROPERTIES IMPORTED_LOCATION "${RE2_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${RE2_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindSnappyAlt.cmake b/cpp/cmake_modules/FindSnappyAlt.cmake index dd7bedb9a1b1..019c8794f18a 100644 --- a/cpp/cmake_modules/FindSnappyAlt.cmake +++ b/cpp/cmake_modules/FindSnappyAlt.cmake @@ -34,7 +34,7 @@ endif() find_package_handle_standard_args(SnappyAlt REQUIRED_VARS Snappy_LIB Snappy_INCLUDE_DIR) if(SnappyAlt_FOUND) - add_library(Snappy::snappy IMPORTED UNKNOWN) + add_library(Snappy::snappy UNKNOWN IMPORTED) set_target_properties(Snappy::snappy PROPERTIES IMPORTED_LOCATION "${Snappy_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${Snappy_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindZSTD.cmake b/cpp/cmake_modules/FindZSTD.cmake index ca7611b905e8..8e47086e86a0 100644 --- a/cpp/cmake_modules/FindZSTD.cmake +++ b/cpp/cmake_modules/FindZSTD.cmake @@ -61,7 +61,7 @@ endif() find_package_handle_standard_args(ZSTD REQUIRED_VARS ZSTD_LIB ZSTD_INCLUDE_DIR) if(ZSTD_FOUND) - add_library(ZSTD::zstd IMPORTED UNKNOWN) + add_library(ZSTD::zstd UNKNOWN IMPORTED) set_target_properties(ZSTD::zstd PROPERTIES IMPORTED_LOCATION "${ZSTD_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/Findc-aresAlt.cmake b/cpp/cmake_modules/Findc-aresAlt.cmake index 6f921ff26af6..a769fb533ee7 100644 --- a/cpp/cmake_modules/Findc-aresAlt.cmake +++ b/cpp/cmake_modules/Findc-aresAlt.cmake @@ -34,7 +34,7 @@ endif() find_package_handle_standard_args(c-aresAlt REQUIRED_VARS CARES_INCLUDE_DIR CARES_LIB) if(c-aresAlt_FOUND) - add_library(c-ares::cares IMPORTED UNKNOWN) + add_library(c-ares::cares UNKNOWN IMPORTED) set_target_properties(c-ares::cares PROPERTIES IMPORTED_LOCATION "${CARES_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${CARES_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindgRPCAlt.cmake b/cpp/cmake_modules/FindgRPCAlt.cmake index 906fdbf1f04f..5d0ec84f14c6 100644 --- a/cpp/cmake_modules/FindgRPCAlt.cmake +++ b/cpp/cmake_modules/FindgRPCAlt.cmake @@ -81,24 +81,24 @@ find_package_handle_standard_args(gRPCAlt GRPC_CPP_PLUGIN) if(gRPCAlt_FOUND) - add_library(gRPC::gpr IMPORTED UNKNOWN) + add_library(gRPC::gpr UNKNOWN IMPORTED) set_target_properties(gRPC::gpr PROPERTIES IMPORTED_LOCATION "${GRPC_GPR_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}") - add_library(gRPC::grpc IMPORTED UNKNOWN) + add_library(gRPC::grpc UNKNOWN IMPORTED) set_target_properties(gRPC::grpc PROPERTIES IMPORTED_LOCATION "${GRPC_GRPC_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}") - add_library(gRPC::grpc++ IMPORTED UNKNOWN) + add_library(gRPC::grpc++ UNKNOWN IMPORTED) set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_LOCATION "${GRPC_GRPCPP_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}") if(GRPC_ADDRESS_SORTING_LIB) # Address sorting is optional and not always requird. - add_library(gRPC::address_sorting IMPORTED UNKNOWN) + add_library(gRPC::address_sorting UNKNOWN IMPORTED) set_target_properties(gRPC::address_sorting PROPERTIES IMPORTED_LOCATION "${GRPC_ADDRESS_SORTING_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GRPC_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/FindgflagsAlt.cmake b/cpp/cmake_modules/FindgflagsAlt.cmake index d0abf0290cec..dfd64f8eef2d 100644 --- a/cpp/cmake_modules/FindgflagsAlt.cmake +++ b/cpp/cmake_modules/FindgflagsAlt.cmake @@ -36,7 +36,7 @@ endif() find_package_handle_standard_args(gflagsAlt REQUIRED_VARS gflags_LIB GFLAGS_INCLUDE_DIR) if(gflagsAlt_FOUND) - add_library(gflags::gflags IMPORTED UNKNOWN) + add_library(gflags::gflags UNKNOWN IMPORTED) set_target_properties(gflags::gflags PROPERTIES IMPORTED_LOCATION "${gflags_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${GFLAGS_INCLUDE_DIR}") diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 8204cc876a54..33dfc3b8850e 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -1080,7 +1080,7 @@ if(ARROW_WITH_PROTOBUF) # Old CMake versions don't define the targets if(NOT TARGET protobuf::libprotobuf) - add_library(protobuf::libprotobuf IMPORTED UNKNOWN) + add_library(protobuf::libprotobuf UNKNOWN IMPORTED) set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_LOCATION "${PROTOBUF_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES @@ -1094,7 +1094,7 @@ if(ARROW_WITH_PROTOBUF) if(NOT Protobuf_PROTOC_LIBRARY) message(FATAL_ERROR "libprotoc was set to ${Protobuf_PROTOC_LIBRARY}") endif() - add_library(protobuf::libprotoc IMPORTED UNKNOWN) + add_library(protobuf::libprotoc UNKNOWN IMPORTED) set_target_properties(protobuf::libprotoc PROPERTIES IMPORTED_LOCATION "${Protobuf_PROTOC_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES @@ -1756,7 +1756,7 @@ if(ARROW_WITH_BZ2) resolve_dependency(BZip2) if(NOT TARGET BZip2::BZip2) - add_library(BZip2::BZip2 IMPORTED UNKNOWN) + add_library(BZip2::BZip2 UNKNOWN IMPORTED) set_target_properties(BZip2::BZip2 PROPERTIES IMPORTED_LOCATION "${BZIP2_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIR}") From 8678632dc86f7a457015dd2736a6e2d81fd68499 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 27 May 2019 13:16:37 -0500 Subject: [PATCH 4/5] Revert more unwanted cmake changes --- cpp/cmake_modules/FindLLVM.cmake | 2 +- cpp/src/gandiva/precompiled/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake_modules/FindLLVM.cmake b/cpp/cmake_modules/FindLLVM.cmake index 13989f2b5d09..bef45085de89 100644 --- a/cpp/cmake_modules/FindLLVM.cmake +++ b/cpp/cmake_modules/FindLLVM.cmake @@ -78,7 +78,7 @@ else() endif() endif() -add_library(LLVM::LLVM_INTERFACE IMPORTED INTERFACE) +add_library(LLVM::LLVM_INTERFACE INTERFACE IMPORTED) set_target_properties(LLVM::LLVM_INTERFACE PROPERTIES INTERFACE_INCLUDE_DIRECTORIES diff --git a/cpp/src/gandiva/precompiled/CMakeLists.txt b/cpp/src/gandiva/precompiled/CMakeLists.txt index 178e2c08cf58..cfd1e88a894e 100644 --- a/cpp/src/gandiva/precompiled/CMakeLists.txt +++ b/cpp/src/gandiva/precompiled/CMakeLists.txt @@ -104,7 +104,7 @@ function(add_precompiled_unit_test REL_TEST_NAME) set(TEST_NAME "gandiva-precompiled-${TEST_NAME}") - add_executable(${TEST_NAME} ${ARGN} ${REL_TEST_NAME}) + add_executable(${TEST_NAME} ${REL_TEST_NAME} ${ARGN}) target_include_directories(${TEST_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src) target_link_libraries(${TEST_NAME} PRIVATE ${ARROW_TEST_LINK_LIBS} RE2::re2) target_compile_definitions(${TEST_NAME} From 515f75b09d0612b9649406a2fa2b2197ab3c157e Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Thu, 30 May 2019 12:36:32 -0500 Subject: [PATCH 5/5] Only set GTest_SOURCE to BUNDLED on MSVC if not passed explicitly --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 33dfc3b8850e..cd9f61f56297 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -63,7 +63,7 @@ set(ARROW_THIRDPARTY_DEPENDENCIES # supported when building with MSVC because of the way that # conda-forge packages have 4 variants of the libraries packaged # together -if(MSVC) +if(MSVC AND "${GTest_SOURCE}" STREQUAL "") set(GTest_SOURCE "BUNDLED") endif()