You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/12/17 21:23:49 UTC

[arrow] branch master updated: ARROW-4026: [C++] Add *-all, *-tests, *-benchmarks modular CMake targets. Use in Travis CI

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 9fcce64  ARROW-4026: [C++] Add *-all, *-tests, *-benchmarks modular CMake targets. Use in Travis CI
9fcce64 is described below

commit 9fcce64e6108dd911c9cfcd4121ea33e2b447c91
Author: Wes McKinney <we...@apache.org>
AuthorDate: Mon Dec 17 15:23:42 2018 -0600

    ARROW-4026: [C++] Add *-all, *-tests, *-benchmarks modular CMake targets. Use in Travis CI
    
    This provides much more granular control over what targets are built. Before this patch `ninja arrow` would build all libraries _and_ tests if `ARROW_BUILD_TESTS=ON`. If you wanted to build the tests for a dependent target of the Arrow libraries, like Parquet or Plasma, you were forced to build the Arrow core unit tests.
    
    Now you can do
    
    ```
    ninja parquet-tests
    ```
    
    And it will only build the Arrow and Parquet libraries, and the tests labeled with "parquet-tests".
    
    Similarly this allows you to rebuild the libraries without necessarily having to relink all the unit tests (e.g. with `ninja arrow` or `ninja parquet`)
    
    Author: Wes McKinney <we...@apache.org>
    
    Closes #3204 from wesm/ARROW-4026 and squashes the following commits:
    
    1e41eee2d <Wes McKinney> Misc fixes, add missing toolchain dependency
    420282433 <Wes McKinney> Add *-all, *-tests, *-benchmarks modular build targets. Use in Travis CI
---
 .travis.yml                                  |  8 ++---
 ci/travis_before_script_cpp.sh               |  4 ---
 ci/travis_script_gandiva_cpp.sh              |  2 +-
 ci/travis_script_python.sh                   |  5 ++-
 cpp/CMakeLists.txt                           | 17 +++++----
 cpp/README.md                                |  8 +++--
 cpp/cmake_modules/BuildUtils.cmake           | 52 ++++++++++++----------------
 cpp/cmake_modules/ThirdpartyToolchain.cmake  | 30 ++++++----------
 cpp/src/arrow/CMakeLists.txt                 | 19 ++++++++--
 cpp/src/arrow/dbi/hiveserver2/CMakeLists.txt |  5 +--
 cpp/src/arrow/flight/CMakeLists.txt          |  1 -
 cpp/src/arrow/gpu/CMakeLists.txt             | 13 +++++--
 cpp/src/arrow/ipc/CMakeLists.txt             |  2 +-
 cpp/src/arrow/python/CMakeLists.txt          |  5 ++-
 cpp/src/gandiva/CMakeLists.txt               | 15 ++++----
 cpp/src/gandiva/jni/CMakeLists.txt           |  2 --
 cpp/src/gandiva/precompiled/CMakeLists.txt   |  2 +-
 cpp/src/parquet/CMakeLists.txt               | 25 ++++++++-----
 cpp/src/parquet/arrow/CMakeLists.txt         |  4 +--
 cpp/src/plasma/CMakeLists.txt                |  6 +++-
 20 files changed, 122 insertions(+), 103 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index d22a4e7..bf0261b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -112,9 +112,7 @@ matrix:
     - ARROW_TRAVIS_GANDIVA_JAVA=1
     - ARROW_TRAVIS_GANDIVA_TESTS=1
     - ARROW_TRAVIS_OPTIONAL_INSTALL=1
-    - ARROW_CPP_BUILD_TARGETS="gandiva"
-    # TODO(wesm): Remove this after ARROW-4026
-    - ARROW_TRAVIS_CPP_TEST_INCLUDE_LABELS="gandiva"
+    - ARROW_CPP_BUILD_TARGETS="gandiva-all"
     - ARROW_TRAVIS_USE_TOOLCHAIN=1
     # ARROW-3979 temporarily disabled.
     - ARROW_TRAVIS_VALGRIND=0
@@ -164,9 +162,7 @@ matrix:
     - ARROW_TRAVIS_GANDIVA_JAVA=1
     - ARROW_TRAVIS_GANDIVA_TESTS=1
     - ARROW_TRAVIS_OPTIONAL_INSTALL=1
-    - ARROW_CPP_BUILD_TARGETS="gandiva"
-    # TODO(wesm): Remove this after ARROW-4026
-    - ARROW_TRAVIS_CPP_TEST_INCLUDE_LABELS="gandiva"
+    - ARROW_CPP_BUILD_TARGETS="gandiva-all"
     - ARROW_TRAVIS_USE_TOOLCHAIN=1
     - ARROW_BUILD_WARNING_LEVEL=CHECKIN
     before_script:
diff --git a/ci/travis_before_script_cpp.sh b/ci/travis_before_script_cpp.sh
index 6cb7d60..aa5b2a6 100755
--- a/ci/travis_before_script_cpp.sh
+++ b/ci/travis_before_script_cpp.sh
@@ -42,7 +42,6 @@ fi
 
 CMAKE_COMMON_FLAGS="\
 -DCMAKE_INSTALL_PREFIX=$ARROW_CPP_INSTALL \
--DARROW_TEST_INCLUDE_LABELS=$ARROW_TRAVIS_CPP_TEST_INCLUDE_LABELS \
 -DARROW_NO_DEPRECATED_API=ON \
 -DARROW_EXTRA_ERROR_CONTEXT=ON"
 CMAKE_LINUX_FLAGS=""
@@ -102,9 +101,6 @@ if [ $ARROW_TRAVIS_GANDIVA == "1" ]; then
   if [ $ARROW_TRAVIS_GANDIVA_JAVA == "1" ]; then
       CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GANDIVA_JAVA=ON"
   fi
-  if [ $ARROW_TRAVIS_GANDIVA_TESTS == "1" ]; then
-    CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_BUILD_TESTS=ON"
-  fi
 fi
 
 if [ $ARROW_TRAVIS_VALGRIND == "1" ]; then
diff --git a/ci/travis_script_gandiva_cpp.sh b/ci/travis_script_gandiva_cpp.sh
index f3c3793..bc4a7a9 100755
--- a/ci/travis_script_gandiva_cpp.sh
+++ b/ci/travis_script_gandiva_cpp.sh
@@ -23,7 +23,7 @@ source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh
 
 pushd $CPP_BUILD_DIR
 
-PATH=$ARROW_BUILD_TYPE:$PATH ctest -j2 --output-on-failure -L gandiva
+PATH=$ARROW_BUILD_TYPE:$PATH ctest -j2 --output-on-failure -L gandiva-tests
 
 popd
 
diff --git a/ci/travis_script_python.sh b/ci/travis_script_python.sh
index b8385c3..20ec57e 100755
--- a/ci/travis_script_python.sh
+++ b/ci/travis_script_python.sh
@@ -87,21 +87,20 @@ rm -rf *
 # XXX Can we simply reuse CMAKE_COMMON_FLAGS from travis_before_script_cpp.sh?
 CMAKE_COMMON_FLAGS="-DARROW_EXTRA_ERROR_CONTEXT=ON"
 
-PYTHON_CPP_BUILD_TARGETS="arrow_python plasma"
+PYTHON_CPP_BUILD_TARGETS="arrow_python-all plasma"
 
 if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then
   CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GENERATE_COVERAGE=ON"
 fi
 
 if [ $ARROW_TRAVIS_PYTHON_GANDIVA == "1" ]; then
-  CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GANDIVA=ON -DARROW_GANDIVA_BUILD_TESTS=OFF"
+  CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GANDIVA=ON"
   PYTHON_CPP_BUILD_TARGETS="$PYTHON_CPP_BUILD_TARGETS gandiva"
 fi
 
 cmake -GNinja \
       $CMAKE_COMMON_FLAGS \
       -DARROW_BUILD_TESTS=ON \
-      -DARROW_TEST_INCLUDE_LABELS=python \
       -DARROW_BUILD_UTILITIES=OFF \
       -DARROW_OPTIONAL_INSTALL=ON \
       -DARROW_PLASMA=on \
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index f563199..60cbe85 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -333,10 +333,6 @@ Always OFF if building binaries"
   #----------------------------------------------------------------------
   # Advanced developer options
 
-  set(ARROW_TEST_INCLUDE_LABELS "" CACHE STRING
-    "Only build unit tests having the indicated label or labels. \
-Pass multiple labels by dividing with semicolons")
-
   option(ARROW_EXTRA_ERROR_CONTEXT
     "Compile with extra error context (line numbers, code)"
     OFF)
@@ -466,10 +462,18 @@ endif()
 
 if(NOT ARROW_BUILD_TESTS)
   set(NO_TESTS 1)
+else()
+  add_custom_target(all-tests)
+  add_custom_target(unittest ctest -L unittest)
+  add_dependencies(unittest all-tests)
 endif()
 
 if(NOT ARROW_BUILD_BENCHMARKS)
   set(NO_BENCHMARKS 1)
+else()
+  add_custom_target(all-benchmarks)
+  add_custom_target(benchmark ctest -L benchmark)
+  add_dependencies(benchmark all-benchmarks)
 endif()
 
 if(NOT ARROW_BUILD_EXAMPLES)
@@ -516,8 +520,6 @@ include(SetupCxxFlags)
 # Dependencies
 ############################################################
 
-add_custom_target(arrow_dependencies)
-
 include(BuildUtils)
 enable_testing()
 
@@ -712,6 +714,9 @@ if (ARROW_USE_GLOG)
   add_definitions("-DARROW_USE_GLOG")
 endif()
 
+add_custom_target(arrow_dependencies)
+add_dependencies(arrow_dependencies toolchain)
+
 if (ARROW_STATIC_LINK_LIBS)
   add_dependencies(arrow_dependencies ${ARROW_STATIC_LINK_LIBS})
 endif()
