]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/compiler/cpp/tests/CMakeLists.txt
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / compiler / cpp / tests / CMakeLists.txt
CommitLineData
f67539c2
TL
1#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19cmake_minimum_required(VERSION 2.8.12)
20
21project(thrift_compiler_tests)
22
23set(THRIFT_COMPILER_SOURCE_DIR
24 ${CMAKE_CURRENT_SOURCE_DIR}/..
25)
26
27# don't generate ZERO_CHECK
28set(CMAKE_SUPPRESS_REGENERATION true)
29
30configure_file(${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/thrift/version.h)
31if(MSVC)
32 # The winflexbison generator outputs some macros that conflict with the Visual Studio 2010 copy of stdint.h
33 # This might be fixed in later versions of Visual Studio, but an easy solution is to include stdint.h first
34 if(HAVE_STDINT_H)
35 add_definitions(-D__STDC_LIMIT_MACROS)
36 add_definitions(/FI"stdint.h")
37 endif(HAVE_STDINT_H)
38endif()
39
40find_package(FLEX REQUIRED)
41find_package(BISON REQUIRED)
42
43# create directory for thrifty and thriftl
44file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thrift/)
45
46# Create flex and bison files and build the lib parse static library
47BISON_TARGET(thrifty ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/thrifty.yy ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.cc)
48FLEX_TARGET(thriftl ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/thriftl.ll ${CMAKE_CURRENT_BINARY_DIR}/thrift/thriftl.cc)
49ADD_FLEX_BISON_DEPENDENCY(thriftl thrifty)
50
51set(parse_SOURCES
52 ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.cc
53 ${CMAKE_CURRENT_BINARY_DIR}/thrift/thriftl.cc
54 ${CMAKE_CURRENT_BINARY_DIR}/thrift/thrifty.hh
55)
56
57add_library(parse STATIC ${parse_SOURCES})
58
59# Thrift compiler tests
60set(thrift_compiler_tests
61)
62
63# you can add some files manually there
64set(thrift_compiler_tests_manual_SOURCES
65 # tests file to avoid main in every test file
66 ${CMAKE_CURRENT_SOURCE_DIR}/tests_main.cc
67)
68
69# set variable for tests sources - will be filled later
70set(thrift_compiler_tests_SOURCES
71)
72
73set(thrift_compiler_SOURCES
74 ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/logging.cc # we use logging instead of main to avoid breaking compillation (2 main v)
75 ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/audit/t_audit.cpp
76 ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/common.cc
77 ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/generate/t_generator.cc
78 ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/parse/t_typedef.cc
79 ${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/parse/parse.cc
80 ${CMAKE_CURRENT_BINARY_DIR}/thrift/version.h
81)
82
83# This macro adds an option THRIFT_COMPILER_${NAME}
84# that allows enabling or disabling certain languages
85macro(THRIFT_ADD_COMPILER name description initial)
86 string(TOUPPER "THRIFT_COMPILER_${name}" enabler)
87 set(src "${THRIFT_COMPILER_SOURCE_DIR}/src/thrift/generate/t_${name}_generator.cc")
88 option(${enabler} ${description} ${initial})
89 if(${enabler})
90 list(APPEND thrift_compiler_SOURCES ${src})
91 file(GLOB thrift_compiler_tests_SOURCES
92 "${CMAKE_CURRENT_SOURCE_DIR}/${name}/*.c*"
93 "${CMAKE_CURRENT_SOURCE_DIR}/${name}/*.thrift"
94 )
95 endif()
96endmacro()
97
98# The following compiler with unit tests can be enabled or disabled
99THRIFT_ADD_COMPILER(as3 "Enable compiler for ActionScript 3" OFF)
100THRIFT_ADD_COMPILER(c_glib "Enable compiler for C with Glib" OFF)
101THRIFT_ADD_COMPILER(cl "Enable compiler for Common LISP" OFF)
102THRIFT_ADD_COMPILER(cpp "Enable compiler for C++" OFF)
103THRIFT_ADD_COMPILER(csharp "Enable compiler for C#" OFF)
104THRIFT_ADD_COMPILER(d "Enable compiler for D" OFF)
105THRIFT_ADD_COMPILER(dart "Enable compiler for Dart" OFF)
106THRIFT_ADD_COMPILER(delphi "Enable compiler for Delphi" OFF)
107THRIFT_ADD_COMPILER(erl "Enable compiler for Erlang" OFF)
108THRIFT_ADD_COMPILER(go "Enable compiler for Go" OFF)
109THRIFT_ADD_COMPILER(gv "Enable compiler for GraphViz" OFF)
110THRIFT_ADD_COMPILER(haxe "Enable compiler for Haxe" OFF)
111THRIFT_ADD_COMPILER(hs "Enable compiler for Haskell" OFF)
112THRIFT_ADD_COMPILER(html "Enable compiler for HTML Documentation" OFF)
113THRIFT_ADD_COMPILER(java "Enable compiler for Java" OFF)
114THRIFT_ADD_COMPILER(javame "Enable compiler for Java ME" OFF)
115THRIFT_ADD_COMPILER(js "Enable compiler for JavaScript" OFF)
116THRIFT_ADD_COMPILER(json "Enable compiler for JSON" OFF)
117THRIFT_ADD_COMPILER(lua "Enable compiler for Lua" OFF)
118THRIFT_ADD_COMPILER(netcore "Enable compiler for .NET Core" ON)
119THRIFT_ADD_COMPILER(ocaml "Enable compiler for OCaml" OFF)
120THRIFT_ADD_COMPILER(perl "Enable compiler for Perl" OFF)
121THRIFT_ADD_COMPILER(php "Enable compiler for PHP" OFF)
122THRIFT_ADD_COMPILER(py "Enable compiler for Python 2.0" OFF)
123THRIFT_ADD_COMPILER(rb "Enable compiler for Ruby" OFF)
124THRIFT_ADD_COMPILER(rs "Enable compiler for Rust" OFF)
125THRIFT_ADD_COMPILER(st "Enable compiler for Smalltalk" OFF)
126THRIFT_ADD_COMPILER(swift "Enable compiler for Swift" OFF)
127THRIFT_ADD_COMPILER(xml "Enable compiler for XML" OFF)
128THRIFT_ADD_COMPILER(xsd "Enable compiler for XSD" OFF)
129
130# Thrift is looking for include files in the src directory
131# we also add the current binary directory for generated files
132include_directories(${CMAKE_CURRENT_BINARY_DIR} ${THRIFT_COMPILER_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/catch)
133
134add_library(thrift_compiler ${thrift_compiler_SOURCES})
135
136#link parse lib to thrift_compiler lib
137target_link_libraries(thrift_compiler parse)
138
139# add tests executable
140add_executable(thrift_compiler_tests ${thrift_compiler_tests_manual_SOURCES} ${thrift_compiler_tests_SOURCES})
141
142# if generates for Visual Studio set thrift_compiler_tests as default project
143if(MSVC)
144 set_property(TARGET thrift_compiler_tests PROPERTY VS_STARTUP_PROJECT thrift_compiler_tests)
145endif()
146
147set_target_properties(thrift_compiler_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY bin/)
148set_target_properties(thrift_compiler_tests PROPERTIES OUTPUT_NAME thrift_compiler_tests)
149
150target_link_libraries(thrift_compiler_tests thrift_compiler)
151
152enable_testing()
153add_test(NAME ThriftTests COMMAND thrift_compiler_tests)