From 982db73792be33a20b86d419526d26e04a39d7d4 Mon Sep 17 00:00:00 2001
From: Rashad Kanavath <rashad.kanavath@c-s.fr>
Date: Wed, 11 Apr 2018 11:48:36 +0200
Subject: [PATCH] ENH: third arg must be a directory with pathsep at end

---
 Modules/Wrappers/QGIS/src/CMakeLists.txt       |  7 ++++---
 .../Wrappers/QGIS/src/otbQgisDescriptor.cxx    | 18 +++++-------------
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/Modules/Wrappers/QGIS/src/CMakeLists.txt b/Modules/Wrappers/QGIS/src/CMakeLists.txt
index cb223f1e8c..28d59a75d4 100644
--- a/Modules/Wrappers/QGIS/src/CMakeLists.txt
+++ b/Modules/Wrappers/QGIS/src/CMakeLists.txt
@@ -29,15 +29,16 @@ foreach(otb_app ${app_list})
   set(dfile "${OTB_BINARY_DIR}/descriptors/${otb_app}.txt")
   add_custom_command(OUTPUT "${dfile}"
   COMMAND "$<TARGET_FILE:otbQgisDescriptor>"
-     "${otb_app}" "${OTB_BINARY_DIR}/lib/otb/applications"
+     "${otb_app}" "${OTB_BINARY_DIR}/lib/otb/applications" "${OTB_BINARY_DIR}/descriptors/"
   DEPENDS otbQgisDescriptor
-  WORKING_DIRECTORY ${OTB_BINARY_DIR}/descriptors/
-  COMMENT "./bin/otbQgisDescriptor ${otb_app} ${OTB_BINARY_DIR}/lib/otb/applications"
+  WORKING_DIRECTORY ${OTB_BINARY_DIR}
+  COMMENT "./bin/otbQgisDescriptor ${otb_app} ./lib/otb/applications ./descriptors/"
   VERBATIM)
 list(APPEND dfiles "${dfile}")
 endforeach()
 add_custom_target(generate_qgis_descriptor
   COMMAND "${CMAKE_COMMAND}" "-E" "echo" "Generating descriptor files for QGIS"
+  COMMAND "${CMAKE_COMMAND}" "-E" "remove" "${OTB_BINARY_DIR}/descriptors/algs.txt"
   COMMAND "${CMAKE_COMMAND}" "-E" "echo" "Installing: ${CMAKE_INSTALL_PREFIX}/descriptors/"
   COMMAND "${CMAKE_COMMAND}" "-E" "copy_directory" "${OTB_BINARY_DIR}/descriptors" "${CMAKE_INSTALL_PREFIX}/descriptors"
   DEPENDS ${dfiles}
diff --git a/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx b/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
index 24e46a83aa..ff2aeb6971 100644
--- a/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
+++ b/Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
@@ -95,26 +95,18 @@ int main(int argc, char* argv[])
 
   std::string output_file = module + ".txt";
   std::string  algs_txt = "algs.txt";
-  if (argc > 3) {
-   #if defined(WIN32)
-   std::string output_dir = std::string(argv[3]) + "\\";
-   #else
-   std::string output_dir = std::string(argv[3]) + "/";
-   #endif
-    output_file = output_dir + module + ".txt";
-    algs_txt = output_dir +  "algs.txt";
+  if (argc > 3)
+    {
+      output_file = std::string(argv[3]) + module + ".txt";
+      algs_txt = std::string(argv[3])  +  "algs.txt";
     }
-
-  #if 0
-  std::cout << "output_file: " << output_file << std::endl;
-  std::cout << "algs_txt: " << algs_txt << std::endl;
-  #endif
   std::ofstream dFile;
   dFile.open (output_file, std::ios::out);
   std::cerr << "Writing " << output_file << std::endl;
 
   std::string output_parameter_name;
   bool hasRasterOutput = false;
+  {
   for (unsigned int i = 0; i < nbOfParam; i++)
     {
       Parameter::Pointer param = appli->GetParameterByKey(appKeyList[i]);
-- 
GitLab