-
Notifications
You must be signed in to change notification settings - Fork 129
Fix flatbuffer builds for upcoming release #730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c8b399b
55bfcf7
1f113a3
ba5b394
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
[submodule "flatbuffers"] | ||
path = flatbuffers | ||
url = https://github.com/google/flatbuffers.git | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,9 +100,10 @@ protobuf_generate_cpp(PROTO_SRCS PROTO_HEADERS ${OSI_PROTO_FILES}) | |
set(FLAT_HEADERS "") | ||
if(OSI_BUILD_FLATBUFFER) | ||
set(FLAT_FBS "") | ||
add_subdirectory("flatbuffers" | ||
${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build | ||
EXCLUDE_FROM_ALL) | ||
find_package(flatbuffers REQUIRED) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment above. |
||
if(NOT FLATBUFFERS_FLATC_EXECUTABLE) | ||
set(FLATBUFFERS_FLATC_EXECUTABLE ${flatbuffers_DIR}/../../tools/flatbuffers/flatc) | ||
endif() | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/descriptor.fbs" "namespace osi3;") | ||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include") | ||
list(APPEND FLAT_FBS "${CMAKE_CURRENT_BINARY_DIR}/descriptor.fbs") | ||
|
@@ -111,9 +112,9 @@ if(OSI_BUILD_FLATBUFFER) | |
set(fbs "${proto_base}.fbs") | ||
add_custom_command( | ||
OUTPUT "${fbs}" | ||
COMMAND $<TARGET_FILE:flatc> -I "${PROTOBUF_IMPORT_DIRS}" -o "${CMAKE_CURRENT_BINARY_DIR}" --proto "${CMAKE_CURRENT_SOURCE_DIR}/${proto}" | ||
DEPENDS "${proto}" flatc | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" | ||
COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -I "${PROTOBUF_IMPORT_DIRS}" -I "${CMAKE_CURRENT_BINARY_DIR}" -o "${CMAKE_CURRENT_BINARY_DIR}" --proto "${proto}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change fixing an issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes:
|
||
DEPENDS "${proto}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
COMMENT "Convert ${proto} to ${fbs} using flatc" | ||
) | ||
list(APPEND FLAT_FBS "${CMAKE_CURRENT_BINARY_DIR}/${fbs}") | ||
|
@@ -125,8 +126,8 @@ if(OSI_BUILD_FLATBUFFER) | |
set(fbh "${flat_base}_generated.h") | ||
add_custom_command( | ||
OUTPUT "include/${fbh}" | ||
COMMAND $<TARGET_FILE:flatc> -o "${CMAKE_CURRENT_BINARY_DIR}/include" --cpp --gen-mutable --gen-name-strings --scoped-enums "${fbs}" | ||
DEPENDS "${FLAT_FBS}" flatc | ||
COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -o "${CMAKE_CURRENT_BINARY_DIR}/include" --cpp --gen-mutable --gen-name-strings --scoped-enums "${fbs}" | ||
DEPENDS "${FLAT_FBS}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" | ||
COMMENT "Process ${fbs} to ${fbh} using flatc" | ||
) | ||
|
@@ -135,9 +136,10 @@ if(OSI_BUILD_FLATBUFFER) | |
|
||
add_custom_target(${PROJECT_NAME}_fbs_build ALL DEPENDS "${FLAT_HEADERS}") | ||
add_library(${PROJECT_NAME}_fbs INTERFACE) | ||
add_library(${PROJECT_NAME}::${PROJECT_NAME}_fbs ALIAS ${PROJECT_NAME}_fbs) | ||
target_include_directories(${PROJECT_NAME}_fbs INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/>) | ||
target_include_directories(${PROJECT_NAME}_fbs SYSTEM INTERFACE $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>) | ||
target_link_libraries(${PROJECT_NAME}_fbs INTERFACE flatbuffers) | ||
target_link_libraries(${PROJECT_NAME}_fbs INTERFACE flatbuffers::flatbuffers) | ||
endif() | ||
|
||
add_library(${PROJECT_NAME}_static STATIC ${PROTO_SRCS} ${PROTO_HEADERS}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit surprised that the submodule is deleted here and
find_package
is used in CMakeLists instead. @pmai why do you suggest this particular change?Background info: I find it very convenient to use a submodule here and not have the dependency on an (possibly) existing package. It is one of the pro-points on the list for flatbuffers that this is somehow possible..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I also found this somewhat convenient, it has its own problems (both in nailing down the version of flatbuffers needlessly, and not making it easy to configure for different target settings), and it is not what we do for protobuf. And with todays availability of vcpkg and others for installing flatbuffers, it seems better to stay consistently out of the submodule business for these kinds of dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. On the other side, nailing down the version of flatbuffers (and possibly protobuf) could prevent some missunderstandings in combining different models / tool plugins. The flexibility to configure for different target settings is indeed very important for our project. So if using submodules can be a problem to this point, I am ok with the change here.