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

stigahuang pushed a commit to branch branch-3.4.2
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 3fe856f8cdb344f47f9c1eaea1a48d86dbc0605c
Author: zhangyifan27 <[email protected]>
AuthorDate: Fri Jul 21 20:22:27 2023 +0800

    IMPALA-12288: Add BUILD_WITH_NO_TESTS option to remove test targets
    
    This patch adds a new option 'BUILD_WITH_NO_TESTS' to tell CMake not
    to generate test targets. In order to be consistent with the previous
    test workflow, this option is only set ON when building impala using
    the 'buildall.sh' script with '-notest' and '-package' flags. This
    is useful for a packaging build which do not need to build all test
    binaries.
    
    Testing:
      - Ran 'buildall.sh -release -package' with and without '-notests'
    flag and verified generated executables.
    
    Backport notes: resolved conflicts in following files
     - be/src/codegen/CMakeLists.txt
     - be/src/exec/parquet/CMakeLists.txt
     - be/src/testutil/CMakeLists.txt
     - be/src/util/CMakeLists.txt
    
    Change-Id: I575ce76176c9f6a05fd2db0f420ebe6926d0272a
    Reviewed-on: http://gerrit.cloudera.org:8080/20294
    Reviewed-by: Michael Smith <[email protected]>
    Reviewed-by: Quanlong Huang <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
    Reviewed-on: http://gerrit.cloudera.org:8080/21262
    Reviewed-by: Yifan Zhang <[email protected]>
    Tested-by: Quanlong Huang <[email protected]>
---
 be/CMakeLists.txt                        | 53 +++++++++++++++++++-------------
 be/src/benchmarks/CMakeLists.txt         |  3 ++
 be/src/catalog/CMakeLists.txt            |  4 +++
 be/src/codegen/CMakeLists.txt            | 14 ++++++---
 be/src/common/CMakeLists.txt             | 22 +++++++------
 be/src/exec/CMakeLists.txt               |  4 +++
 be/src/exec/parquet/CMakeLists.txt       |  4 +++
 be/src/experiments/CMakeLists.txt        |  4 +++
 be/src/exprs/CMakeLists.txt              |  4 +++
 be/src/gutil/CMakeLists.txt              |  4 +++
 be/src/rpc/CMakeLists.txt                |  7 +++++
 be/src/runtime/CMakeLists.txt            |  4 +++
 be/src/runtime/bufferpool/CMakeLists.txt |  4 +++
 be/src/runtime/io/CMakeLists.txt         |  4 +++
 be/src/scheduling/CMakeLists.txt         |  4 +++
 be/src/service/CMakeLists.txt            | 32 ++++++++++---------
 be/src/statestore/CMakeLists.txt         |  4 +++
 be/src/testutil/CMakeLists.txt           |  4 +++
 be/src/udf/CMakeLists.txt                |  4 +++
 be/src/udf_samples/CMakeLists.txt        |  4 +++
 be/src/util/CMakeLists.txt               | 34 +++++++++++---------
 be/src/util/cache/CMakeLists.txt         |  4 +++
 buildall.sh                              |  3 ++
 23 files changed, 163 insertions(+), 65 deletions(-)

diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index c7bd31a63..ebaabeb0d 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -28,6 +28,8 @@ enable_testing()
 #      to CMakeFiles/<currentdir>.dir/<srcfile>.s
 PROJECT(ASSEMBLER)
 
+option(BUILD_WITH_NO_TESTS "Do not generate test and benchmark targets" OFF)
+
 # compiler flags that are common across debug/release builds
 #  -Wall: Enable all warnings.
 #  -Wno-sign-compare: suppress warnings for comparison between signed and 
