Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
3f8700b2
Commit
3f8700b2
authored
Sep 15, 2014
by
Zbigniew Mandziejewicz
Committed by
Wouter van Oortmerssen
Sep 22, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate headers from spec, add option for installing targets
Change-Id: I16ddb06e887e618fa871e842054115909fbf235c
parent
048638a9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
CMakeLists.txt
CMakeLists.txt
+29
-13
monster_generated.h
samples/monster_generated.h
+2
-2
No files found.
CMakeLists.txt
View file @
3f8700b2
...
...
@@ -5,6 +5,7 @@ project(FlatBuffers)
# NOTE: Code coverage only works on Linux & OSX.
option
(
FLATBUFFERS_CODE_COVERAGE
"Enable the code coverage build option."
OFF
)
option
(
FLATBUFFERS_BUILD_TESTS
"Enable the build of tests and samples."
ON
)
option
(
FLATBUFFERS_INSTALL
"Enable the installation of targets."
ON
)
set
(
FlatBuffers_Compiler_SRCS
include/flatbuffers/flatbuffers.h
...
...
@@ -26,14 +27,14 @@ set(FlatBuffers_Tests_SRCS
src/idl_gen_text.cpp
tests/test.cpp
# file generate by running compiler on tests/monster_test.fbs
tests/monster_test_generated.h
${
CMAKE_CURRENT_BINARY_DIR
}
/
tests/monster_test_generated.h
)
set
(
FlatBuffers_Sample_Binary_SRCS
include/flatbuffers/flatbuffers.h
samples/sample_binary.cpp
# file generate by running compiler on samples/monster.fbs
samples/monster_generated.h
# file generate
d
by running compiler on samples/monster.fbs
${
CMAKE_CURRENT_BINARY_DIR
}
/
samples/monster_generated.h
)
set
(
FlatBuffers_Sample_Text_SRCS
...
...
@@ -43,12 +44,10 @@ set(FlatBuffers_Sample_Text_SRCS
src/idl_parser.cpp
src/idl_gen_text.cpp
samples/sample_text.cpp
# file generate by running compiler on samples/monster.fbs
samples/monster_generated.h
# file generate
d
by running compiler on samples/monster.fbs
${
CMAKE_CURRENT_BINARY_DIR
}
/
samples/monster_generated.h
)
set
(
CMAKE_BUILD_TYPE Debug
)
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
...
...
@@ -69,18 +68,35 @@ endif()
include_directories
(
include
)
add_executable
(
flatc
${
FlatBuffers_Compiler_SRCS
}
)
function
(
compile_flatbuffers_schema_to_cpp SRC_FBS
)
get_filename_component
(
SRC_FBS_DIR
${
SRC_FBS
}
DIRECTORY
)
string
(
REGEX REPLACE
".fbs$"
"_generated.h"
GEN_HEADER
${
SRC_FBS
}
)
add_custom_command
(
OUTPUT
${
GEN_HEADER
}
COMMAND flatc -c -o
"
${
SRC_FBS_DIR
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SRC_FBS
}
"
DEPENDS flatc
)
endfunction
()
if
(
FLATBUFFERS_BUILD_TESTS
)
compile_flatbuffers_schema_to_cpp
(
tests/monster_test.fbs
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
/tests
)
add_executable
(
flattests
${
FlatBuffers_Tests_SRCS
}
)
compile_flatbuffers_schema_to_cpp
(
samples/monster.fbs
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
/samples
)
add_executable
(
flatsamplebinary
${
FlatBuffers_Sample_Binary_SRCS
}
)
add_executable
(
flatsampletext
${
FlatBuffers_Sample_Text_SRCS
}
)
endif
()
install
(
DIRECTORY include/flatbuffers DESTINATION include
)
install
(
TARGETS flatc DESTINATION bin
)
if
(
FLATBUFFERS_INSTALL
)
install
(
DIRECTORY include/flatbuffers DESTINATION include
)
install
(
TARGETS flatc DESTINATION bin
)
endif
()
if
(
FLATBUFFERS_BUILD_TESTS
)
add_test
(
NAME flattest
CONFIGURATIONS Debug
WORKING_DIRECTORY tests
COMMAND flattests
)
enable_testing
()
file
(
COPY
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/tests"
DESTINATION
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
)
add_test
(
NAME flattests
COMMAND flattests
)
endif
()
samples/monster_generated.h
View file @
3f8700b2
...
...
@@ -37,7 +37,7 @@ inline const char **EnumNamesAny() {
inline
const
char
*
EnumNameAny
(
int
e
)
{
return
EnumNamesAny
()[
e
];
}
bool
VerifyAny
(
flatbuffers
::
Verifier
&
verifier
,
const
void
*
union_obj
,
uint8_t
type
);
inline
bool
VerifyAny
(
flatbuffers
::
Verifier
&
verifier
,
const
void
*
union_obj
,
uint8_t
type
);
MANUALLY_ALIGNED_STRUCT
(
4
)
Vec3
{
private
:
...
...
@@ -107,7 +107,7 @@ inline flatbuffers::Offset<Monster> CreateMonster(flatbuffers::FlatBufferBuilder
return
builder_
.
Finish
();
}
bool
VerifyAny
(
flatbuffers
::
Verifier
&
verifier
,
const
void
*
union_obj
,
uint8_t
type
)
{
inline
bool
VerifyAny
(
flatbuffers
::
Verifier
&
verifier
,
const
void
*
union_obj
,
uint8_t
type
)
{
switch
(
type
)
{
case
Any_NONE
:
return
true
;
case
Any_Monster
:
return
verifier
.
VerifyTable
(
reinterpret_cast
<
const
Monster
*>
(
union_obj
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment