Problem with otbQgisDescriptor

The build is failing on otbQgisDescriptor TrainVectorClassifier step.

Context:

  • OTB 7.2.0
  • no classification backend enabled (I don’t need them for my use-case).
[ 83%] ./bin/otbQgisDescriptor TrainVectorClassifier lib/otb/applications ./share/otb/description/
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::erase: __pos (which is 18446744073709551615) > this->size() (which is 0)
make[2]: *** [Modules/Wrappers/QGIS/src/CMakeFiles/generate_descriptors.dir/build.make:187: share/otb/description/TrainVectorClassifier.txt] Aborted (core dumped)
make[2]: *** Deleting file 'share/otb/description/TrainVectorClassifier.txt'
make[1]: *** [CMakeFiles/Makefile2:16357: Modules/Wrappers/QGIS/src/CMakeFiles/generate_descriptors.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Hello,

I think the problem comes from the CMake cached variable OTB_APPLICATIONS_NAME_LIST. This variable contains the name of all applications built by OTB (internally, an application is added to the list whenever the otb_create_application macro is called. I don’t think this list is cleared when an application is deactivated.

I don’t reproduce the problem if the classification module is not activated on the first Cmake call (for example when calling cmake /path/to/otb with no additional parameter). I guess the bug occurs if the module is first activated, and then manually deactivated.

I’m not sure how this should be fixed. Maybe the aplication list should be deduced from the content of the build/lib/otb/applications directory instead of relying on OTB_APPLICATIONS_NAME_LIST.

In your case you can manually patch the OTB_APPLICATIONS_NAME_LIST in ccmake (advanced variables) or directly in the CMakeCache.txt.