ONNX will build googletest from a Git checkout. Patch CMake to use our googletest package and enable tests by default. diff --git a/CMakeLists.txt b/CMakeLists.txt index 0aa9fda2..a573170c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ option(BUILD_ONNX_PYTHON "Build Python binaries" OFF) option(ONNX_GEN_PB_TYPE_STUBS "Generate protobuf python type stubs" ON) option(ONNX_WERROR "Build with Werror" OFF) option(ONNX_COVERAGE "Build with coverage instrumentation" OFF) -option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" OFF) +option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" ON) option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF) option(ONNXIFI_ENABLE_EXT "Enable onnxifi extensions." OFF) if(NOT DEFINED ONNX_ML) @@ -82,8 +82,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") endif() if(ONNX_BUILD_TESTS) - list(APPEND CMAKE_MODULE_PATH ${ONNX_ROOT}/cmake/external) - include(googletest) + find_package(GTest REQUIRED) + if(NOT GTest_FOUND) + message(FATAL_ERROR "cannot find googletest") + endif() endif() if((ONNX_USE_LITE_PROTO AND TARGET protobuf::libprotobuf-lite) OR ((NOT ONNX_USE_LITE_PROTO) AND TARGET protobuf::libprotobuf)) diff --git a/cmake/unittest.cmake b/cmake/unittest.cmake index e29a93ff..ae146390 100644 --- a/cmake/unittest.cmake +++ b/cmake/unittest.cmake @@ -6,8 +6,8 @@ include(${ONNX_ROOT}/cmake/Utils.cmake) find_package(Threads) -set(${UT_NAME}_libs ${googletest_STATIC_LIBRARIES}) -set(${ONNXIFI_TEST_DRIVER}_libs ${googletest_STATIC_LIBRARIES}) +set(${UT_NAME}_libs ${GTEST_LIBRARIES}) +set(${ONNXIFI_TEST_DRIVER}_libs ${GTEST_LIBRARIES}) list(APPEND ${UT_NAME}_libs onnx) list(APPEND ${UT_NAME}_libs onnx_proto) @@ -31,10 +31,10 @@ function(AddTest) list(REMOVE_DUPLICATES _UT_SOURCES) add_executable(${_UT_TARGET} ${_UT_SOURCES}) - add_dependencies(${_UT_TARGET} onnx onnx_proto googletest) + add_dependencies(${_UT_TARGET} onnx onnx_proto) target_include_directories(${_UT_TARGET} - PUBLIC ${googletest_INCLUDE_DIRS} + PUBLIC ${GTEST_INCLUDE_DIRS} ${ONNX_INCLUDE_DIRS} ${PROTOBUF_INCLUDE_DIRS} ${ONNX_ROOT} >AgeCommit message (Expand)Author 2023-12-02gnu: Use ‘libc-utf8-locales-for-target’....Janneke Nieuwenhuizen 2023-08-31gnu: services: Revert to deleting and updating all matching services...Brian Cully 2023-08-20services: Define 'for-home'....Ludovic Courtès 2023-06-06services: Check if service is #f before applying clause....Josselin Poiret 2023-06-06services: 'modify-services' preserves service ordering....Ludovic Courtès 2023-06-02services: Error in MODIFY-SERVICES when services don't exist...Brian Cully 2023-05-16services: Add default values....Andrew Tropin 2023-03-16services: etc-service: Deprecate etc-service procedure....Bruno Victal 2022-08-30services: provenance: Use 'current-channels' to obtain provenance data....Ludovic Courtès 2022-05-29gnu: services: Update setuid service description....Tobias Geerinckx-Rice 2022-05-18services: Make <service-type> 'description' field mandatory....Ludovic Courtès 2022-05-18services: Add more description fields....Ludovic Courtès 2022-03-10services: startup: Add description....Ludovic Courtès 2021-11-27services: Document the 'delete' clause of 'modify-services'....Ludovic Courtès 2021-08-12system: Handle 'setuid-programs' deprecation handling as a field sanitizer....Ludovic Courtès 2021-07-29services: setuid: More configurable setuid support....Chris Lemmer-Webber