diff --git a/CMakeLists.txt b/CMakeLists.txt index af8f4e2e299..69cbc6153bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,6 +144,9 @@ option(EXECUTORCH_BUILD_EXTENSION_MODULE option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL "Build the extension/runner_util directory" OFF) +# Build gtest +option(EXECUTORCH_BUILD_GTEST "Build GTEST" OFF) + if(NOT BUCK2) set(BUCK2 buck2) endif() @@ -443,5 +446,17 @@ if(EXECUTORCH_BUILD_PYBIND) install(TARGETS portable_lib LIBRARY DESTINATION executorch/extension/pybindings) endif() + +if(EXECUTORCH_BUILD_GTEST) + include(FetchContent) + FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip + ) + # For Windows: Prevent overriding the parent project's compiler/linker settings + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + FetchContent_MakeAvailable(googletest) + add_subdirectory(runtime/kernel/test) +endif() # Print all summary executorch_print_configuration_summary() diff --git a/runtime/kernel/test/CMakeLists.txt b/runtime/kernel/test/CMakeLists.txt new file mode 100644 index 00000000000..c94ea24079f --- /dev/null +++ b/runtime/kernel/test/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# ### Editing this file ### +# +# This file should be formatted with +# ~~~ +# cmake-format --first-comment-is-literal=True CMakeLists.txt +# ~~~ +# It should also be cmake-lint clean. +# +enable_testing() + +add_executable( + make_boxed_from_unboxed_functor_test + make_boxed_from_unboxed_functor_test.cpp +) +target_link_libraries( + make_boxed_from_unboxed_functor_test + executorch + GTest::gtest_main +) + +include(GoogleTest) +gtest_discover_tests(make_boxed_from_unboxed_functor_test)