From c887c71ac62d0c020aa786d92fabf9f6532b1504 Mon Sep 17 00:00:00 2001 From: Alexey Geraskin Date: Wed, 17 Jul 2019 14:04:44 +0300 Subject: [PATCH] [C++] update CMakeLists to compile native_type_test.fbs properly --- CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 538cef758..d201dce2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,24 +310,26 @@ if(FLATBUFFERS_BUILD_SHAREDLIB) VERSION "${FlatBuffers_Library_SONAME_FULL}") endif() -function(compile_flatbuffers_schema_to_cpp_opt SRC_FBS OPT) +function(compile_flatbuffers_schema_to_cpp_with_add_options SRC_FBS NO_INCLUDES GEN_COMPARE ADD_OPTIONS) get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS}) add_custom_command( OUTPUT ${GEN_HEADER} - COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable - --gen-object-api --gen-compare -o "${SRC_FBS_DIR}" + COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --gen-mutable ${NO_INCLUDES} + --gen-object-api ${GEN_COMPARE} -o "${SRC_FBS_DIR}" --cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs - --reflect-names ${OPT} + --reflect-names ${ADD_OPTIONS} -I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test" "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" DEPENDS flatc) endfunction() + function(compile_flatbuffers_schema_to_cpp SRC_FBS) - compile_flatbuffers_schema_to_cpp_opt(${SRC_FBS} "") + compile_flatbuffers_schema_to_cpp_with_add_options(${SRC_FBS} --no-includes --gen-compare "") endfunction() + function(compile_flatbuffers_schema_to_binary SRC_FBS) get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS}) @@ -340,8 +342,8 @@ endfunction() if(FLATBUFFERS_BUILD_TESTS) compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs) - compile_flatbuffers_schema_to_cpp(tests/native_type_test.fbs) - compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs --scoped-enums) + compile_flatbuffers_schema_to_cpp_with_add_options(tests/native_type_test.fbs "" "" "") + compile_flatbuffers_schema_to_cpp_with_add_options(tests/arrays_test.fbs --no-includes --gen-compare --scoped-enums) include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests) add_executable(flattests ${FlatBuffers_Tests_SRCS}) set_property(TARGET flattests