uResourceGenerator

UtiLite provides a utility application called uResourceGenerator to generate resources to include in an executable. For example:

$ ./uresourcegenerator DatabaseSchema.sql

This will generate a HEX file "DatabaseSchema_sql.h" which can be included in source files. Data of the file is global and can be accessed by the generated const char * DATABASESCHEMA_SQL.

#include "DatabaseSchema_sql.h"
...
std::string hex = DATABASESCHEMA_SQL;
// Assuming there are only ASCII characters, we can directly convert to a string:
std::string schema = uHex2Str(hex);
// For binary data:
std::vector<char> bytes = uHex2Bytes(hex);

The generator can be automated in a CMake build like:

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/DatabaseSchema_sql.h
COMMAND ${URESOURCEGENERATOR_EXEC} -n my_namespace -p ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/DatabaseSchema.sql
COMMENT "[Creating database resource]"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/DatabaseSchema.sql
)
SET(RESOURCES
${CMAKE_CURRENT_BINARY_DIR}/DatabaseSchema_sql.h
)
ADD_LIBRARY(mylib ${SRC_FILES} ${RESOURCES})
ADD_EXECUTABLE(myexecutable ${SRC_FILES} ${RESOURCES})

The variable URESOURCEGENERATOR_EXEC is set when FIND_PACKAGE(UtiLite) is done, you would need to add FindUtiLite.cmake.



rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:43:42