From d6d83c3a9241403f1179df171d87a77b721d09c2 Mon Sep 17 00:00:00 2001 From: KerstinKeller Date: Wed, 26 Apr 2023 07:27:14 +0200 Subject: [PATCH] Allow to use functions from `BuildFlatBuffers.cmake` from a flatbuffers installation installed with CMake. (#7912) Co-authored-by: Derek Bailey --- CMake/BuildFlatBuffers.cmake | 9 +++++++++ CMake/flatbuffers-config.cmake | 1 + 2 files changed, 10 insertions(+) diff --git a/CMake/BuildFlatBuffers.cmake b/CMake/BuildFlatBuffers.cmake index 9adba7dc8..631e5adfb 100644 --- a/CMake/BuildFlatBuffers.cmake +++ b/CMake/BuildFlatBuffers.cmake @@ -59,6 +59,9 @@ function(build_flatbuffers flatbuffers_schemas if(FLATBUFFERS_FLATC_EXECUTABLE) set(FLATC_TARGET "") set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE}) + elseif(TARGET flatbuffers::flatc) + set(FLATC_TARGET flatbuffers::flatc) + set(FLATC flatbuffers::flatc) else() set(FLATC_TARGET flatc) set(FLATC flatc) @@ -211,6 +214,9 @@ function(flatbuffers_generate_headers) if(FLATBUFFERS_FLATC_EXECUTABLE) set(FLATC_TARGET "") set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE}) + elseif(TARGET flatbuffers::flatc) + set(FLATC_TARGET flatbuffers::flatc) + set(FLATC flatbuffers::flatc) else() set(FLATC_TARGET flatc) set(FLATC flatc) @@ -382,6 +388,9 @@ function(flatbuffers_generate_binary_files) if(FLATBUFFERS_FLATC_EXECUTABLE) set(FLATC_TARGET "") set(FLATC ${FLATBUFFERS_FLATC_EXECUTABLE}) + elseif(TARGET flatbuffers::flatc) + set(FLATC_TARGET flatbuffers::flatc) + set(FLATC flatbuffers::flatc) else() set(FLATC_TARGET flatc) set(FLATC flatc) diff --git a/CMake/flatbuffers-config.cmake b/CMake/flatbuffers-config.cmake index 592fc79b6..0c32c2fe2 100644 --- a/CMake/flatbuffers-config.cmake +++ b/CMake/flatbuffers-config.cmake @@ -1,3 +1,4 @@ include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersTargets.cmake" OPTIONAL) include("${CMAKE_CURRENT_LIST_DIR}/FlatcTargets.cmake" OPTIONAL) include("${CMAKE_CURRENT_LIST_DIR}/FlatBuffersSharedTargets.cmake" OPTIONAL) +include("${CMAKE_CURRENT_LIST_DIR}/BuildFlatBuffers.cmake" OPTIONAL) \ No newline at end of file