Skip to content

Commit 7b01ed2

Browse files
Skip building tests by default (#993)
CXX-1792 CXX-2702 Tests will not be compiled by default. To enable building tests, build with -DBUILD_TESTING=ON --------- Co-authored-by: vector-of-bool <[email protected]>
1 parent 770645f commit 7b01ed2

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

.evergreen/compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ case "$OS" in
5050
esac
5151

5252
cd build
53-
"${cmake_binary}" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON "$@" ..
53+
"${cmake_binary}" -G "$GENERATOR" "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" -DBUILD_TESTING=ON -DMONGOCXX_ENABLE_SLOW_TESTS=ON -DENABLE_UNINSTALL=ON "$@" ..
5454
"${cmake_binary}" --build . --config $BUILD_TYPE -- $CMAKE_BUILD_OPTS
5555
"${cmake_binary}" --build . --config $BUILD_TYPE --target install -- $CMAKE_BUILD_OPTS
5656
"${cmake_binary}" --build . --config $BUILD_TYPE --target $CMAKE_EXAMPLES_TARGET -- $CMAKE_BUILD_OPTS

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ endif()
2020

2121
project(MONGO_CXX_DRIVER LANGUAGES CXX)
2222

23+
if(NOT DEFINED BUILD_TESTING)
24+
set(BUILD_TESTING OFF) # Set this to OFF by default
25+
endif()
26+
2327
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
2428
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.2")
2529
message(FATAL_ERROR "Insufficient GCC version - GCC 4.8.2+ required")
@@ -102,8 +106,8 @@ if(NEED_DOWNLOAD_C_DRIVER)
102106
add_subdirectory(${mongo-c-driver_SOURCE_DIR} ${mongo-c-driver_BINARY_DIR})
103107
set(CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS})
104108
set(CMAKE_C_FLAGS ${OLD_CMAKE_C_FLAGS})
105-
set(ENABLE_TESTS OLD_ENABLE_TESTS)
106-
set(BUILD_TESTING OLD_BUILD_TESTING)
109+
set(ENABLE_TESTS ${OLD_ENABLE_TESTS})
110+
set(BUILD_TESTING ${OLD_BUILD_TESTING})
107111
endif()
108112
message(STATUS "Download and configure C driver version ${LIBMONGOC_DOWNLOAD_VERSION} ... end")
109113
endif()

src/bsoncxx/test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
if(NOT BUILD_TESTING)
16+
set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE)
17+
endif()
18+
1519
include_directories(
1620
${MONGO_CXX_DRIVER_SOURCE_DIR}/src/third_party/catch/include
1721
)

src/mongocxx/test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
if(NOT BUILD_TESTING)
16+
set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE)
17+
endif()
18+
1519
include_directories(
1620
${THIRD_PARTY_SOURCE_DIR}/catch/include
1721
)

0 commit comments

Comments
 (0)