diff options
author | Aaron Seigo <aseigo@kde.org> | 2014-11-30 13:05:19 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2014-11-30 13:05:19 +0100 |
commit | 97b79eeb86eedee57630b8d29f6eeab08ccb02b0 (patch) | |
tree | f1944c54ac2ab4650221974e81dc14809550cc7c /cmake/modules/FindFlatBuffers.cmake | |
parent | 0bcfc57f24adf8ce8dfb2fad33b294b5f0110a89 (diff) | |
download | sink-97b79eeb86eedee57630b8d29f6eeab08ccb02b0.tar.gz sink-97b79eeb86eedee57630b8d29f6eeab08ccb02b0.zip |
add flatbuffer support and use that for the handshake
Diffstat (limited to 'cmake/modules/FindFlatBuffers.cmake')
-rw-r--r-- | cmake/modules/FindFlatBuffers.cmake | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/cmake/modules/FindFlatBuffers.cmake b/cmake/modules/FindFlatBuffers.cmake new file mode 100644 index 0000000..0a54e2a --- /dev/null +++ b/cmake/modules/FindFlatBuffers.cmake | |||
@@ -0,0 +1,56 @@ | |||
1 | # Copyright 2014 Stefan.Eilemann@epfl.ch | ||
2 | # Copyright 2014 Google Inc. All rights reserved. | ||
3 | # | ||
4 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | # you may not use this file except in compliance with the License. | ||
6 | # You may obtain a copy of the License at | ||
7 | # | ||
8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | # | ||
10 | # Unless required by applicable law or agreed to in writing, software | ||
11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | # See the License for the specific language governing permissions and | ||
14 | # limitations under the License. | ||
15 | |||
16 | # Find the flatbuffers schema compiler | ||
17 | # | ||
18 | # Output Variables: | ||
19 | # * FLATBUFFERS_FLATC_EXECUTABLE the flatc compiler executable | ||
20 | # * FLATBUFFERS_FOUND | ||
21 | # | ||
22 | # Provides: | ||
23 | # * FLATBUFFERS_GENERATE_C_HEADERS(Name <files>) creates the C++ headers | ||
24 | # for the given flatbuffer schema files. | ||
25 | # Returns the header files in ${Name}_OUTPUTS | ||
26 | |||
27 | find_program(FLATBUFFERS_FLATC_EXECUTABLE NAMES flatc) | ||
28 | find_path(FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h) | ||
29 | |||
30 | include(FindPackageHandleStandardArgs) | ||
31 | find_package_handle_standard_args(flatbuffers | ||
32 | DEFAULT_MSG FLATBUFFERS_FLATC_EXECUTABLE FLATBUFFERS_INCLUDE_DIR) | ||
33 | |||
34 | if(FLATBUFFERS_FOUND) | ||
35 | function(FLATBUFFERS_GENERATE_C_HEADERS Name) | ||
36 | set(FLATC_OUTPUTS) | ||
37 | foreach(FILE ${ARGN}) | ||
38 | get_filename_component(FLATC_OUTPUT ${FILE} NAME_WE) | ||
39 | set(FLATC_OUTPUT | ||
40 | "${CMAKE_CURRENT_BINARY_DIR}/${FLATC_OUTPUT}_generated.h") | ||
41 | list(APPEND FLATC_OUTPUTS ${FLATC_OUTPUT}) | ||
42 | |||
43 | add_custom_command(OUTPUT ${FLATC_OUTPUT} | ||
44 | COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} | ||
45 | ARGS -c -o "${CMAKE_CURRENT_BINARY_DIR}/" ${FILE} | ||
46 | COMMENT "Building C++ header for ${FILE}" | ||
47 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | ||
48 | endforeach() | ||
49 | set(${Name}_OUTPUTS ${FLATC_OUTPUTS} PARENT_SCOPE) | ||
50 | endfunction() | ||
51 | |||
52 | set(FLATBUFFERS_INCLUDE_DIRS ${FLATBUFFERS_INCLUDE_DIR}) | ||
53 | include_directories(${CMAKE_BINARY_DIR}) | ||
54 | else() | ||
55 | set(FLATBUFFERS_INCLUDE_DIR) | ||
56 | endif() | ||