Merge pull request #23092 from webosbrew/feature/webOS
[xbmc.git] / cmake / modules / FindFlatBuffers.cmake
blobfffac4fae7390cc7a08e79dcb78f9cbcf957d3fd
1 # FindFlatBuffers
2 # --------
3 # Find the FlatBuffers schema compiler and headers
5 # This will define the following variables:
7 # FLATBUFFERS_FOUND - system has FlatBuffers compiler and headers
8 # FLATBUFFERS_INCLUDE_DIRS - the FlatFuffers include directory
9 # FLATBUFFERS_MESSAGES_INCLUDE_DIR - the directory for generated headers
11 find_package(FlatC REQUIRED)
13 if(ENABLE_INTERNAL_FLATBUFFERS)
14   include(cmake/scripts/common/ModuleHelpers.cmake)
16   set(MODULE_LC flatbuffers)
18   SETUP_BUILD_VARS()
20   # Override build type detection and always build as release
21   set(FLATBUFFERS_BUILD_TYPE Release)
23   set(CMAKE_ARGS -DFLATBUFFERS_CODE_COVERAGE=OFF
24                  -DFLATBUFFERS_BUILD_TESTS=OFF
25                  -DFLATBUFFERS_INSTALL=ON
26                  -DFLATBUFFERS_BUILD_FLATLIB=OFF
27                  -DFLATBUFFERS_BUILD_FLATC=OFF
28                  -DFLATBUFFERS_BUILD_FLATHASH=OFF
29                  -DFLATBUFFERS_BUILD_GRPCTEST=OFF
30                  -DFLATBUFFERS_BUILD_SHAREDLIB=OFF
31                  "${EXTRA_ARGS}")
32   set(BUILD_BYPRODUCTS ${DEPENDS_PATH}/include/flatbuffers/flatbuffers.h)
34   BUILD_DEP_TARGET()
35 else()
36   find_path(FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h)
37 endif()
39 include(FindPackageHandleStandardArgs)
40 find_package_handle_standard_args(FlatBuffers
41                                   REQUIRED_VARS FLATBUFFERS_INCLUDE_DIR
42                                   VERSION_VAR FLATBUFFERS_VER)
44 if(FLATBUFFERS_FOUND)
45   set(FLATBUFFERS_MESSAGES_INCLUDE_DIR ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/RetroPlayer/messages CACHE INTERNAL "Generated FlatBuffer headers")
46   set(FLATBUFFERS_INCLUDE_DIRS ${FLATBUFFERS_INCLUDE_DIR} ${FLATBUFFERS_MESSAGES_INCLUDE_DIR})
48   if(NOT TARGET flatbuffers::flatbuffers)
49     add_library(flatbuffers::flatbuffers UNKNOWN IMPORTED)
50     set_target_properties(flatbuffers::flatbuffers PROPERTIES
51                                FOLDER "External Projects"
52                                INTERFACE_INCLUDE_DIRECTORIES ${FLATBUFFERS_INCLUDE_DIR})
53   endif()
55   add_dependencies(flatbuffers::flatbuffers flatbuffers::flatc)
57   if(TARGET flatbuffers)
58     add_dependencies(flatbuffers::flatbuffers flatbuffers)
59   endif()
60   set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP flatbuffers::flatbuffers)
61 endif()
63 mark_as_advanced(FLATBUFFERS_INCLUDE_DIR)