Warning, /pim/sink/cmake/modules/FindFlatBuffers.cmake is written in an unsupported language. File is not indexed.

0001 # Copyright 2014 Stefan.Eilemann@epfl.ch
0002 # Copyright 2014 Google Inc. All rights reserved.
0003 #
0004 # Licensed under the Apache License, Version 2.0 (the "License");
0005 # you may not use this file except in compliance with the License.
0006 # You may obtain a copy of the License at
0007 #
0008 #     http://www.apache.org/licenses/LICENSE-2.0
0009 #
0010 # Unless required by applicable law or agreed to in writing, software
0011 # distributed under the License is distributed on an "AS IS" BASIS,
0012 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013 # See the License for the specific language governing permissions and
0014 # limitations under the License.
0015 
0016 # Find the flatbuffers schema compiler
0017 #
0018 # Output Variables:
0019 # * FLATBUFFERS_FLATC_EXECUTABLE the flatc compiler executable
0020 # * FLATBUFFERS_FOUND
0021 #
0022 # Provides:
0023 # * FLATBUFFERS_GENERATE_C_HEADERS(Name <files>) creates the C++ headers
0024 #   for the given flatbuffer schema files.
0025 #   Returns the header files in ${Name}_OUTPUTS
0026 
0027 find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc)
0028 find_path(FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h)
0029 
0030 include(FindPackageHandleStandardArgs)
0031 find_package_handle_standard_args(FlatBuffers
0032   DEFAULT_MSG FLATBUFFERS_FLATC_EXECUTABLE FLATBUFFERS_INCLUDE_DIR)
0033 
0034 if(FLATBUFFERS_FOUND)
0035   function(FLATBUFFERS_GENERATE_C_HEADERS Name)
0036     set(FLATC_OUTPUTS)
0037     foreach(FILE ${ARGN})
0038       get_filename_component(FLATC_OUTPUT ${FILE} NAME_WE)
0039       set(FLATC_OUTPUT
0040         "${CMAKE_CURRENT_BINARY_DIR}/${FLATC_OUTPUT}_generated.h")
0041       list(APPEND FLATC_OUTPUTS ${FLATC_OUTPUT})
0042 
0043       add_custom_command(OUTPUT ${FLATC_OUTPUT}
0044         COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE}
0045         ARGS -c -o "${CMAKE_CURRENT_BINARY_DIR}/" ${FILE}
0046         COMMENT "Building C++ header for ${FILE}"
0047         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
0048     endforeach()
0049     set(${Name}_OUTPUTS ${FLATC_OUTPUTS} PARENT_SCOPE)
0050   endfunction()
0051 
0052   set(FLATBUFFERS_INCLUDE_DIRS ${FLATBUFFERS_INCLUDE_DIR})
0053   include_directories(${CMAKE_BINARY_DIR})
0054 else()
0055   set(FLATBUFFERS_INCLUDE_DIR)
0056 endif()