Skip to content

Commit

Permalink
ARROW-7929: [C++] Align CMake target names to upstreams
Browse files Browse the repository at this point in the history
Closes #6480 from tobim/ARROW-7929 and squashes the following commits:

eca5563 <Tobias Mayer> Explicitly use module mode to find LLVM
2f40e3b <Tobias Mayer> Align CMake target names to upstreams

Authored-by: Tobias Mayer <tobim@fastmail.fm>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
tobim authored and kou committed Feb 26, 2020
1 parent 4aded1d commit 396861b
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 78 deletions.
12 changes: 6 additions & 6 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,9 @@ if(ARROW_ORC)
endif()

if(ARROW_USE_GLOG)
list(APPEND ARROW_LINK_LIBS GLOG::glog)
list(APPEND ARROW_STATIC_LINK_LIBS GLOG::glog)
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS GLOG::glog)
list(APPEND ARROW_LINK_LIBS glog::glog)
list(APPEND ARROW_STATIC_LINK_LIBS glog::glog)
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS glog::glog)
add_definitions("-DARROW_USE_GLOG")
endif()

Expand Down Expand Up @@ -707,9 +707,9 @@ if(NOT MSVC)
endif()

set(ARROW_TEST_LINK_TOOLCHAIN
GTest::Main
GTest::GTest
GTest::GMock
GTest::gtest_main
GTest::gtest
GTest::gmock
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_SYSTEM_LIBRARY})

Expand Down
4 changes: 2 additions & 2 deletions cpp/cmake_modules/FindGLOG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ endif()
find_package_handle_standard_args(GLOG REQUIRED_VARS GLOG_INCLUDE_DIR GLOG_LIB)

