diff --git a/.evergreen/build_all.sh b/.evergreen/build_all.sh index 945ce95d0..be0fce306 100755 --- a/.evergreen/build_all.sh +++ b/.evergreen/build_all.sh @@ -27,6 +27,10 @@ export CMAKE_INSTALL_PREFIX="${MONGOCRYPT_INSTALL_PREFIX-}" export CTEST_OUTPUT_ON_FAILURE=1 # Generate a compilation database for use by other tools export CMAKE_EXPORT_COMPILE_COMMANDS=1 +# Permit skipping build of tests. +BUILD_TESTING="${BUILD_TESTING-TRUE}" +# Build nocrypto and sharedbson variants (true by defualt). +LIBMONGOCRYPT_BUILD_VARIANTS="${LIBMONGOCRYPT_BUILD_VARIANTS:-TRUE}" # Accumulate arguments that are passed to CMake cmake_args=( @@ -38,7 +42,7 @@ cmake_args=( # Toggle compiling with shared BSON -D USE_SHARED_LIBBSON="${USE_SHARED_LIBBSON-FALSE}" # Toggle building of tests - -D BUILD_TESTING="${BUILD_TESTING-TRUE}" + -D BUILD_TESTING="${BUILD_TESTING:?}" # Enable additional warnings-as-errors -D ENABLE_MORE_WARNINGS_AS_ERRORS=TRUE ) @@ -85,7 +89,7 @@ if [ "$CONFIGURE_ONLY" ]; then exit 0; fi echo "Installing libmongocrypt" -_cmake_with_env --build "$BINARY_DIR" --target install test-mongocrypt test_kms_request +_cmake_with_env --build "$BINARY_DIR" --target install run_chdir "$BINARY_DIR" run_ctest # MONGOCRYPT-372, ensure macOS universal builds contain both x86_64 and arm64 architectures. @@ -105,12 +109,17 @@ if [ "$PPA_BUILD_ONLY" ]; then exit 0; fi +if [ "${LIBMONGOCRYPT_BUILD_VARIANTS:?}" != "TRUE" ]; then + echo "Skipping build of libmongocrypt variants"; + exit 0; +fi + # Build and install libmongocrypt with no native crypto. _cmake_with_env "${cmake_args[@]}" \ -DDISABLE_NATIVE_CRYPTO=ON \ -DCMAKE_INSTALL_PREFIX="$MONGOCRYPT_INSTALL_PREFIX/nocrypto" \ -B "$BINARY_DIR" -S "$LIBMONGOCRYPT_DIR" -_cmake_with_env --build "$BINARY_DIR" --target install test-mongocrypt +_cmake_with_env --build "$BINARY_DIR" --target install run_chdir "$BINARY_DIR" run_ctest # Build and install libmongocrypt without statically linking libbson @@ -118,5 +127,5 @@ _cmake_with_env "${cmake_args[@]}" \ -DUSE_SHARED_LIBBSON=ON \ -DCMAKE_INSTALL_PREFIX="$MONGOCRYPT_INSTALL_PREFIX/sharedbson" \ -B "$BINARY_DIR" -S "$LIBMONGOCRYPT_DIR" -_cmake_with_env --build "$BINARY_DIR" --target install test-mongocrypt +_cmake_with_env --build "$BINARY_DIR" --target install run_chdir "$BINARY_DIR" run_ctest diff --git a/CMakeLists.txt b/CMakeLists.txt index d44c1122e..d19276fb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,6 +499,8 @@ set (TEST_MONGOCRYPT_SOURCES test/test-unicode-fold.c ) +if (BUILD_TESTING) + # Define test-mongocrypt add_executable (test-mongocrypt ${TEST_MONGOCRYPT_SOURCES}) # Use the static version since it allows the test binary to use private symbols @@ -549,6 +551,8 @@ if ("cxx_relaxed_constexpr" IN_LIST CMAKE_CXX_COMPILE_FEATURES) endforeach () endif () +endif () # BUILD_TESTING + if ("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES) add_executable (csfle-markup src/csfle-markup.cpp) target_link_libraries (csfle-markup PRIVATE mongocrypt_static _mongocrypt::libbson_for_static mongo::mc-mlib)