blob: 4feb27ff97dbbe7c0b6daa533e702a0a0efc3035 [file] [log] [blame]
# Copyright (C) 2016 The Android Open Source Project
#
# 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
#
# http://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.
go_install()
function(embed)
if(DISABLED_CODE_GENERATION OR NOT TARGET embed)
return()
endif()
get_filename_component(name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
cmake_parse_arguments(EMBED "" "OUTPUT;PACKAGE" "" ${ARGN})
default(EMBED_OUTPUT "embed.go")
default(EMBED_PACKAGE ${name})
required(EMBED_UNPARSED_ARGUMENTS "for embed")
set(EMBED_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${EMBED_OUTPUT})
abs_list(EMBED_UNPARSED_ARGUMENTS ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_command(
OUTPUT ${EMBED_OUTPUT}
COMMAND embed --out ${EMBED_OUTPUT} --package ${EMBED_PACKAGE} ${EMBED_UNPARSED_ARGUMENTS}
DEPENDS embed ${EMBED_UNPARSED_ARGUMENTS}
COMMENT "Embed generating ${EMBED_OUTPUT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
all_target(embed ${name} ${EMBED_OUTPUT})
set_source_files_properties(${EMBED_OUTPUT} PROPERTIES GENERATED TRUE)
endfunction(embed)