diff options
author | bjacob <jacob.benoit.1@gmail.com> | 2021-01-22 23:40:29 +0300 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2021-01-22 23:41:02 +0300 |
commit | 09827c89612fdb3b7adef229d9b057bbe61a8d31 (patch) | |
tree | dee15a4b782e1f4eb23bc38058bf54927412071e | |
parent | 58e3051707b3a92dab0a72297183114a1d35f483 (diff) |
Disable tests by default when ruy is a subproject.
Closes https://github.com/google/ruy/pull/249
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/ruy/pull/249 from bjacob:tests-disabled-when-submodule 3a33bb081acadca3520edeae2c226827e9fe0f89
PiperOrigin-RevId: 353298619
-rw-r--r-- | CMakeLists.txt | 23 | ||||
-rw-r--r-- | cmake/ruy_cc_binary.cmake | 2 | ||||
-rw-r--r-- | cmake/ruy_cc_library.cmake | 2 | ||||
-rw-r--r-- | cmake/ruy_cc_test.cmake | 2 |
4 files changed, 22 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e0f24b1..55e3397 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,14 @@ project(ruy CXX) cmake_minimum_required(VERSION 3.13) # Copied from IREE set(CMAKE_CXX_STANDARD 14) -option(RUY_ENABLE_TESTS "Enable ruy's tests" ON) -if (RUY_ENABLE_TESTS) +if (PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME) + set(RUY_MINIMAL_BUILD_DEFAULT_VALUE OFF) +else() + set(RUY_MINIMAL_BUILD_DEFAULT_VALUE ON) +endif() + +option(RUY_MINIMAL_BUILD "Disable ruy's tests, examples, etc. Build only ruy public libraries." ${RUY_MINIMAL_BUILD_DEFAULT_VALUE}) +if (NOT RUY_MINIMAL_BUILD) enable_testing() endif() @@ -40,8 +46,17 @@ if (NOT TARGET cpuinfo) add_subdirectory("third_party/cpuinfo" EXCLUDE_FROM_ALL) endif() -if (NOT TARGET gtest) +# googletest is only needed for tests. Projects embedding ruy as a subdirectory +# and not needing to build ruy tests may proceed without a local checkout of +# third_party/googletest. +if (NOT RUY_MINIMAL_BUILD + AND NOT TARGET gtest + AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/CMakeLists.txt") add_subdirectory("third_party/googletest" EXCLUDE_FROM_ALL) endif() -ruy_add_all_subdirs() +add_subdirectory("ruy") + +if (NOT RUY_MINIMAL_BUILD) + add_subdirectory("example") +endif() diff --git a/cmake/ruy_cc_binary.cmake b/cmake/ruy_cc_binary.cmake index 21dbb9d..93d1adf 100644 --- a/cmake/ruy_cc_binary.cmake +++ b/cmake/ruy_cc_binary.cmake @@ -29,7 +29,7 @@ function(ruy_cc_binary) ${ARGN} ) - if(_RULE_TESTONLY AND NOT RUY_ENABLE_TESTS) + if(_RULE_TESTONLY AND RUY_MINIMAL_BUILD) return() endif() diff --git a/cmake/ruy_cc_library.cmake b/cmake/ruy_cc_library.cmake index 2fa413f..38accc5 100644 --- a/cmake/ruy_cc_library.cmake +++ b/cmake/ruy_cc_library.cmake @@ -29,7 +29,7 @@ function(ruy_cc_library) ${ARGN} ) - if(_RULE_TESTONLY AND NOT RUY_ENABLE_TESTS) + if(_RULE_TESTONLY AND RUY_MINIMAL_BUILD) return() endif() diff --git a/cmake/ruy_cc_test.cmake b/cmake/ruy_cc_test.cmake index 2d78697..6ad247e 100644 --- a/cmake/ruy_cc_test.cmake +++ b/cmake/ruy_cc_test.cmake @@ -29,7 +29,7 @@ function(ruy_cc_test) ${ARGN} ) - if(NOT RUY_ENABLE_TESTS) + if(RUY_MINIMAL_BUILD) return() endif() |