MATLAB's built-in packing function( "Package Code" button or packNGo) has not been updated in time for the new factorGraph support, and its underlying dependency is on third-party libraries such as ceres,eigen, etc. To fix this, you can manually copy the dependent source and header files from the generated "CMakeLists.txt".
I solved the third-party dependency packaging problem by the following CMake method
set(all_src_files ${MATLAB_ROOT}/toolbox/shared/ceres/builtins/libsrc/cerescodegen/cerescodegen_api.cpp
${MATLAB_ROOT}/toolbox/shared/ceres/builtins/libsrc/cerescodegen/factor_graph.cpp
...
omit large numbers of cpp files
set custom package path,
list(LENGTH all_src_files src_files_len)
message(STATUS "NUMBERS:${src_files_len}")
set(package_path ${CMAKE_CURRENT_SOURCE_DIR}/myPackage_codes)
foreach(item RANGE 5 110 1)
list(GET all_src_files ${item} currentSourceFile)
string(REPLACE ${MATLAB_ROOT}/toolbox/shared/robotics/externalDependency ${package_path}/src dstSourceFile ${currentSourceFile})
cmake_path(GET dstSourceFile PARENT_PATH dstSourceFolder)
file(COPY ${currentSourceFile} DESTINATION ${dstSourceFolder})
endforeach()
However, from "CMakeLists.txt" it seems that I can only see the directory of dependent headers, but I don't know exactly what headers are needed, the number of headers and the amount of space they take up!
---------------
By the way, on the above "simple" MATLAB code, the generated source code cpp file as many as 116, if the header file is also taken into account, ceres library include as many as 400 +, eigen library as many as 278. If I set cfg.FilePartitionMethod = "singleFile", it still generates the C++ classes as above, but the user functions/classes are not separate, but inline, I don't it is if a bug issue?