zephyr/modules/thrift/cmake/thrift.cmake
Chris Friedt 0c00a3ea79 modules: add thrift module
Add glue code for the thrift module. This includes:
* workarounds for Zephyr's missing C++ facilities
* thrift config.h

This code was merged from the following repository
at the commit specified below, with minor formatting
and coding-style modifications.

https://github.com/zephyrproject-rtos/gsoc-2022-thrift
e12e014d295918cc5ba0b4c507d1bf595a2f539a

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-02-09 20:30:21 +09:00

34 lines
971 B
CMake

# Copyright 2022 Meta
# SPDX-License-Identifier: Apache-2.0
find_program(THRIFT_EXECUTABLE thrift)
if(NOT THRIFT_EXECUTABLE)
message(FATAL_ERROR "The 'thrift' command was not found")
endif()
function(thrift
target # CMake target (for dependencies / headers)
lang # The language for generated sources
lang_opts # Language options (e.g. ':no_skeleton')
out_dir # Output directory for generated files
# (do not include 'gen-cpp', etc)
source_file # The .thrift source file
options # Additional thrift options
# Generated files in ${ARGN}
)
file(MAKE_DIRECTORY ${out_dir})
add_custom_command(
OUTPUT ${ARGN}
COMMAND
${THRIFT_EXECUTABLE}
--gen ${lang}${lang_opts}
-o ${out_dir}
${source_file}
${options}
DEPENDS ${source_file}
)
target_include_directories(${target} PRIVATE ${out_dir}/gen-${lang})
endfunction()