diff --git a/cpp/README.md b/cpp/README.md
index a94c4be..5940db1 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -105,14 +105,18 @@ export LC_ALL="en_US.UTF-8"
 ## Modular Build Targets
 
 Since there are several major parts of the C++ project, we have provided
-modular CMake targets for building each component along with its dependencies,
-unit tests, and benchmarks (if enabled):
+modular CMake targets for building each library component, group of unit tests
+and benchmarks, and their dependencies:
 
 * `make arrow` for Arrow core libraries
 * `make parquet` for Parquet libraries
 * `make gandiva` for Gandiva (LLVM expression compiler) libraries
 * `make plasma` for Plasma libraries, server
 
+To build the unit tests or benchmarks, add `-tests` or `-benchmarks` to the
+target name. So `make arrow-tests` will build the Arrow core unit tests. Using
+the `-all` target, e.g. `parquet-all`, will build everything.
+
 If you wish to only build and install one or more project subcomponents, we
 have provided the CMake option `ARROW_OPTIONAL_INSTALL` to only install targets
 that have been built. For example, if you only wish to build the Parquet
diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 812d0c3..7c1db67 100644
--- a/cpp/cmake_modules/BuildUtils.cmake
+++ b/cpp/cmake_modules/BuildUtils.cmake
@@ -308,6 +308,9 @@ endfunction()
 # \arg PREFIX a string to append to the name of the benchmark executable. For
 # example, if you have src/arrow/foo/bar-benchmark.cc, then PREFIX "foo" will
 # create test executable foo-bar-benchmark
+# \arg LABELS the benchmark label or labels to assign the unit tests to. By
+# default, benchmarks will go in the "benchmark" group. Custom targets for the
+# group names must exist
 function(ADD_BENCHMARK REL_BENCHMARK_NAME)
   set(options)
   set(one_value_args)
@@ -343,20 +346,22 @@ function(ADD_BENCHMARK REL_BENCHMARK_NAME)
     set(NO_COLOR "")
   endif()
 
+  # Add test as dependency of relevant label targets
+  add_dependencies(all-benchmarks ${BENCHMARK_NAME})
+  foreach (TARGET ${ARG_LABELS})
+    add_dependencies(${TARGET} ${BENCHMARK_NAME})
+  endforeach()
+
   if (ARG_DEPENDENCIES)
     add_dependencies(${BENCHMARK_NAME} ${ARG_DEPENDENCIES})
   endif()
 
   if (ARG_LABELS)
-    set(ARG_LABELS "${ARG_LABELS}")
+    set(ARG_LABELS "benchmark;${ARG_LABELS}")
   else()
     set(ARG_LABELS benchmark)
   endif()
 
-  foreach (TEST_LABEL ${ARG_LABELS})
-    add_dependencies(${TEST_LABEL} ${BENCHMARK_NAME})
-  endforeach()
-
   add_test(${BENCHMARK_NAME}
     ${BUILD_SUPPORT_DIR}/run-test.sh ${CMAKE_BINARY_DIR} benchmark ${BENCHMARK_PATH} ${NO_COLOR})
   set_property(TEST ${BENCHMARK_NAME}
@@ -389,7 +394,7 @@ endfunction()
 # \arg LABELS the unit test label or labels to assign the unit tests
 # to. By default, unit tests will go in the "unittest" group, but if we have
 # multiple unit tests in some subgroup, you can assign a test to multiple
-# groups using the syntax unittest;GROUP2;GROUP3. Custom targets for the group
+# groups use the syntax unittest;GROUP2;GROUP3. Custom targets for the group
 # names must exist
 function(ADD_TEST_CASE REL_TEST_NAME)
   set(options NO_VALGRIND ENABLED)
@@ -401,18 +406,6 @@ function(ADD_TEST_CASE REL_TEST_NAME)
     message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}")
   endif()
 
-  if (NOT "${ARROW_TEST_INCLUDE_LABELS}" STREQUAL "")
-    set(_SKIP_TEST TRUE)
-    foreach (_INCLUDED_LABEL ${ARROW_TEST_INCLUDE_LABELS})
-      if ("${ARG_LABELS}" MATCHES "${_INCLUDED_LABEL}")
-        set(_SKIP_TEST FALSE)
-      endif()
-    endforeach()
-    if (_SKIP_TEST)
-      return()
-    endif()
-  endif()
-
   if (NO_TESTS AND NOT ARG_ENABLED)
     return()
   endif()
@@ -422,12 +415,6 @@ function(ADD_TEST_CASE REL_TEST_NAME)
     set(TEST_NAME "${ARG_PREFIX}-${TEST_NAME}")
   endif()
 
-  if (ARG_LABELS)
-    set(ARG_LABELS "${ARG_LABELS}")
-  else()
-    set(ARG_LABELS unittest)
-  endif()
-
   if (ARG_SOURCES)
     set(SOURCES ${ARG_SOURCES})
   else()