if(GLOG_FOUND)
add_library(GLOG::glog UNKNOWN IMPORTED)
set_target_properties(GLOG::glog
add_library(glog::glog UNKNOWN IMPORTED)
set_target_properties(glog::glog
PROPERTIES IMPORTED_LOCATION "${GLOG_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIR}")
endif()
54 changes: 27 additions & 27 deletions cpp/cmake_modules/FindGTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ Imported targets

This module defines the following :prop_tgt:`IMPORTED` targets:

``GTest::GTest``
``GTest::gtest``
The Google Test ``gtest`` library, if found; adds Thread::Thread
automatically
``GTest::Main``
``GTest::gtest_main``
The Google Test ``gtest_main`` library, if found
``GMock::GMock``
``GTest::gmock``
The Google Mock ``gmock`` library, if found


Expand Down Expand Up @@ -80,7 +80,7 @@ Example usage
find_package(GTest REQUIRED)

add_executable(foo foo.cc)
target_link_libraries(foo GTest::GTest GTest::Main)
target_link_libraries(foo GTest::gtest GTest::gtest_main)

add_test(AllTestsInFoo foo)

Expand Down Expand Up @@ -228,51 +228,51 @@ if(GTEST_FOUND)

find_package(Threads QUIET)

if(NOT TARGET GTest::GTest)
if(NOT TARGET GTest::gtest)
__gtest_determine_library_type(GTEST_LIBRARY)
add_library(GTest::GTest ${GTEST_LIBRARY_TYPE} IMPORTED)
add_library(GTest::gtest ${GTEST_LIBRARY_TYPE} IMPORTED)
if(TARGET Threads::Threads)
set_target_properties(GTest::GTest PROPERTIES
set_target_properties(GTest::gtest PROPERTIES
INTERFACE_LINK_LIBRARIES Threads::Threads)
endif()
if(GTEST_LIBRARY_TYPE STREQUAL "SHARED")
set_target_properties(GTest::GTest PROPERTIES
set_target_properties(GTest::gtest PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
endif()
if(GTEST_INCLUDE_DIRS)
set_target_properties(GTest::GTest PROPERTIES
set_target_properties(GTest::gtest PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIRS}")
endif()
__gtest_import_library(GTest::GTest GTEST_LIBRARY "")
__gtest_import_library(GTest::GTest GTEST_LIBRARY "RELEASE")
__gtest_import_library(GTest::GTest GTEST_LIBRARY "DEBUG")
__gtest_import_library(GTest::gtest GTEST_LIBRARY "")
__gtest_import_library(GTest::gtest GTEST_LIBRARY "RELEASE")
__gtest_import_library(GTest::gtest GTEST_LIBRARY "DEBUG")
endif()
if(NOT TARGET GTest::Main)
if(NOT TARGET GTest::gtest_main)
__gtest_determine_library_type(GTEST_MAIN_LIBRARY)
add_library(GTest::Main ${GTEST_MAIN_LIBRARY_TYPE} IMPORTED)
set_target_properties(GTest::Main PROPERTIES
INTERFACE_LINK_LIBRARIES "GTest::GTest")
__gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "")
__gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "RELEASE")
__gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "DEBUG")
add_library(GTest::gtest_main ${GTEST_MAIN_LIBRARY_TYPE} IMPORTED)
set_target_properties(GTest::gtest_main PROPERTIES
INTERFACE_LINK_LIBRARIES "GTest::gtest")
__gtest_import_library(GTest::gtest_main GTEST_MAIN_LIBRARY "")
__gtest_import_library(GTest::gtest_main GTEST_MAIN_LIBRARY "RELEASE")
__gtest_import_library(GTest::gtest_main GTEST_MAIN_LIBRARY "DEBUG")
endif()
if(NOT TARGET GTest::GMock)
if(NOT TARGET GTest::gmock)
__gtest_determine_library_type(GMOCK_LIBRARY)
add_library(GTest::GMock ${GMOCK_LIBRARY_TYPE} IMPORTED)
add_library(GTest::gmock ${GMOCK_LIBRARY_TYPE} IMPORTED)
if(TARGET Threads::Threads)
set_target_properties(GTest::GMock PROPERTIES
set_target_properties(GTest::gmock PROPERTIES
INTERFACE_LINK_LIBRARIES Threads::Threads)
endif()
if(GMOCK_LIBRARY_TYPE STREQUAL "SHARED")
set_target_properties(GTest::GMock PROPERTIES
set_target_properties(GTest::gmock PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
endif()
if(GTEST_INCLUDE_DIRS)
set_target_properties(GTest::GMock PROPERTIES
set_target_properties(GTest::gmock PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIRS}")
endif()
__gtest_import_library(GTest::GMock GMOCK_LIBRARY "")
__gtest_import_library(GTest::GMock GMOCK_LIBRARY "RELEASE")
__gtest_import_library(GTest::GMock GMOCK_LIBRARY "DEBUG")
__gtest_import_library(GTest::gmock GMOCK_LIBRARY "")
__gtest_import_library(GTest::gmock GMOCK_LIBRARY "RELEASE")
__gtest_import_library(GTest::gmock GMOCK_LIBRARY "DEBUG")
endif()
endif()
6 changes: 3 additions & 3 deletions cpp/cmake_modules/FindThrift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ find_package_handle_standard_args(Thrift

if(Thrift_FOUND OR THRIFT_FOUND)
set(Thrift_FOUND TRUE)
add_library(Thrift::thrift STATIC IMPORTED)
set_target_properties(Thrift::thrift
add_library(thrift::thrift STATIC IMPORTED)
set_target_properties(thrift::thrift
PROPERTIES IMPORTED_LOCATION "${THRIFT_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${THRIFT_INCLUDE_DIR}")
if(WIN32 AND NOT MSVC)
# 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++.
set_target_properties(Thrift::thrift PROPERTIES INTERFACE_LINK_LIBRARIES "ws2_32")
set_target_properties(thrift::thrift PROPERTIES INTERFACE_LINK_LIBRARIES "ws2_32")
endif()
endif()
34 changes: 17 additions & 17 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -910,17 +910,17 @@ macro(build_glog)
add_dependencies(toolchain glog_ep)
file(MAKE_DIRECTORY "${GLOG_INCLUDE_DIR}")

add_library(GLOG::glog STATIC IMPORTED)
set_target_properties(GLOG::glog
add_library(glog::glog STATIC IMPORTED)
set_target_properties(glog::glog
PROPERTIES IMPORTED_LOCATION "${GLOG_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIR}")
add_dependencies(GLOG::glog glog_ep)
add_dependencies(glog::glog glog_ep)
endmacro()

if(ARROW_USE_GLOG)
resolve_dependency(GLOG)
# TODO: Don't use global includes but rather target_include_directories
get_target_property(GLOG_INCLUDE_DIR GLOG::glog INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(GLOG_INCLUDE_DIR glog::glog INTERFACE_INCLUDE_DIRECTORIES)
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
endif()

Expand Down Expand Up @@ -1142,14 +1142,14 @@ macro(build_thrift)
CMAKE_ARGS ${THRIFT_CMAKE_ARGS}
DEPENDS ${THRIFT_DEPENDENCIES} ${EP_LOG_OPTIONS})

add_library(Thrift::thrift STATIC IMPORTED)
add_library(thrift::thrift STATIC IMPORTED)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${THRIFT_INCLUDE_DIR}")
set_target_properties(Thrift::thrift
set_target_properties(thrift::thrift
PROPERTIES IMPORTED_LOCATION "${THRIFT_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${THRIFT_INCLUDE_DIR}")
add_dependencies(toolchain thrift_ep)
add_dependencies(Thrift::thrift thrift_ep)
add_dependencies(thrift::thrift thrift_ep)
set(THRIFT_VERSION ${ARROW_THRIFT_BUILD_VERSION})
endmacro()

Expand Down Expand Up @@ -1504,24 +1504,24 @@ macro(build_gtest)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}")

add_library(GTest::GTest SHARED IMPORTED)
set_target_properties(GTest::GTest
add_library(GTest::gtest SHARED IMPORTED)
set_target_properties(GTest::gtest
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::Main SHARED IMPORTED)
set_target_properties(GTest::Main
add_library(GTest::gtest_main SHARED IMPORTED)
set_target_properties(GTest::gtest_main
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::GMock SHARED IMPORTED)
set_target_properties(GTest::GMock
add_library(GTest::gmock SHARED IMPORTED)
set_target_properties(GTest::gmock
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)
add_dependencies(GTest::Main googletest_ep)
add_dependencies(GTest::GMock googletest_ep)
add_dependencies(GTest::gtest googletest_ep)
add_dependencies(GTest::gtest_main googletest_ep)
add_dependencies(GTest::gmock googletest_ep)
endmacro()

if(ARROW_BUILD_TESTS
Expand Down Expand Up @@ -1559,7 +1559,7 @@ if(ARROW_BUILD_TESTS
# set(CMAKE_REQUIRED_LIBRARIES)
endif()

get_target_property(GTEST_INCLUDE_DIR GTest::GTest INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(GTEST_INCLUDE_DIR GTest::gtest INTERFACE_INCLUDE_DIRECTORIES)
# TODO: Don't use global includes but rather target_include_directories
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
endif()
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ if(ARROW_BUILD_TESTS
arrow_test_dependencies
SHARED_LINK_LIBS
arrow_shared
GTest::GTest
GTest::gtest
STATIC_LINK_LIBS
arrow_static)

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ install(FILES adapter.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/arrow/adapters/
arrow_add_pkg_config("arrow-orc")

set(ORC_MIN_TEST_LIBS
GTest::Main
GTest::GTest
GTest::gtest_main
GTest::gtest
Snappy::snappy
LZ4::lz4
ZLIB::ZLIB)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/dbi/hiveserver2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ set_property(SOURCE ${ARROW_HIVESERVER2_SRCS}
PROPERTY COMPILE_FLAGS " -Wno-shadow-field")

set(ARROW_HIVESERVER2_TEST_LINK_LIBS arrow_hiveserver2_static arrow_hiveserver2_thrift
${ARROW_TEST_LINK_LIBS} Thrift::thrift)
${ARROW_TEST_LINK_LIBS} thrift::thrift)

if(ARROW_BUILD_TESTS)
add_test_case(hiveserver2_test
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(ARROW_S3)
if(ARROW_BUILD_TESTS)
add_executable(arrow-s3fs-narrative-test s3fs_narrative_test.cc)
target_link_libraries(arrow-s3fs-narrative-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
${GFLAGS_LIBRARIES} GTest::gtest)
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()
endif()
Expand Down
14 changes: 7 additions & 7 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS OR ARROW_BUILD_INTEGRATION)
SOURCES
test_util.cc
DEPENDENCIES
GTest::GTest
GTest::gtest
flight_grpc_gen
arrow_dependencies
SHARED_LINK_LIBS
Expand All @@ -130,7 +130,7 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS OR ARROW_BUILD_INTEGRATION)
arrow_testing_shared
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_SYSTEM_LIBRARY}
GTest::GTest
GTest::gtest
STATIC_LINK_LIBS
arrow_static
arrow_flight_static
Expand All @@ -151,7 +151,7 @@ add_arrow_test(flight_test
if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
add_executable(flight-test-server test_server.cc)
target_link_libraries(flight-test-server ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
${GFLAGS_LIBRARIES} GTest::gtest)

if(ARROW_BUILD_TESTS)
add_dependencies(arrow-flight-test flight-test-server)
Expand All @@ -163,11 +163,11 @@ endif()
if(ARROW_BUILD_INTEGRATION)
add_executable(flight-test-integration-server test_integration_server.cc)
target_link_libraries(flight-test-integration-server ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
${GFLAGS_LIBRARIES} GTest::gtest)

add_executable(flight-test-integration-client test_integration_client.cc)
target_link_libraries(flight-test-integration-client ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
${GFLAGS_LIBRARIES} GTest::gtest)

add_dependencies(arrow_flight flight-test-integration-client
flight-test-integration-server)
Expand All @@ -187,11 +187,11 @@ if(ARROW_BUILD_BENCHMARKS)

add_executable(arrow-flight-perf-server perf_server.cc perf.pb.cc)
target_link_libraries(arrow-flight-perf-server ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
${GFLAGS_LIBRARIES} GTest::gtest)

add_executable(arrow-flight-benchmark flight_benchmark.cc perf.pb.cc)
target_link_libraries(arrow-flight-benchmark ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
${GFLAGS_LIBRARIES} GTest::gtest)

add_dependencies(arrow-flight-benchmark arrow-flight-perf-server)

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ endif()

if(ARROW_BUILD_BENCHMARKS)
cuda_add_executable(arrow-cuda-benchmark cuda_benchmark.cc)
target_link_libraries(arrow-cuda-benchmark arrow_cuda_shared GTest::GTest
target_link_libraries(arrow-cuda-benchmark arrow_cuda_shared GTest::gtest
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-cuda-benchmark)
endif()
2 changes: 1 addition & 1 deletion cpp/src/arrow/ipc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if(ARROW_BUILD_TESTS)
elseif(ARROW_BUILD_INTEGRATION)
add_executable(arrow-json-integration-test json_integration_test.cc)
target_link_libraries(arrow-json-integration-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::GTest)
${GFLAGS_LIBRARIES} GTest::gtest)

add_dependencies(arrow-json-integration-test arrow arrow_testing)
add_dependencies(arrow-integration arrow-json-integration-test)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ arrow_install_all_headers("arrow/python")
if(ARROW_BUILD_TESTS)
add_library(arrow_python_test_main STATIC util/test_main.cc)

target_link_libraries(arrow_python_test_main GTest::GTest)
target_link_libraries(arrow_python_test_main GTest::gtest)
target_include_directories(arrow_python_test_main SYSTEM
PUBLIC ${ARROW_PYTHON_INCLUDES})

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/python/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ if(PYARROW_BUILD_TESTS)
add_library(arrow/python_test_main STATIC test_main.cc)

if(APPLE)
target_link_libraries(arrow/python_test_main GTest::GTest dl)
target_link_libraries(arrow/python_test_main GTest::gtest dl)
set_target_properties(arrow/python_test_main
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
target_link_libraries(arrow/python_test_main GTest::GTest pthread dl)
target_link_libraries(arrow/python_test_main GTest::gtest pthread dl)
endif()
endif()
5 changes: 4 additions & 1 deletion cpp/src/gandiva/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ add_dependencies(gandiva-all gandiva gandiva-tests gandiva-benchmarks)
if(ARROW_DEPENDENCY_SOURCE STREQUAL "CONDA")
set(LLVM_ROOT $ENV{CONDA_PREFIX})
endif()
find_package(LLVM)
# The semantics of the upstream configuration file are different from what is
# provided in our FindLLVM module, so the module is explicitly requested here to
# avoid a configuration error if CMAKE_FIND_PACKAGE_PREFER_CONFIG is enabled.
find_package(LLVM MODULE)

# Set the path where the bitcode file generated, see precompiled/CMakeLists.txt
set(GANDIVA_PRECOMPILED_BC_PATH "${CMAKE_CURRENT_BINARY_DIR}/irhelpers.bc")
Expand Down
Loading

0 comments on commit 396861b

Please sign in to comment.