]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/cpp/src/arrow/dbi/hiveserver2/thrift/CMakeLists.txt
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / cpp / src / arrow / dbi / hiveserver2 / thrift / CMakeLists.txt
1 # Copyright 2012 Cloudera Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Helper function to generate build rules. For each input thrift file, this function will
16 # generate a rule that maps the input file to the output c++ file.
17 # Thrift will generate multiple output files for each input (including java files) and
18 # ideally, we'd specify all of the outputs for dependency tracking.
19 # Unfortunately, it's not easy to figure out all the output files without parsing the
20 # thrift input. (TODO: can thrift tells us what the java output files will be?)
21 # The list of output files is used for build dependency tracking so it's not necessary to
22 # capture all the output files.
23 #
24 # To call this function, pass it the output file list followed by the input thrift files:
25 # i.e. HS2_THRIFT_GEN(OUTPUT_FILES, ${THRIFT_FILES})
26 #
27 # cmake seems to be case sensitive for some keywords. Changing the first IF check to lower
28 # case makes it not work. TODO: investigate this
29 function(HS2_THRIFT_GEN VAR)
30 if(NOT ARGN)
31 message(SEND_ERROR "Error: THRIFT_GEN called without any src files")
32 return()
33 endif(NOT ARGN)
34
35 set(${VAR})
36 foreach(FIL ${ARGN})
37 # Get full path
38 get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
39 # Get basename
40 get_filename_component(FIL_WE ${FIL} NAME_WE)
41
42 set(GEN_DIR "${OUTPUT_DIR}/arrow/dbi/hiveserver2")
43
44 # All the output files we can determine based on filename.
45 # - Does not include .skeleton.cpp files
46 # - Does not include java output files
47 set(OUTPUT_BE_FILE
48 "${GEN_DIR}/${FIL_WE}_types.cpp" "${GEN_DIR}/${FIL_WE}_types.h"
49 "${GEN_DIR}/${FIL_WE}_constants.cpp" "${GEN_DIR}/${FIL_WE}_constants.h")
50 list(APPEND ${VAR} ${OUTPUT_BE_FILE})
51
52 # BeeswaxService thrift generation
53 # It depends on hive_meta_store, which in turn depends on fb303.
54 # The java dependency is handled by maven.
55 # We need to generate C++ src file for the parent dependencies using the "-r" option.
56 set(CPP_ARGS
57 -nowarn
58 --gen
59 cpp
60 -out
61 ${GEN_DIR})
62 if(FIL STREQUAL "beeswax.thrift")
63 set(CPP_ARGS
64 -r
65 -nowarn
66 --gen
67 cpp
68 -out
69 ${GEN_DIR})
70 endif(FIL STREQUAL "beeswax.thrift")
71
72 # Be able to include generated ErrorCodes.thrift file
73 set(CPP_ARGS ${CPP_ARGS} -I ${CMAKE_CURRENT_BINARY_DIR})
74
75 add_custom_command(OUTPUT ${OUTPUT_BE_FILE}
76 COMMAND ${THRIFT_COMPILER} ${CPP_ARGS} ${FIL}
77 DEPENDS ${ABS_FIL}
78 COMMENT "Running thrift compiler on ${FIL}"
79 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
80 VERBATIM)
81 endforeach(FIL)
82
83 set(${VAR}
84 ${${VAR}}
85 PARENT_SCOPE)
86 endfunction(HS2_THRIFT_GEN)
87
88 message("Using Thrift compiler: ${THRIFT_COMPILER}")
89
90 set(OUTPUT_DIR ${ARROW_BINARY_DIR}/src)
91 file(MAKE_DIRECTORY ${OUTPUT_DIR})
92
93 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ErrorCodes.thrift
94 COMMAND python generate_error_codes.py ${CMAKE_CURRENT_BINARY_DIR}
95 DEPENDS generate_error_codes.py
96 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
97
98 set(SRC_FILES
99 ${CMAKE_CURRENT_BINARY_DIR}/ErrorCodes.thrift
100 beeswax.thrift
101 TCLIService.thrift
102 ExecStats.thrift
103 ImpalaService.thrift
104 Status.thrift
105 Types.thrift)
106
107 set_source_files_properties(Status.thrift
108 PROPERTIES OBJECT_DEPENDS
109 ${CMAKE_CURRENT_BINARY_DIR}/ErrorCodes.thrift)
110
111 # Create a build command for each of the thrift src files and generate
112 # a list of files they produce
113 hs2_thrift_gen(THRIFT_ALL_FILES ${SRC_FILES})
114
115 # Add a custom target that generates all the thrift files
116 add_custom_target(hs2-thrift-cpp ALL DEPENDS ${THRIFT_ALL_FILES})
117
118 add_custom_target(hs2-thrift-generated-files-error
119 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ErrorCodes.thrift)
120 add_dependencies(hs2-thrift-cpp hs2-thrift-generated-files-error)