Have cmake copy flatbuffer schema files to simplify dev (#3446)
This commit is contained in:
parent
84f4efd593
commit
4e2ffe9993
2 changed files with 10 additions and 14 deletions
|
|
@ -48,6 +48,12 @@ foreach(file ${files})
|
|||
message(
|
||||
"Generating flatbuffers code for: ${flatbuffers_filename} into ${CMAKE_CURRENT_SOURCE_DIR}/generated/flatbuffers"
|
||||
)
|
||||
|
||||
configure_file(
|
||||
${file}
|
||||
${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/api/flatbuffers/${flatbuffers_filename}.fbs
|
||||
COPYONLY)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/generated/flatbuffers/${flatbuffers_filename}_generated.h
|
||||
|
|
|
|||
|
|
@ -35,25 +35,15 @@ std::string make_error_response (std::string const & error_message)
|
|||
|
||||
/**
|
||||
* Returns the 'api/flatbuffers' directory, boost::none if not found.
|
||||
* This searches the binary path as well as the parent (which is mostly useful for development)
|
||||
*/
|
||||
boost::optional<boost::filesystem::path> get_api_path ()
|
||||
{
|
||||
auto parent_path = boost::dll::program_location ().parent_path ();
|
||||
if (!boost::filesystem::exists (parent_path / "api" / "flatbuffers"))
|
||||
boost::filesystem::path const fb_path = "api/flatbuffers";
|
||||
if (!boost::filesystem::exists (fb_path))
|
||||
{
|
||||
// See if the parent directory has the api subdirectories
|
||||
if (parent_path.has_parent_path ())
|
||||
{
|
||||
parent_path = boost::dll::program_location ().parent_path ().parent_path ();
|
||||
}
|
||||
|
||||
if (!boost::filesystem::exists (parent_path / "api" / "flatbuffers"))
|
||||
{
|
||||
return boost::none;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
return parent_path / "api" / "flatbuffers";
|
||||
return fb_path;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue