diff options
author | Benoit Jacob <benoitjacob@google.com> | 2021-01-21 01:04:41 +0300 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2021-01-21 01:05:04 +0300 |
commit | d65bcd7add7b5e7587355e4301c1b8ce335a877a (patch) | |
tree | e976cfe508a5cbe11dc5d8aecbedadc935ce3b00 | |
parent | c200f59184b6d0bda940aadfbaafa957a72f291c (diff) |
Fixes for builds in open source projects with cpuinfo and googletest deps.
- Following XNNPACK's example, in CMakeLists.txt, skip including our own
third_party/ directories if the target is already defined. This means that
IREE embedding ruy as a third_party/ dep does not need to have its
submodules checked out, ruy can use IREE's own cpuinfo and googletest.
- Switch open-source builds to using the stripped-include-paths flavor
of cpuinfo (like IREE is already using).
PiperOrigin-RevId: 352871140
-rw-r--r-- | CMakeLists.txt | 21 | ||||
-rw-r--r-- | cmake/ruy_include_directories.cmake | 2 | ||||
-rw-r--r-- | ruy/BUILD | 2 | ||||
-rw-r--r-- | ruy/cpuinfo.cc | 2 |
4 files changed, 16 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6577dd8..e0f24b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,13 +30,18 @@ include(cmake/ruy_cc_library.cmake) include(cmake/ruy_cc_binary.cmake) include(cmake/ruy_cc_test.cmake) -# Disabling cpuinfo's tests and benchmarks to prevent a copy of its -# googletest dependency getting downloaded into a 'deps' directory in the -# source tree! -set(CPUINFO_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE) -set(CPUINFO_BUILD_UNIT_TESTS OFF CACHE BOOL "" FORCE) -set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE BOOL "" FORCE) -add_subdirectory("third_party/cpuinfo" EXCLUDE_FROM_ALL) -add_subdirectory("third_party/googletest" EXCLUDE_FROM_ALL) +if (NOT TARGET cpuinfo) + # Disabling cpuinfo's tests and benchmarks to prevent a copy of its + # googletest dependency getting downloaded into a 'deps' directory in the + # source tree! + set(CPUINFO_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE) + set(CPUINFO_BUILD_UNIT_TESTS OFF CACHE BOOL "" FORCE) + set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE BOOL "" FORCE) + add_subdirectory("third_party/cpuinfo" EXCLUDE_FROM_ALL) +endif() + +if (NOT TARGET gtest) + add_subdirectory("third_party/googletest" EXCLUDE_FROM_ALL) +endif() ruy_add_all_subdirs() diff --git a/cmake/ruy_include_directories.cmake b/cmake/ruy_include_directories.cmake index d2e0ad1..e9b50a9 100644 --- a/cmake/ruy_include_directories.cmake +++ b/cmake/ruy_include_directories.cmake @@ -20,7 +20,7 @@ function(ruy_include_directories NAME DEPS) if (cpuinfo IN_LIST DEPS) target_include_directories(${NAME} PRIVATE - "${PROJECT_SOURCE_DIR}/third_party/cpuinfo" + "${PROJECT_SOURCE_DIR}/third_party/cpuinfo/include" ) endif() if ((gtest IN_LIST DEPS) OR @@ -404,7 +404,7 @@ cc_library( ":ppc": [], ":s390x": [], ":fuchsia": [], - "//conditions:default": ["@cpuinfo//:cpuinfo_with_unstripped_include_path"], + "//conditions:default": ["@cpuinfo"], }), ) diff --git a/ruy/cpuinfo.cc b/ruy/cpuinfo.cc index a4e71ef..b1f54bc 100644 --- a/ruy/cpuinfo.cc +++ b/ruy/cpuinfo.cc @@ -9,7 +9,7 @@ #include "ruy/platform.h" #ifdef RUY_HAVE_CPUINFO -#include "include/cpuinfo.h" +#include <cpuinfo.h> #endif namespace ruy { |