From 149fb0b8907dc4fcb030898dff72dd1dbeeb0fd7 Mon Sep 17 00:00:00 2001 From: Alexey Geraskin Date: Fri, 19 Jul 2019 13:31:27 +0300 Subject: [PATCH] [C++] Keep only one optional parameter to compile_flatbuffers_schema_to_cpp_opt --- CMakeLists.txt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d201dce2c..40896905d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,26 +310,24 @@ if(FLATBUFFERS_BUILD_SHAREDLIB) VERSION "${FlatBuffers_Library_SONAME_FULL}") endif() -function(compile_flatbuffers_schema_to_cpp_with_add_options SRC_FBS NO_INCLUDES GEN_COMPARE ADD_OPTIONS) +function(compile_flatbuffers_schema_to_cpp_opt SRC_FBS OPT) 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 --gen-mutable ${NO_INCLUDES} - --gen-object-api ${GEN_COMPARE} -o "${SRC_FBS_DIR}" + COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c + --gen-object-api --gen-compare -o "${SRC_FBS_DIR}" --cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs - --reflect-names ${ADD_OPTIONS} + --reflect-names ${OPT} -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_with_add_options(${SRC_FBS} --no-includes --gen-compare "") + compile_flatbuffers_schema_to_cpp_opt(${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}) @@ -342,8 +340,8 @@ endfunction() if(FLATBUFFERS_BUILD_TESTS) compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs) - 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) + compile_flatbuffers_schema_to_cpp_opt(tests/native_type_test.fbs "") + compile_flatbuffers_schema_to_cpp_opt(tests/arrays_test.fbs --scoped-enums) include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests) add_executable(flattests ${FlatBuffers_Tests_SRCS}) set_property(TARGET flattests