Commit cc60dd19 authored by Rashad Kanavath's avatar Rashad Kanavath

ENH: fix generation of qgis descriptors

descriptors are generated with a custom target called
'generate_descriptors'. It depends on all OTBAPP.txt
So a missing .txt during installation will try to generate txt file.
This make sure all available applications have a valid descriptor.
There is a internal custom target called clean_descr which depends on
otbQgisDescriptor executable. This target re-create an empty directory
set in OTB_INSTALL_DESCR_DIR under OTB_BINARY_DIR. This make sure every
execution of generate_descriptor target is a clean one.

Finally, custom target is executed by make install using cmake's
install(CODE. Users can either can "make generate_descriptors" manually
or is automatically called during install.
parent 71e8dd93
......@@ -119,20 +119,6 @@ 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}/"
DEPENDS otbQgisDescriptor
#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)
......
......@@ -21,9 +21,41 @@ add_executable(otbQgisDescriptor otbQgisDescriptor.cxx)
target_link_libraries(otbQgisDescriptor ${OTBQgis_LIBRARIES})
otb_module_target(otbQgisDescriptor)
add_custom_command(TARGET otbQgisDescriptor
POST_BUILD
COMMAND "${CMAKE_COMMAND}" "-E" "echo" "make_directory ${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}/"
set(dfiles)
set(app_names ${OTB_APPLICATIONS_NAME_LIST})
list(REMOVE_ITEM app_names "TestApplication")
list(REMOVE_ITEM app_names "ApplicationExample")
list(REMOVE_DUPLICATES app_names)
foreach(app_name ${app_names})
set(dfile "${OTB_BINARY_DIR}/descriptors/${app_name}.txt")
add_custom_command(OUTPUT "${dfile}"
COMMAND "$<TARGET_FILE:otbQgisDescriptor>"
"${app_name}" "${OTB_BINARY_DIR}/${OTB_INSTALL_APP_DIR}" "${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}/"
DEPENDS otbQgisDescriptor
WORKING_DIRECTORY ${OTB_BINARY_DIR}
COMMENT "./bin/otbQgisDescriptor ${app_name} ./${OTB_INSTALL_APP_DIR} ./${OTB_INSTALL_DESCR_DIR}/"
VERBATIM)
list(APPEND dfiles "${dfile}")
endforeach()
add_custom_target(clean_descr.dirs
COMMAND "${CMAKE_COMMAND}" "-E" "remove_directory" "${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}/"
COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" "${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}/"
DEPENDS otbQgisDescriptor
)
add_custom_target(generate_descriptors
COMMAND "${CMAKE_COMMAND}" "-E" "echo" "Generated descriptor files for QGIS"
DEPENDS clean_descr.dirs ${dfiles}
)
install(CODE "
message(STATUS \"Generating descriptor files for QGIS in ${OTB_INSTALL_DESCR_DIR}\")
execute_process(
COMMAND ${CMAKE_COMMAND} --build \"${OTB_BINARY_DIR}\" --target generate_descriptors
COMMAND ${CMAKE_COMMAND} -E echo \"Installing: ${CMAKE_INSTALL_PREFIX}/${OTB_INSTALL_DESCR_DIR}/\"
COMMAND ${CMAKE_COMMAND} -E copy_directory \"${OTB_BINARY_DIR}/${OTB_INSTALL_DESCR_DIR}\" \"${CMAKE_INSTALL_PREFIX}/${OTB_INSTALL_DESCR_DIR}\"
WORKING_DIRECTORY \"${OTB_BINARY_DIR}\"
)
")
......@@ -330,14 +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;
std::cerr << "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();
......
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