unsigned
@@ -414,7 +416,6 @@ set (IMPALA_LIBS
   security
   Service
   Statestore
-  TestUtil
   ThriftSaslTransport
   token_proto
   Udf
@@ -422,6 +423,10 @@ set (IMPALA_LIBS
   UtilCache
 )
 
+if (NOT BUILD_WITH_NO_TESTS)
+  set(IMPALA_LIBS ${IMPALA_LIBS} TestUtil)
+endif()
+
 set (IMPALA_LINK_LIBS
   ${WL_START_GROUP}
   ${IMPALA_LIBS}
@@ -584,17 +589,19 @@ endif()
 set(LLVM_IR_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/llvm-ir")
 file(MAKE_DIRECTORY ${LLVM_IR_OUTPUT_DIRECTORY})
 
-# Add custom target to only build the backend tests
-# Note: this specifies "ALL" so it builds if running "make" with no arguments. 
This is
-# necessary due to the non-executable targets (i.e. generating backend test 
scripts)
-# that run for the unified backend tests.
-add_custom_target(be-test ALL)
+if (NOT BUILD_WITH_NO_TESTS)
+  # Add custom target to only build the backend tests
+  # Note: this specifies "ALL" so it builds if running "make" with no 
arguments. This is
+  # necessary due to the non-executable targets (i.e. generating backend test 
scripts)
+  # that run for the unified backend tests.
+  add_custom_target(be-test ALL)
 
-# Add custom target to build unified backend tests
-add_custom_target(unified-be-test)
+  # Add custom target to build unified backend tests
+  add_custom_target(unified-be-test)
 
-# Add custom target to build the unified backend test executable
-add_custom_target(unified-be-test-executable)
+  # Add custom target to build the unified backend test executable
+  add_custom_target(unified-be-test-executable)
+endif()
 
 # Variable to use to aggregate all of the filter patterns, joined by ":"
 set_property(GLOBAL PROPERTY AGG_UNIFIED_FILTER_PATTERN)
@@ -735,18 +742,20 @@ link_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}/build/transport
 )
 
-# Add custom target to validate the unified backend test executable and test 
match
-# patterns. At this point, all filter patterns have been aggregated from the 
individual
-# ADD_UNIFIED_BE_TEST calls into AGG_UNIFIED_FILTER_PATTERN.
-get_property(TOTAL_UNIFIED_FILTER_PATTERN GLOBAL PROPERTY 
AGG_UNIFIED_FILTER_PATTERN)
-add_custom_target(unified-be-test-validated-executable
-  "${CMAKE_CURRENT_SOURCE_DIR}/../bin/validate-unified-backend-test-filters.py"
-  "-f" "${TOTAL_UNIFIED_FILTER_PATTERN}"
-  "-b" "${BUILD_OUTPUT_ROOT_DIRECTORY}/service/unifiedbetests")
-
-ADD_DEPENDENCIES(be-test unified-be-test)
-ADD_DEPENDENCIES(unified-be-test unified-be-test-validated-executable)
-ADD_DEPENDENCIES(unified-be-test-validated-executable 
unified-be-test-executable)
+if (NOT BUILD_WITH_NO_TESTS)
+  # Add custom target to validate the unified backend test executable and test 
match
+  # patterns. At this point, all filter patterns have been aggregated from the 
individual
+  # ADD_UNIFIED_BE_TEST calls into AGG_UNIFIED_FILTER_PATTERN.
+  get_property(TOTAL_UNIFIED_FILTER_PATTERN GLOBAL PROPERTY 
AGG_UNIFIED_FILTER_PATTERN)
+  add_custom_target(unified-be-test-validated-executable
+    
"${CMAKE_CURRENT_SOURCE_DIR}/../bin/validate-unified-backend-test-filters.py"
+    "-f" "${TOTAL_UNIFIED_FILTER_PATTERN}"
+    "-b" "${BUILD_OUTPUT_ROOT_DIRECTORY}/service/unifiedbetests")
+
+  ADD_DEPENDENCIES(be-test unified-be-test)
+  ADD_DEPENDENCIES(unified-be-test unified-be-test-validated-executable)
+  ADD_DEPENDENCIES(unified-be-test-validated-executable 
unified-be-test-executable)
+endif()
 
 # only generate statically linked libs and executables
 set(BUILD_SHARED_LIBS OFF)
diff --git a/be/src/benchmarks/CMakeLists.txt b/be/src/benchmarks/CMakeLists.txt
index c09e71e9b..9381dc6fa 100644
--- a/be/src/benchmarks/CMakeLists.txt
+++ b/be/src/benchmarks/CMakeLists.txt
@@ -15,6 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
 
 # where to put generated libraries
 set(LIBRARY_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}/benchmarks")
diff --git a/be/src/catalog/CMakeLists.txt b/be/src/catalog/CMakeLists.txt
index 89fd96d26..273a82487 100644
--- a/be/src/catalog/CMakeLists.txt
+++ b/be/src/catalog/CMakeLists.txt
@@ -26,6 +26,10 @@ add_library(Catalog
 )
 add_dependencies(Catalog gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_library(CatalogTests STATIC
   catalog-util-test.cc
 )
diff --git a/be/src/codegen/CMakeLists.txt b/be/src/codegen/CMakeLists.txt
index 0cf5ff594..16a9f9f7f 100644
--- a/be/src/codegen/CMakeLists.txt
+++ b/be/src/codegen/CMakeLists.txt
@@ -38,11 +38,6 @@ add_library(CodeGen
 )
 add_dependencies(CodeGen gen-deps gen_ir_descriptions)
 
-add_library(CodeGenTests STATIC
-  instruction-counter-test.cc
-)
-add_dependencies(CodeGenTests gen-deps)
-
 # output cross compile to ir metadata
 set(IR_DESC_GEN_OUTPUT
   $ENV{IMPALA_HOME}/be/generated-sources/impala-ir/impala-ir-names.h
@@ -106,6 +101,15 @@ add_custom_command(
   DEPENDS ${IR_NO_SSE_OUTPUT_FILE}
 )
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
+add_library(CodeGenTests STATIC
+  instruction-counter-test.cc
+)
+add_dependencies(CodeGenTests gen-deps)
+
 # Run the clang compiler to generate BC for llvm-codegen-test
 add_custom_target(test-loop.bc
   COMMAND ${LLVM_CLANG_EXECUTABLE} ${CLANG_IR_CXX_FLAGS} 
${CLANG_INCLUDE_FLAGS} ${CMAKE_SOURCE_DIR}/testdata/llvm/test-loop.cc -o 
${CMAKE_SOURCE_DIR}/llvm-ir/test-loop.bc
diff --git a/be/src/common/CMakeLists.txt b/be/src/common/CMakeLists.txt
index d2f30d139..70115cf75 100644
--- a/be/src/common/CMakeLists.txt
+++ b/be/src/common/CMakeLists.txt
@@ -37,12 +37,6 @@ add_library(Common
 )
 add_dependencies(Common gen-deps)
 
-add_library(CommonTests STATIC
-  atomic-test.cc
-  thread-debug-info-test.cc
-)
-add_dependencies(CommonTests gen-deps)
-
 # Command to generate the build version file if not present. We don't 
automatically
 # regenerate the file if present, which speeds up incremental builds but can 
lead
 # to the version being stale.
@@ -58,9 +52,19 @@ add_library(GlobalFlags
 )
 add_dependencies(GlobalFlags gen-deps)
 
-ADD_UNIFIED_BE_LSAN_TEST(atomic-test AtomicTest.*)
-ADD_UNIFIED_BE_LSAN_TEST(thread-debug-info-test ThreadDebugInfo.*)
-
 # Generate config.h from config.h.in, filling in variables from CMake
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
     ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
+add_library(CommonTests STATIC
+  atomic-test.cc
+  thread-debug-info-test.cc
+)
+add_dependencies(CommonTests gen-deps)
+
+ADD_UNIFIED_BE_LSAN_TEST(atomic-test AtomicTest.*)
+ADD_UNIFIED_BE_LSAN_TEST(thread-debug-info-test ThreadDebugInfo.*)
diff --git a/be/src/exec/CMakeLists.txt b/be/src/exec/CMakeLists.txt
index c4440c1ba..2371c8e42 100644
--- a/be/src/exec/CMakeLists.txt
+++ b/be/src/exec/CMakeLists.txt
@@ -108,6 +108,10 @@ add_library(Exec
 
 add_dependencies(Exec gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_library(ExecTests STATIC
   delimited-text-parser-test.cc
   hash-table-test.cc
diff --git a/be/src/exec/parquet/CMakeLists.txt 
b/be/src/exec/parquet/CMakeLists.txt
index 7b18a26f1..e7b58c7a2 100644
--- a/be/src/exec/parquet/CMakeLists.txt
+++ b/be/src/exec/parquet/CMakeLists.txt
@@ -40,6 +40,10 @@ add_library(Parquet
 
 add_dependencies(Parquet gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_library(ParquetTests STATIC
   hdfs-parquet-scanner-test.cc
   parquet-bool-decoder-test.cc
diff --git a/be/src/experiments/CMakeLists.txt 
b/be/src/experiments/CMakeLists.txt
index a50798caa..f544025d4 100644
--- a/be/src/experiments/CMakeLists.txt
+++ b/be/src/experiments/CMakeLists.txt
@@ -26,6 +26,10 @@ add_library(Experiments
 )
 add_dependencies(Experiments gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_executable(data-provider-test data-provider-test.cc)
 add_executable(tuple-splitter-test tuple-splitter-test.cc)
 add_executable(hash-partition-test hash-partition-test.cc)
diff --git a/be/src/exprs/CMakeLists.txt b/be/src/exprs/CMakeLists.txt
index b80d77c84..0efb1cdc6 100644
--- a/be/src/exprs/CMakeLists.txt
+++ b/be/src/exprs/CMakeLists.txt
@@ -71,6 +71,10 @@ add_library(Exprs
 )
 add_dependencies(Exprs gen-deps gen_ir_descriptions)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_library(ExprsTests STATIC
   expr-test.cc
   timezone_db-test.cc
diff --git a/be/src/gutil/CMakeLists.txt b/be/src/gutil/CMakeLists.txt
index 444ef809c..d5ac48b6d 100644
--- a/be/src/gutil/CMakeLists.txt
+++ b/be/src/gutil/CMakeLists.txt
@@ -70,6 +70,10 @@ ADD_EXPORTABLE_LIBRARY(gutil
   # Disable warnings which trigger a lot in the Google code:
   COMPILE_FLAGS "-funsigned-char -Wno-deprecated -Wno-char-subscripts")
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_kudu_test(strings/string_util-test)
 
 add_library(GUtilTests STATIC
diff --git a/be/src/rpc/CMakeLists.txt b/be/src/rpc/CMakeLists.txt
index ffd4481ab..851048b50 100644
--- a/be/src/rpc/CMakeLists.txt
+++ b/be/src/rpc/CMakeLists.txt
@@ -40,6 +40,13 @@ add_library(Rpc
 )
 add_dependencies(Rpc gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  # thrift-util.cc uses the EXPECT_NO_THROW macro, explicitly linking gtest 
library
+  # to avoid linker errors.
+  target_link_libraries(Rpc gtest)
+  return()
+endif()
+
 add_library(RpcTests STATIC
   thrift-util-test.cc
 )
diff --git a/be/src/runtime/CMakeLists.txt b/be/src/runtime/CMakeLists.txt
index 585b291fa..d03c608dd 100644
--- a/be/src/runtime/CMakeLists.txt
+++ b/be/src/runtime/CMakeLists.txt
@@ -87,6 +87,10 @@ add_library(Runtime
 )
 add_dependencies(Runtime gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_library(RuntimeTests STATIC
   coordinator-backend-state-test.cc
   date-test.cc
diff --git a/be/src/runtime/bufferpool/CMakeLists.txt 
b/be/src/runtime/bufferpool/CMakeLists.txt
index e20640e2d..be8130205 100644
--- a/be/src/runtime/bufferpool/CMakeLists.txt
+++ b/be/src/runtime/bufferpool/CMakeLists.txt
@@ -31,6 +31,10 @@ add_library(BufferPool
 )
 add_dependencies(BufferPool gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_library(BufferPoolTests STATIC
   free-list-test.cc
   suballocator-test.cc
diff --git a/be/src/runtime/io/CMakeLists.txt b/be/src/runtime/io/CMakeLists.txt
index 239d90112..eff0df1d2 100644
--- a/be/src/runtime/io/CMakeLists.txt
+++ b/be/src/runtime/io/CMakeLists.txt
@@ -41,6 +41,10 @@ add_library(IoTests STATIC
 )
 add_dependencies(IoTests gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 # This test runs forever so should not be part of 'make test'
 add_executable(disk-io-mgr-stress-test disk-io-mgr-stress-test.cc)
 target_link_libraries(disk-io-mgr-stress-test ${IMPALA_TEST_LINK_LIBS})
diff --git a/be/src/scheduling/CMakeLists.txt b/be/src/scheduling/CMakeLists.txt
index 0b5aa74d3..42d2ac647 100644
--- a/be/src/scheduling/CMakeLists.txt
+++ b/be/src/scheduling/CMakeLists.txt
@@ -37,6 +37,10 @@ add_library(Scheduling STATIC
 )
 add_dependencies(Scheduling gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_library(SchedulingTests STATIC
   admission-controller-test.cc
   cluster-membership-mgr-test.cc
diff --git a/be/src/service/CMakeLists.txt b/be/src/service/CMakeLists.txt
index 9371cbc80..844b6587c 100644
--- a/be/src/service/CMakeLists.txt
+++ b/be/src/service/CMakeLists.txt
@@ -47,13 +47,6 @@ add_library(Service
 )
 add_dependencies(Service gen-deps)
 
-add_library(ServiceTests STATIC
-  hs2-util-test.cc
-  impala-server-test.cc
-  query-options-test.cc
-)
-add_dependencies(ServiceTests gen-deps)
-
 # this shared library provides Impala executor functionality to FE test.
 add_library(fesupport SHARED
   fe-support.cc
@@ -74,10 +67,6 @@ add_executable(impalad
   daemon-main.cc
 )
 
-add_executable(unifiedbetests
-  unified-betest-main.cc
-)
-
 # All Impala daemons run from the same binary. The code that is run is 
determined by the
 # name (i.e. argv[0]) of the command that executes the binary, so we create 
symlinks for
 # statestored and catalogd. The symlinks are relative so they can be installed 
along with
@@ -106,13 +95,28 @@ target_link_libraries(impalad
   ${IMPALA_LINK_LIBS}
 )
 
+install(FILES ${STATESTORED_SYMLINK} DESTINATION ${IMPALA_INSTALLDIR}/bin)
+install(FILES ${CATALOGD_SYMLINK} DESTINATION ${IMPALA_INSTALLDIR}/bin)
+install(TARGETS impalad DESTINATION ${IMPALA_INSTALLDIR}/bin)
+
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
+add_executable(unifiedbetests
+  unified-betest-main.cc
+)
+
 target_link_libraries(unifiedbetests
   ${JAVA_JSIG_LIBRARY} ${UNIFIED_TEST_LINK_LIBS})
 ADD_DEPENDENCIES(unified-be-test-executable unifiedbetests)
 
-install(FILES ${STATESTORED_SYMLINK} DESTINATION ${IMPALA_INSTALLDIR}/bin)
-install(FILES ${CATALOGD_SYMLINK} DESTINATION ${IMPALA_INSTALLDIR}/bin)
-install(TARGETS impalad DESTINATION ${IMPALA_INSTALLDIR}/bin)
+add_library(ServiceTests STATIC
+  hs2-util-test.cc
+  impala-server-test.cc
+  query-options-test.cc
+)
+add_dependencies(ServiceTests gen-deps)
 
 # Exception to unified be tests: Custom main() due to leak
 ADD_BE_TEST(session-expiry-test session-expiry-test.cc) # TODO: this leaks 
thrift server
diff --git a/be/src/statestore/CMakeLists.txt b/be/src/statestore/CMakeLists.txt
index a2bc4c040..799d88a5c 100644
--- a/be/src/statestore/CMakeLists.txt
+++ b/be/src/statestore/CMakeLists.txt
@@ -30,4 +30,8 @@ add_library(Statestore
 )
 add_dependencies(Statestore gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 ADD_BE_LSAN_TEST(statestore-test)
diff --git a/be/src/testutil/CMakeLists.txt b/be/src/testutil/CMakeLists.txt
index 17885fa71..4aee7be7e 100644
--- a/be/src/testutil/CMakeLists.txt
+++ b/be/src/testutil/CMakeLists.txt
@@ -18,6 +18,10 @@
 
 cmake_minimum_required(VERSION 2.6)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 # where to put generated libraries
 set(LIBRARY_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}/testutil")
 
diff --git a/be/src/udf/CMakeLists.txt b/be/src/udf/CMakeLists.txt
index 0470716a8..d9ad7ecfa 100644
--- a/be/src/udf/CMakeLists.txt
+++ b/be/src/udf/CMakeLists.txt
@@ -32,5 +32,9 @@ add_library(ImpalaUdf udf.cc udf-ir.cc udf-test-harness.cc)
 add_dependencies(ImpalaUdf gen-deps)
 set_target_properties(ImpalaUdf PROPERTIES COMPILE_FLAGS 
"-DIMPALA_UDF_SDK_BUILD")
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 ADD_UDF_TEST(udf-test)
 ADD_UDF_TEST(uda-test)
diff --git a/be/src/udf_samples/CMakeLists.txt 
b/be/src/udf_samples/CMakeLists.txt
index e4aaf8d26..4f0751a51 100644
--- a/be/src/udf_samples/CMakeLists.txt
+++ b/be/src/udf_samples/CMakeLists.txt
@@ -54,6 +54,10 @@ add_dependencies(udf-sample-ir gen-deps)
 COMPILE_TO_IR(uda-sample.cc )
 add_dependencies(uda-sample-ir gen-deps)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 # This is an example of how to use the test harness to help develop UDF and 
UDAs.
 add_executable(udf-sample-test udf-sample-test.cc)
 target_link_libraries(udf-sample-test ImpalaUdf udfsample)
diff --git a/be/src/util/CMakeLists.txt b/be/src/util/CMakeLists.txt
index c8cd73566..1b8c41d5b 100644
--- a/be/src/util/CMakeLists.txt
+++ b/be/src/util/CMakeLists.txt
@@ -104,6 +104,25 @@ add_library(Util
   ${MPFIT_SRC_DIR}/mpfit.c)
 add_dependencies(Util gen-deps gen_ir_descriptions)
 
+# Squeasel requires C99 compatibility to build.
+SET_SOURCE_FILES_PROPERTIES(${SQUEASEL_SRC_DIR}/squeasel.c
+  PROPERTIES COMPILE_FLAGS -std=c99)
+
+# shared library which provides native logging support to JVMs over JNI.
+add_library(loggingsupport SHARED
+  logging-support.cc
+)
+
+add_executable(parquet-reader parquet-reader.cc)
+
+target_link_libraries(parquet-reader ${IMPALA_LINK_LIBS})
+
+target_link_libraries(loggingsupport ${IMPALA_LINK_LIBS_DYNAMIC_TARGETS})
+
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_library(UtilTests STATIC
   benchmark-test.cc
   bitmap-test.cc
@@ -149,21 +168,6 @@ add_library(UtilTests STATIC
 )
 add_dependencies(UtilTests gen-deps gen_ir_descriptions)
 
-# Squeasel requires C99 compatibility to build.
-SET_SOURCE_FILES_PROPERTIES(${SQUEASEL_SRC_DIR}/squeasel.c
-  PROPERTIES COMPILE_FLAGS -std=c99)
-
-# shared library which provides native logging support to JVMs over JNI.
-add_library(loggingsupport SHARED
-  logging-support.cc
-)
-
-add_executable(parquet-reader parquet-reader.cc)
-
-target_link_libraries(parquet-reader ${IMPALA_LINK_LIBS})
-
-target_link_libraries(loggingsupport ${IMPALA_LINK_LIBS_DYNAMIC_TARGETS})
-
 ADD_UNIFIED_BE_LSAN_TEST(benchmark-test "BenchmarkTest.*")
 ADD_UNIFIED_BE_LSAN_TEST(bitmap-test "Bitmap.*")
 ADD_UNIFIED_BE_LSAN_TEST(bit-packing-test "BitPackingTest.*")
diff --git a/be/src/util/cache/CMakeLists.txt b/be/src/util/cache/CMakeLists.txt
index cb3595c04..8809ac683 100644
--- a/be/src/util/cache/CMakeLists.txt
+++ b/be/src/util/cache/CMakeLists.txt
@@ -26,6 +26,10 @@ add_library(UtilCache
 )
 add_dependencies(UtilCache gen-deps gen_ir_descriptions)
 
+if (BUILD_WITH_NO_TESTS)
+  return()
+endif()
+
 add_library(UtilCacheTests STATIC
   cache-test.cc
 )
diff --git a/buildall.sh b/buildall.sh
index 0f5d03101..5cb180e3a 100755
--- a/buildall.sh
+++ b/buildall.sh
@@ -454,6 +454,9 @@ generate_cmake_files() {
   if [[ $BUILD_SHARED_LIBS -eq 1 ]]; then
     CMAKE_ARGS+=(-DBUILD_SHARED_LIBS=ON)
   fi
+  if [[ "$BUILD_TESTS" -eq 0 && "$GEN_PACKAGE" -eq 1 ]]; then
+    CMAKE_ARGS+=(-DBUILD_WITH_NO_TESTS=ON)
+  fi
   if [[ "${MAKE_CMD}" = "ninja" ]]; then
     CMAKE_ARGS+=(-GNinja)
   fi

Reply via email to