Commit 97e635c8 authored by Rashad Kanavath's avatar Rashad Kanavath

ENH: make qgis descriptor file with app POST_BUILD

parent d019da5b
......@@ -119,6 +119,19 @@ macro(otb_create_application)
CACHE STRING "List of all applications" FORCE)
mark_as_advanced(OTB_APPLICATIONS_NAME_LIST)
if(NOT ${APPLICATION_NAME} MATCHES "(TestApplication|ApplicationExample)")
set(descriptor_output_dir "${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}")
set(dfile "${descriptor_output_dir}/${APPLICATION_NAME}.txt")
add_custom_command(TARGET "${APPLICATION_TARGET_NAME}" POST_BUILD
COMMAND "$<TARGET_FILE:otbQgisDescriptor>"
"${APPLICATION_NAME}"
"${APPLICATION_BINARY_PATH}"
"${descriptor_output_dir}/"
#COMMENT "./bin/otbQgisDescriptor ${APPLICATION_NAME} ${APPLICATION_BINARY_PATH} ${descriptor_output_dir}"
WORKING_DIRECTORY ${OTB_BINARY_DIR} VERBATIM)
install(FILES ${dfile} DESTINATION ${OTB_INSTALL_DESCR_DIR})
endif()
endmacro()
macro(otb_test_application)
......
......@@ -174,6 +174,10 @@ if(NOT OTB_INSTALL_PACKAGE_DIR)
set(OTB_INSTALL_PACKAGE_DIR "${OTB_INSTALL_LIBRARY_DIR}/cmake/OTB-${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}")
endif()
if(NOT OTB_INSTALL_DESCR_DIR)
set (OTB_INSTALL_DESCR_DIR "share/otb/description")
endif()
#convert path to native for reconfiguring otbcli.bat.in
file(TO_NATIVE_PATH "${OTB_INSTALL_APP_DIR}" OTB_INSTALL_APP_DIR_NATIVE)
......
......@@ -21,36 +21,9 @@ add_executable(otbQgisDescriptor otbQgisDescriptor.cxx)
target_link_libraries(otbQgisDescriptor ${OTBQgis_LIBRARIES})
otb_module_target(otbQgisDescriptor)
set(dfiles)
set(app_list ${OTB_APPLICATIONS_NAME_LIST})
list(REMOVE_ITEM app_list "TestApplication")
list(REMOVE_ITEM app_list "ApplicationExample")
list(REMOVE_DUPLICATES app_list)
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_BINARY_DIR}/descriptors/"
DEPENDS otbQgisDescriptor
WORKING_DIRECTORY ${OTB_BINARY_DIR}
COMMENT "./bin/otbQgisDescriptor ${otb_app} ./lib/otb/applications ./descriptors/"
VERBATIM)
list(APPEND dfiles "${dfile}")
endforeach()
add_custom_target(clean_algs_txt
COMMAND "${CMAKE_COMMAND}" "-E" "remove_directory" "${OTB_BINARY_DIR}/descriptors/"
COMMAND "${CMAKE_COMMAND}" "-E" "remove_directory" "${CMAKE_INSTALL_PREFIX}/descriptors/"
COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" "${OTB_BINARY_DIR}/descriptors/"
COMMAND "${CMAKE_COMMAND}" "-E" "echo" "Generating descriptor files for QGIS"
DEPENDS otbQgisDescriptor
)
add_custom_target(generate_qgis_descriptor
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 clean_algs_txt ${dfiles}
add_custom_command(TARGET otbQgisDescriptor
POST_BUILD
COMMAND "${CMAKE_COMMAND}" "-E" "echo" "make_directory ${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}/"
COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" "${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}/"
)
#otb_module_target_label(generate_qgis_descriptor)
......@@ -99,7 +99,6 @@ int main(int argc, char* argv[])
}
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;
......@@ -331,13 +330,14 @@ int main(int argc, char* argv[])
dFile << "*QgsProcessingParameterEnum|outputpixeltype|Output pixel type|uint8;int;float;double|False|2|True" << std::endl;
}
std::cerr << "[100%] Writing " << output_file << std::endl;
dFile.close();
std::ofstream indexFile;
indexFile.open (algs_txt, std::ios::out | std::ios::app );
indexFile << group << "|" << module << std::endl;
indexFile.close();
std::cerr << "Updated " << algs_txt << std::endl;
//std::cerr << "Updated " << algs_txt << std::endl;
appli = nullptr;
ApplicationRegistry::CleanRegistry();
......
......@@ -20,7 +20,7 @@
function(install_qgis_bindings)
if(HAVE_QGIS)
install(DIRECTORY ${SUPERBUILD_INSTALL_DIR}/descriptors
install(DIRECTORY ${SUPERBUILD_INSTALL_DIR}/share/otb/description
DESTINATION ${PKG_STAGE_DIR})
endif()
endfunction()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment