Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 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 | # |
| 19 | |
| 20 | |
| 21 | if(${WITH_PLUGIN}) |
| 22 | include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") |
| 23 | |
| 24 | # Make sure gen-cpp files can be included |
| 25 | include_directories("${CMAKE_CURRENT_BINARY_DIR}") |
| 26 | |
| 27 | set(plugintest_SOURCES |
| 28 | plugin/conversion_test.cc |
| 29 | ) |
| 30 | add_executable(plugintest ${plugintest_SOURCES}) |
| 31 | if(WITH_SHARED_LIB AND NOT MSVC) |
| 32 | target_link_libraries(plugintest |
| 33 | thriftc |
| 34 | ${Boost_LIBRARIES} |
| 35 | ) |
| 36 | else() |
| 37 | target_link_libraries(plugintest |
| 38 | thriftc_static |
| 39 | thrift_static |
| 40 | ${Boost_LIBRARIES} |
| 41 | ) |
| 42 | endif() |
| 43 | add_test(NAME PluginUnitTest COMMAND plugintest) |
| 44 | |
| 45 | set(thrift-gen-mycpp_SOURCES |
dtmuller | 052abc3 | 2016-07-26 11:58:28 +0200 | [diff] [blame] | 46 | ../src/thrift/generate/t_cpp_generator.cc |
Nobuaki Sukegawa | 11da87e | 2016-09-10 14:02:19 +0900 | [diff] [blame] | 47 | plugin/cpp_plugin.cc |
| 48 | ) |
| 49 | add_executable(thrift-gen-mycpp ${thrift-gen-mycpp_SOURCES}) |
| 50 | if(WITH_SHARED_LIB AND NOT MSVC) |
| 51 | target_link_libraries(thrift-gen-mycpp thriftc) |
| 52 | else() |
| 53 | target_link_libraries(thrift-gen-mycpp thriftc_static thrift_static) |
| 54 | endif() |
| 55 | |
| 56 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 57 | set(BUILDTYPE "Debug") |
| 58 | else() |
| 59 | # RelWithDebInfo generates binaries in "Release" directory too |
| 60 | set(BUILDTYPE "Release") |
| 61 | endif() |
| 62 | |
| 63 | set_directory_properties(PROPERTIES |
| 64 | ADDITIONAL_MAKE_CLEAN_FILES gen-cpp |
| 65 | ADDITIONAL_MAKE_CLEAN_FILES gen-mycpp) |
| 66 | |
| 67 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen-cpp) |
| 68 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen-mycpp) |
| 69 | add_test(NAME PluginIntegrationTest |
| 70 | COMMAND ${CMAKE_COMMAND} |
| 71 | -DTHRIFT_COMPILER=${THRIFT_COMPILER} |
| 72 | -DBINDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} |
| 73 | -DBUILDTYPE=${BUILDTYPE} |
| 74 | -DCURDIR=${CMAKE_CURRENT_BINARY_DIR} |
| 75 | -DSRCDIR=${CMAKE_CURRENT_SOURCE_DIR} |
| 76 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cpp_plugin_test.cmake) |
| 77 | endif() |
Mustafa Senol Cosar | 09c1f37 | 2018-04-04 15:25:28 +0300 | [diff] [blame] | 78 | |
nsrtvwls | 014f53f | 2018-09-28 08:11:21 -0700 | [diff] [blame^] | 79 | file(GLOB KEYWORD_SAMPLES "${CMAKE_CURRENT_SOURCE_DIR}/keyword-samples/*.thrift") |
| 80 | foreach(LANG ${thrift_compiler_LANGS}) |
| 81 | foreach(SAMPLE ${KEYWORD_SAMPLES}) |
| 82 | get_filename_component(FILENAME ${SAMPLE} NAME_WE) |
| 83 | add_test(NAME "${LANG}_${FILENAME}" |
| 84 | COMMAND thrift-compiler --gen ${LANG} ${SAMPLE}) |
| 85 | set_tests_properties("${LANG}_${FILENAME}" PROPERTIES |
| 86 | PASS_REGULAR_EXPRESSION "Cannot use reserved language keyword") |
| 87 | endforeach() |
| 88 | endforeach() |
| 89 | |
| 90 | |
Mustafa Senol Cosar | 09c1f37 | 2018-04-04 15:25:28 +0300 | [diff] [blame] | 91 | find_package(PythonInterp REQUIRED) |
nsrtvwls | 014f53f | 2018-09-28 08:11:21 -0700 | [diff] [blame^] | 92 | add_test(NAME StalenessCheckTest COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/compiler/staleness_check.py ${THRIFT_COMPILER}) |