@@ -458,10 +445,6 @@ function(ADD_TEST_CASE REL_TEST_NAME)
     add_dependencies(${TEST_NAME} ${ARG_EXTRA_DEPENDENCIES})
   endif()
 
-  foreach (TEST_LABEL ${ARG_LABELS})
-    add_dependencies(${TEST_LABEL} ${TEST_NAME})
-  endforeach()
-
   if (ARROW_TEST_MEMCHECK AND NOT ARG_NO_VALGRIND)
     SET_PROPERTY(TARGET ${TEST_NAME}
       APPEND_STRING PROPERTY
@@ -477,6 +460,18 @@ function(ADD_TEST_CASE REL_TEST_NAME)
       ${BUILD_SUPPORT_DIR}/run-test.sh ${CMAKE_BINARY_DIR} test ${TEST_PATH})
   endif()
 
+  # Add test as dependency of relevant targets
+  add_dependencies(all-tests ${TEST_NAME})
+  foreach (TARGET ${ARG_LABELS})
+    add_dependencies(${TARGET} ${TEST_NAME})
+  endforeach()
+
+  if (ARG_LABELS)
+    set(ARG_LABELS "unittest;${ARG_LABELS}")
+  else()
+    set(ARG_LABELS unittest)
+  endif()
+
   set_property(TEST ${TEST_NAME}
     APPEND PROPERTY
     LABELS ${ARG_LABELS})
@@ -537,7 +532,6 @@ function(ADD_ARROW_EXAMPLE REL_EXAMPLE_NAME)
     add_dependencies(${EXAMPLE_NAME} ${ARG_DEPENDENCIES})
   endif()
 
-
   add_test(${EXAMPLE_NAME} ${EXAMPLE_PATH})
   set_tests_properties(${EXAMPLE_NAME} PROPERTIES LABELS "example")
 endfunction()
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index c007b1c..d493de7 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -15,6 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
+add_custom_target(toolchain)
+
 # ----------------------------------------------------------------------
 # Toolchain linkage options
 
@@ -401,7 +403,7 @@ if (ARROW_BOOST_VENDORED)
     ${EP_LOG_OPTIONS})
   set(Boost_INCLUDE_DIR "${BOOST_PREFIX}")
   set(Boost_INCLUDE_DIRS "${BOOST_INCLUDE_DIR}")
-  add_dependencies(arrow_dependencies boost_ep)
+  add_dependencies(toolchain boost_ep)
 else()
   if (MSVC)
     # disable autolinking in boost
@@ -506,15 +508,14 @@ if("${DOUBLE_CONVERSION_HOME}" STREQUAL "")
     CMAKE_ARGS ${DOUBLE_CONVERSION_CMAKE_ARGS}
     BUILD_BYPRODUCTS "${DOUBLE_CONVERSION_STATIC_LIB}")
   set(DOUBLE_CONVERSION_VENDORED 1)
+  add_dependencies(toolchain double-conversion_ep)
 else()
   find_package(double-conversion REQUIRED
     PATHS "${DOUBLE_CONVERSION_HOME}")
   set(DOUBLE_CONVERSION_VENDORED 0)
 endif()
 
