aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorbjacob <benoitjacob@google.com>2021-01-19 21:37:31 -0500
committerGitHub <noreply@github.com>2021-01-19 21:37:31 -0500
commitb87d6d2e65ca24ba38e9afbf1e9d0744dbda82d3 (patch)
treed850e0185e717beff6e071c1fa12c62ad74b1608 /CMakeLists.txt
parentfb9174e5a1e706424dc42b270e02e3429470955c (diff)
downloadruy-b87d6d2e65ca24ba38e9afbf1e9d0744dbda82d3.tar.gz
Add CMake support with a converter from Bazel (#233)
* Add CMake support with a converter from Bazel, update by running: cmake/bazel_to_cmake.sh This supports building and running tests also on Android, e.g. ``` cmake ../ruy -G Ninja \ -DCMAKE_TOOLCHAIN_FILE=~/android-ndk-r21d/build/cmake/android.toolchain.cmake \ -DANDROID_ABI=arm64-v8a \ -DANDROID_PLATFORM=android-29 cmake --build . -j12 ctest . -j12 ``` Some parts of this were forked from IREE's cmake setup.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt42
1 files changed, 42 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..6577dd8
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,42 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+cmake_policy(SET CMP0012 NEW)
+cmake_policy(SET CMP0048 NEW)
+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)
+ enable_testing()
+endif()
+
+option(RUY_PROFILER "Enable ruy's built-in profiler (harms performance)" OFF)
+
+include(cmake/ruy_add_all_subdirs.cmake)
+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)
+
+ruy_add_all_subdirs()