1*bb86c7edSAndroid Build Coastguard Worker# Copyright 2019 Google LLC 2*bb86c7edSAndroid Build Coastguard Worker# 3*bb86c7edSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*bb86c7edSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*bb86c7edSAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*bb86c7edSAndroid Build Coastguard Worker# 7*bb86c7edSAndroid Build Coastguard Worker# https://www.apache.org/licenses/LICENSE-2.0 8*bb86c7edSAndroid Build Coastguard Worker# 9*bb86c7edSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*bb86c7edSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*bb86c7edSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*bb86c7edSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*bb86c7edSAndroid Build Coastguard Worker# limitations under the License. 14*bb86c7edSAndroid Build Coastguard Worker 15*bb86c7edSAndroid Build Coastguard Worker# Forked from IREE's iree_cc_binary.cmake. 16*bb86c7edSAndroid Build Coastguard Worker 17*bb86c7edSAndroid Build Coastguard Workerinclude(CMakeParseArguments) 18*bb86c7edSAndroid Build Coastguard Workerinclude(cmake/ruy_include_directories.cmake) 19*bb86c7edSAndroid Build Coastguard Worker 20*bb86c7edSAndroid Build Coastguard Worker# ruy_cc_binary() 21*bb86c7edSAndroid Build Coastguard Worker# 22*bb86c7edSAndroid Build Coastguard Worker# CMake function to imitate Bazel's cc_binary rule. 23*bb86c7edSAndroid Build Coastguard Workerfunction(ruy_cc_binary) 24*bb86c7edSAndroid Build Coastguard Worker cmake_parse_arguments( 25*bb86c7edSAndroid Build Coastguard Worker _RULE 26*bb86c7edSAndroid Build Coastguard Worker "TESTONLY" 27*bb86c7edSAndroid Build Coastguard Worker "NAME" 28*bb86c7edSAndroid Build Coastguard Worker "SRCS;COPTS;LINKOPTS;DEPS;TAGS" 29*bb86c7edSAndroid Build Coastguard Worker ${ARGN} 30*bb86c7edSAndroid Build Coastguard Worker ) 31*bb86c7edSAndroid Build Coastguard Worker 32*bb86c7edSAndroid Build Coastguard Worker if(_RULE_TESTONLY AND RUY_MINIMAL_BUILD) 33*bb86c7edSAndroid Build Coastguard Worker return() 34*bb86c7edSAndroid Build Coastguard Worker endif() 35*bb86c7edSAndroid Build Coastguard Worker 36*bb86c7edSAndroid Build Coastguard Worker set(_NAME "${_RULE_NAME}") 37*bb86c7edSAndroid Build Coastguard Worker 38*bb86c7edSAndroid Build Coastguard Worker add_executable(${_NAME} "") 39*bb86c7edSAndroid Build Coastguard Worker target_sources(${_NAME} 40*bb86c7edSAndroid Build Coastguard Worker PRIVATE 41*bb86c7edSAndroid Build Coastguard Worker ${_RULE_SRCS} 42*bb86c7edSAndroid Build Coastguard Worker ) 43*bb86c7edSAndroid Build Coastguard Worker set_target_properties(${_NAME} PROPERTIES OUTPUT_NAME "${_RULE_NAME}") 44*bb86c7edSAndroid Build Coastguard Worker ruy_include_directories(${_NAME} "${_RULE_DEPS}") 45*bb86c7edSAndroid Build Coastguard Worker target_compile_options(${_NAME} 46*bb86c7edSAndroid Build Coastguard Worker PRIVATE 47*bb86c7edSAndroid Build Coastguard Worker ${_RULE_COPTS} 48*bb86c7edSAndroid Build Coastguard Worker ) 49*bb86c7edSAndroid Build Coastguard Worker target_link_options(${_NAME} 50*bb86c7edSAndroid Build Coastguard Worker PRIVATE 51*bb86c7edSAndroid Build Coastguard Worker ${_RULE_LINKOPTS} 52*bb86c7edSAndroid Build Coastguard Worker ) 53*bb86c7edSAndroid Build Coastguard Worker target_link_libraries(${_NAME} 54*bb86c7edSAndroid Build Coastguard Worker PUBLIC 55*bb86c7edSAndroid Build Coastguard Worker ${_RULE_DEPS} 56*bb86c7edSAndroid Build Coastguard Worker ) 57*bb86c7edSAndroid Build Coastguard Workerendfunction() 58