Skip to content

Commit d3ee649

Browse files
committed
✨ Refactor googletest inclusion for improved build configuration
1 parent 6fafe7c commit d3ee649

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

CMakeLists.txt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ else()
143143
set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}")
144144
endif()
145145

146+
if(EXECUTORCH_BUILD_TESTS)
147+
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
148+
include(CTest)
149+
endif()
150+
146151
add_subdirectory(third-party)
147152

148153
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
@@ -254,11 +259,6 @@ if(EXECUTORCH_BUILD_PTHREADPOOL)
254259
)
255260
endif()
256261

257-
if(EXECUTORCH_BUILD_TESTS)
258-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
259-
include(CTest)
260-
endif()
261-
262262
# TODO(dbort): Fix these warnings and remove this flag.
263263
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
264264

@@ -472,11 +472,6 @@ install(
472472
)
473473
install(FILES tools/cmake/executorch-config.cmake DESTINATION lib/cmake/ExecuTorch)
474474

475-
# Add googletest if any test targets should be built
476-
if(BUILD_TESTING)
477-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/googletest)
478-
endif()
479-
480475
if(EXECUTORCH_BUILD_ARM_BAREMETAL)
481476
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
482477
endif()

third-party/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ if(EXECUTORCH_BUILD_PYBIND)
1010
add_subdirectory(pybind11)
1111
endif()
1212

13+
if(BUILD_TESTING)
14+
add_subdirectory(googletest)
15+
endif()
16+
1317
# MARK: - flatbuffers
1418

1519
if(WIN32)

0 commit comments

Comments
 (0)