-if (DOUBLE_CONVERSION_VENDORED)
-  add_dependencies(arrow_dependencies double-conversion_ep)
-else()
+if (NOT DOUBLE_CONVERSION_VENDORED)
   get_property(DOUBLE_CONVERSION_STATIC_LIB TARGET double-conversion::double-conversion
     PROPERTY LOCATION)
   get_property(DOUBLE_CONVERSION_INCLUDE_DIR TARGET double-conversion::double-conversion
@@ -532,9 +533,6 @@ message(STATUS "double-conversion static library: ${DOUBLE_CONVERSION_STATIC_LIB
 # ----------------------------------------------------------------------
 # Google gtest & gflags
 
-add_custom_target(unittest ctest -L unittest)
-add_custom_target(benchmark ctest -L benchmark)
-
 if(ARROW_BUILD_TESTS OR ARROW_GANDIVA_BUILD_TESTS
    OR ARROW_BUILD_BENCHMARKS)
   if("${GTEST_HOME}" STREQUAL "")
@@ -699,6 +697,7 @@ if (ARROW_IPC)
     ExternalProject_Get_Property(rapidjson_ep SOURCE_DIR)
     set(RAPIDJSON_INCLUDE_DIR "${SOURCE_DIR}/include")
     set(RAPIDJSON_VENDORED 1)
+    add_dependencies(toolchain rapidjson_ep)
   else()
     set(RAPIDJSON_INCLUDE_DIR "${RAPIDJSON_HOME}/include")
     set(RAPIDJSON_VENDORED 0)
@@ -706,10 +705,6 @@ if (ARROW_IPC)
   message(STATUS "RapidJSON include dir: ${RAPIDJSON_INCLUDE_DIR}")
   include_directories(SYSTEM ${RAPIDJSON_INCLUDE_DIR})
 
-  if(RAPIDJSON_VENDORED)
-    add_dependencies(arrow_dependencies rapidjson_ep)
-  endif()
-
   ## Flatbuffers
   if("${FLATBUFFERS_HOME}" STREQUAL "")
     set(FLATBUFFERS_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/flatbuffers_ep-prefix/src/flatbuffers_ep-install")
@@ -733,15 +728,12 @@ if (ARROW_IPC)
     set(FLATBUFFERS_INCLUDE_DIR "${FLATBUFFERS_PREFIX}/include")
     set(FLATBUFFERS_COMPILER "${FLATBUFFERS_PREFIX}/bin/flatc")
     set(FLATBUFFERS_VENDORED 1)
+    add_dependencies(toolchain flatbuffers_ep)
   else()
     find_package(Flatbuffers REQUIRED)
     set(FLATBUFFERS_VENDORED 0)
   endif()
 
-  if(FLATBUFFERS_VENDORED)
-    add_dependencies(arrow_dependencies flatbuffers_ep)
-  endif()
-
   message(STATUS "Flatbuffers include dir: ${FLATBUFFERS_INCLUDE_DIR}")
   message(STATUS "Flatbuffers compiler: ${FLATBUFFERS_COMPILER}")
   include_directories(SYSTEM ${FLATBUFFERS_INCLUDE_DIR})
@@ -1155,6 +1147,7 @@ if (ARROW_GANDIVA)
       CMAKE_ARGS ${RE2_CMAKE_ARGS}
       BUILD_BYPRODUCTS "${RE2_STATIC_LIB}")
     set (RE2_VENDORED 1)
+    add_dependencies(toolchain re2_ep)
   else ()
     find_package (RE2 REQUIRED)
     set (RE2_VENDORED 0)
@@ -1171,10 +1164,6 @@ if (ARROW_GANDIVA)
       STATIC_LIB ${RE2_STATIC_LIB})
     set(RE2_LIBRARY re2_static)
   endif()
-
-  if (RE2_VENDORED)
-    add_dependencies (arrow_dependencies re2_ep)
-  endif ()
 endif ()
 
 
@@ -1317,6 +1306,8 @@ if (ARROW_ORC)
       CMAKE_ARGS ${ORC_CMAKE_ARGS}
       ${EP_LOG_OPTIONS})
 
+    add_dependencies(toolchain orc_ep)
+
     set(ORC_VENDORED 1)
     add_dependencies(orc_ep ${ZLIB_LIBRARY})
     if (LZ4_VENDORED)
@@ -1342,7 +1333,6 @@ if (ARROW_ORC)
   if (ORC_VENDORED)
     add_dependencies(orc_static orc_ep)
   endif()
-
 endif()
 
 # ----------------------------------------------------------------------
diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt
index 9291add..8dd2ac0 100644
--- a/cpp/src/arrow/CMakeLists.txt
+++ b/cpp/src/arrow/CMakeLists.txt
@@ -15,13 +15,17 @@
 # specific language governing permissions and limitations
 # under the License.
 
+add_custom_target(arrow-all)
 add_custom_target(arrow)
+add_custom_target(arrow-benchmarks)
+add_custom_target(arrow-tests)
+add_dependencies(arrow-all arrow arrow-tests arrow-benchmarks)
 
 # Adding unit tests part of the "arrow" portion of the test suite
 function(ADD_ARROW_TEST REL_TEST_NAME)
   set(options)
   set(one_value_args PREFIX)
-  set(multi_value_args)
+  set(multi_value_args LABELS)
   cmake_parse_arguments(ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
 
   if (ARG_PREFIX)
@@ -29,9 +33,16 @@ function(ADD_ARROW_TEST REL_TEST_NAME)
   else()
     set(PREFIX "arrow")
   endif()
+
+  if (ARG_LABELS)
+    set(LABELS ${ARG_LABELS})
+  else()
+    set(LABELS "arrow-tests")
+  endif()
+
   ADD_TEST_CASE(${REL_TEST_NAME}
     PREFIX ${PREFIX}
-    LABELS "unittest;arrow"
+    LABELS ${LABELS}
     ${ARG_UNPARSED_ARGUMENTS})
 endfunction()
 
@@ -47,7 +58,7 @@ function(ADD_ARROW_BENCHMARK REL_TEST_NAME)
   endif()
   ADD_BENCHMARK(${REL_TEST_NAME}
     PREFIX ${PREFIX}
-    LABELS "benchmark;arrow"
+    LABELS "arrow-benchmarks"
     ${ARG_UNPARSED_ARGUMENTS})
 endfunction()
 
@@ -215,6 +226,8 @@ ADD_ARROW_LIB(arrow
   SHARED_PRIVATE_LINK_LIBS ${ARROW_SHARED_PRIVATE_LINK_LIBS}
   STATIC_LINK_LIBS ${ARROW_STATIC_LINK_LIBS})
 
+add_dependencies(arrow ${ARROW_LIBRARIES})
+
 if (ARROW_BUILD_STATIC AND WIN32)
   target_compile_definitions(arrow_static PUBLIC ARROW_STATIC)
 endif()
diff --git a/cpp/src/arrow/dbi/hiveserver2/CMakeLists.txt b/cpp/src/arrow/dbi/hiveserver2/CMakeLists.txt
index 9fd7f92..d2640a6 100644
--- a/cpp/src/arrow/dbi/hiveserver2/CMakeLists.txt
+++ b/cpp/src/arrow/dbi/hiveserver2/CMakeLists.txt
@@ -16,6 +16,7 @@
 # under the License.
 
 add_custom_target(arrow_hiveserver2)
+add_custom_target(arrow_hiveserver2-tests)
 
 # Headers: top level
 ARROW_INSTALL_ALL_HEADERS("arrow/dbi/hiveserver2")
@@ -103,9 +104,9 @@ set(ARROW_HIVESERVER2_TEST_LINK_LIBS
   thriftstatic)
 
 if (ARROW_BUILD_TESTS)
-  ADD_ARROW_TEST(hiveserver2-test
+  ADD_TEST_CASE(hiveserver2-test
     STATIC_LINK_LIBS "${ARROW_HIVESERVER2_TEST_LINK_LIBS}"
-    LABELS "arrow_hiveserver2"
+    LABELS "arrow_hiveserver2-tests"
   )
   if (TARGET arrow-hiveserver2-test)
     set_property(TARGET arrow-hiveserver2-test
diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt
index aa56269..2feaee1 100644
--- a/cpp/src/arrow/flight/CMakeLists.txt
+++ b/cpp/src/arrow/flight/CMakeLists.txt
@@ -75,7 +75,6 @@ set(ARROW_FLIGHT_SRCS
 
 ADD_ARROW_LIB(arrow_flight
   SOURCES ${ARROW_FLIGHT_SRCS}
-  DEPENDENCIES arrow_dependencies
   SHARED_LINK_LIBS arrow_shared ${ARROW_FLIGHT_STATIC_LINK_LIBS}
   STATIC_LINK_LIBS arrow_static ${ARROW_FLIGHT_STATIC_LINK_LIBS})
 
diff --git a/cpp/src/arrow/gpu/CMakeLists.txt b/cpp/src/arrow/gpu/CMakeLists.txt
index 8b69c65..2fcdf23 100644
--- a/cpp/src/arrow/gpu/CMakeLists.txt
+++ b/cpp/src/arrow/gpu/CMakeLists.txt
@@ -19,6 +19,12 @@
 # arrow_cuda
 #######################################
 
+add_custom_target(arrow_cuda-all)
+add_custom_target(arrow_cuda)
+add_custom_target(arrow_cuda-benchmarks)
+add_custom_target(arrow_cuda-tests)
+add_dependencies(arrow_cuda-all arrow_cuda arrow_cuda-tests arrow_cuda-benchmarks)
+
 if (DEFINED ENV{CUDA_HOME})
   set(CUDA_TOOLKIT_ROOT_DIR "$ENV{CUDA_HOME}")
 endif()
@@ -49,6 +55,8 @@ ADD_ARROW_LIB(arrow_cuda
   STATIC_LINK_LIBS ${ARROW_CUDA_SHARED_LINK_LIBS}
 )
 
+add_dependencies(arrow_cuda ${ARROW_CUDA_LIBRARIES})
+
 foreach(LIB_TARGET ${ARROW_CUDA_LIBRARIES})
   target_compile_definitions(${LIB_TARGET}
     PRIVATE ARROW_EXPORTING)
@@ -77,9 +85,10 @@ if (ARROW_BUILD_TESTS)
 endif()
 
 if (ARROW_BUILD_BENCHMARKS)
-  cuda_add_executable(cuda-benchmark cuda-benchmark.cc)
-  target_link_libraries(cuda-benchmark
+  cuda_add_executable(arrow-cuda-benchmark cuda-benchmark.cc)
+  target_link_libraries(arrow-cuda-benchmark
     arrow_cuda_shared
     gtest_static
     ${ARROW_BENCHMARK_LINK_LIBS})
+  add_dependencies(arrow_cuda-benchmarks arrow-cuda-benchmark)
 endif()
diff --git a/cpp/src/arrow/ipc/CMakeLists.txt b/cpp/src/arrow/ipc/CMakeLists.txt
index c44f7b9..422e72e 100644
--- a/cpp/src/arrow/ipc/CMakeLists.txt
+++ b/cpp/src/arrow/ipc/CMakeLists.txt
@@ -17,7 +17,7 @@
 
 # Targets required for protocol integration testing
 add_custom_target(integration)
-add_dependencies(arrow integration)
+add_dependencies(arrow-tests integration)
 
 #######################################
 # Messaging and interprocess communication
diff --git a/cpp/src/arrow/python/CMakeLists.txt b/cpp/src/arrow/python/CMakeLists.txt
index 98c105a..cccbf09 100644
--- a/cpp/src/arrow/python/CMakeLists.txt
+++ b/cpp/src/arrow/python/CMakeLists.txt
@@ -22,7 +22,10 @@
 find_package(PythonLibsNew REQUIRED)
 find_package(NumPy REQUIRED)
 
+add_custom_target(arrow_python-all)
 add_custom_target(arrow_python)
+add_custom_target(arrow_python-tests)
+add_dependencies(arrow_python-all arrow_python arrow_python-tests)
 
 set(ARROW_PYTHON_SRCS
   arrow_to_pandas.cc
@@ -130,6 +133,6 @@ if (ARROW_BUILD_TESTS)
     STATIC_LINK_LIBS "${ARROW_PYTHON_TEST_LINK_LIBS}"
     EXTRA_LINK_LIBS ${PYTHON_LIBRARIES}
     EXTRA_INCLUDES "${ARROW_PYTHON_INCLUDES}"
-    LABELS "arrow_python"
+    LABELS "arrow_python-tests"
     NO_VALGRIND)
 endif()
diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt
index da0d3bb..8052db5 100644
--- a/cpp/src/gandiva/CMakeLists.txt
+++ b/cpp/src/gandiva/CMakeLists.txt
@@ -15,12 +15,15 @@
 # specific language governing permissions and limitations
 # under the License.
 
-project(gandiva)
-
-find_package(LLVM)
-
 # For "make gandiva" to build everything Gandiva-related
+add_custom_target(gandiva-all)
 add_custom_target(gandiva)
+add_custom_target(gandiva-tests)
+add_custom_target(gandiva-benchmarks)
+
+add_dependencies(gandiva-all gandiva gandiva-tests gandiva-benchmarks)
+
+find_package(LLVM)
 
 # Set the path where the byte-code files will be installed.
 set(GANDIVA_BC_INSTALL_DIR
@@ -80,7 +83,7 @@ endif()
 ADD_ARROW_LIB(gandiva
   SOURCES ${SRC_FILES}
   OUTPUTS GANDIVA_LIBRARIES
-  DEPENDENCIES arrow_dependencies precompiled
+  DEPENDENCIES precompiled
   EXTRA_INCLUDES
   $<TARGET_PROPERTY:LLVM::LLVM_INTERFACE,INTERFACE_INCLUDE_DIRECTORIES>
   SHARED_LINK_LIBS arrow_shared
@@ -120,7 +123,7 @@ function(ADD_GANDIVA_TEST REL_TEST_NAME)
   set(TEST_ARGUMENTS
     ENABLED
     PREFIX "gandiva"
-    LABELS "unittest;gandiva"
+    LABELS "gandiva-tests"
     ${ARG_UNPARSED_ARGUMENTS})
 
   # and uses less disk space, but in some cases we need to force static
diff --git a/cpp/src/gandiva/jni/CMakeLists.txt b/cpp/src/gandiva/jni/CMakeLists.txt
index ab04f53..a07d390 100644
--- a/cpp/src/gandiva/jni/CMakeLists.txt
+++ b/cpp/src/gandiva/jni/CMakeLists.txt
@@ -15,8 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-project(gandiva_jni)
-
 if(CMAKE_VERSION VERSION_LESS 3.11)
   message(FATAL_ERROR "Building the Gandiva JNI bindings requires CMake version >= 3.11")
 endif()
diff --git a/cpp/src/gandiva/precompiled/CMakeLists.txt b/cpp/src/gandiva/precompiled/CMakeLists.txt
index 0792fd6..2af4908 100644
--- a/cpp/src/gandiva/precompiled/CMakeLists.txt
+++ b/cpp/src/gandiva/precompiled/CMakeLists.txt
@@ -58,7 +58,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_dependencies(gandiva ${TEST_NAME})
+  add_dependencies(gandiva-tests ${TEST_NAME})
   target_include_directories(${TEST_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
   target_link_libraries(${TEST_NAME}
     PRIVATE ${ARROW_TEST_LINK_LIBS} ${RE2_LIBRARY}
diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt
index 995c39a..4eb8f68 100644
--- a/cpp/src/parquet/CMakeLists.txt
+++ b/cpp/src/parquet/CMakeLists.txt
@@ -15,6 +15,12 @@
 # specific language governing permissions and limitations
 # under the License.
 
+add_custom_target(parquet-all)
+add_custom_target(parquet)
+add_custom_target(parquet-benchmarks)
+add_custom_target(parquet-tests)
+add_dependencies(parquet-all parquet parquet-tests parquet-benchmarks)
+
 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/.parquetcppversion" PARQUET_VERSION)
 string(REPLACE "\n" "" PARQUET_VERSION "${PARQUET_VERSION}")
 string(REGEX MATCH "^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)" VERSION ${PARQUET_VERSION})
@@ -22,9 +28,6 @@ if(NOT VERSION)
   message(FATAL_ERROR "invalid .parquetcppversion")
 endif()
 
-# For "make parquet" to build everything Parquet-related
-add_custom_target(parquet)
-
 function(ADD_PARQUET_TEST REL_TEST_NAME)
   set(options USE_STATIC_LINKING)
   set(one_value_args)
@@ -34,19 +37,21 @@ function(ADD_PARQUET_TEST REL_TEST_NAME)
     message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}")
   endif()
 
+  set(TEST_ARGUMENTS
+    PREFIX "parquet"
+    LABELS "parquet-tests")
+
   # By default we prefer shared linking with libparquet, as it's faster
   # and uses less disk space, but in some cases we need to force static
   # linking (see rationale below).
   if (ARG_USE_STATIC_LINKING)
     ADD_TEST_CASE(${REL_TEST_NAME}
       STATIC_LINK_LIBS ${PARQUET_STATIC_TEST_LINK_LIBS}
-      PREFIX "parquet"
-      LABELS "unittest;parquet")
+      ${TEST_ARGUMENTS})
   else()
     ADD_TEST_CASE(${REL_TEST_NAME}
       STATIC_LINK_LIBS ${PARQUET_SHARED_TEST_LINK_LIBS}
-      PREFIX "parquet"
-      LABELS "unittest;parquet")
+      ${TEST_ARGUMENTS})
   endif()
 endfunction()
 
@@ -217,6 +222,8 @@ ADD_ARROW_LIB(parquet
   STATIC_LINK_LIBS ${PARQUET_STATIC_LINK_LIBS}
 )
 
+add_dependencies(parquet ${PARQUET_LIBRARIES})
+
 # Thrift requires these definitions for some types that we use
 foreach(LIB_TARGET ${PARQUET_LIBRARIES})
   target_compile_definitions(${LIB_TARGET}
@@ -232,8 +239,6 @@ foreach(LIB_TARGET ${PARQUET_LIBRARIES})
   endif()
 endforeach()
 
-add_dependencies(parquet ${PARQUET_LIBRARIES})
-
 add_subdirectory(api)
 add_subdirectory(arrow)
 add_subdirectory(util)
@@ -271,7 +276,9 @@ ADD_PARQUET_TEST(schema-test USE_STATIC_LINKING)
 
 ADD_ARROW_BENCHMARK(column-io-benchmark
   PREFIX "parquet"
+  LABELS "parquet-benchmarks"
   EXTRA_LINK_LIBS ${PARQUET_BENCHMARK_LINK_LIBRARIES})
 ADD_ARROW_BENCHMARK(encoding-benchmark
   PREFIX "parquet"
+  LABELS "parquet-benchmarks"
   EXTRA_LINK_LIBS ${PARQUET_BENCHMARK_LINK_LIBRARIES})
diff --git a/cpp/src/parquet/arrow/CMakeLists.txt b/cpp/src/parquet/arrow/CMakeLists.txt
index 89afc39..f4e4f7e 100644
--- a/cpp/src/parquet/arrow/CMakeLists.txt
+++ b/cpp/src/parquet/arrow/CMakeLists.txt
@@ -20,9 +20,7 @@ ADD_PARQUET_TEST(arrow-reader-writer-test)
 
 ADD_BENCHMARK(reader-writer-benchmark
   PREFIX "parquet-arrow"
+  LABELS "parquet-benchmarks"
   EXTRA_LINK_LIBS ${PARQUET_BENCHMARK_LINK_LIBRARIES})
-if (TARGET parquet-arrow-reader-writer-benchmark)
-  add_dependencies(parquet parquet-arrow-reader-writer-benchmark)
-endif()
 
 ARROW_INSTALL_ALL_HEADERS("parquet/arrow")
diff --git a/cpp/src/plasma/CMakeLists.txt b/cpp/src/plasma/CMakeLists.txt
index 83c201d..d9c7dca 100644
--- a/cpp/src/plasma/CMakeLists.txt
+++ b/cpp/src/plasma/CMakeLists.txt
@@ -15,7 +15,11 @@
 # specific language governing permissions and limitations
 # under the License.
 
+add_custom_target(plasma-all)
 add_custom_target(plasma)
+add_custom_target(plasma-benchmarks)
+add_custom_target(plasma-tests)
+add_dependencies(plasma-all plasma plasma-tests plasma-benchmarks)
 
 # For the moment, Plasma is versioned like Arrow
 project(plasma VERSION "${ARROW_BASE_VERSION}")
@@ -199,7 +203,7 @@ function(ADD_PLASMA_TEST REL_TEST_NAME)
   cmake_parse_arguments(ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
   ADD_TEST_CASE(${REL_TEST_NAME}
     PREFIX "plasma"
-    LABELS "unittest;plasma"
+    LABELS "plasma-tests"
     ${ARG_UNPARSED_ARGUMENTS})
 endfunction()