mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 00:56:31 +08:00
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
This commit is contained in:
1 parent
64f2cc7986
commit
c83c7d6330
19 files changed
+125
-90
No files matched your search
@@ -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
|
||||
|
||||
+41
-32
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}"
|
||||
GTEST_MAIN_SHARED_LIB
|
||||
|
||||
"${GTEST_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}gtest_main${_GTEST_LIBRARY_SUFFIX}"
|
||||
)
|
||||
set(
|
||||
GTEST_MAIN_STATIC_LIB
|
||||
"${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_GTEST_DEBUG_EXTENSION}${CMAKE_STATIC_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}")
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
Reference in new issue
Block a user