Commit 0dbeabd2 authored by Rashad Kanavath's avatar Rashad Kanavath

PKG: Generate single windows archive with OTB and Monteverdi

parent 9d6d5a23
# Get the translation files coming with Qt, and install them in the bundle
# They are loaded by Monteverdi.
function(get_qt_translation_files RESULT)
# These files are the "qt_<localename>.qm" files
# They are located in QT_TRANSLATIONS_DIR, which comes from FindQt4
file(GLOB translation_files ${QT_TRANSLATIONS_DIR}/qt_*)
# We need to remove the "qt_help_<localename>.qm" files from this list
foreach(translation_item ${translation_files})
if(${translation_item} MATCHES "qt_help")
list(REMOVE_ITEM translation_files ${translation_item})
endif()
endforeach()
set(${RESULT} ${translation_files} PARENT_SCOPE)
endfunction()
#RK: two packages.
#function(create_cpack_config application)
function(create_cpack_config)
#should we handle this when calling function ?
#for now mapla has no specific version or it is same as monteverdi
SET(CPACK_PACKAGE_VERSION "${Monteverdi_VERSION_MAJOR}.${Monteverdi_VERSION_MINOR}.${Monteverdi_VERSION_PATCH}${Monteverdi_VERSION_SUFFIX}")
......@@ -215,67 +197,67 @@ function(configure_app_package app with_otb_apps)
endif() #(NOT CMAKE_CROSSCOMPILING AND Monteverdi_USE_CPACK)
if(CMAKE_CROSSCOMPILING)
if(NOT DEFINED MXE_TARGET_DIR)
message(FATAL_ERROR "MXE_TARGET_DIR is missing")
endif()
if(MXE_TARGET_DIR MATCHES "i686")
set(mxearch x86)
set(archive_name ${app}-${Monteverdi_VERSION_STRING}-win32)
elseif(MXE_TARGET_DIR MATCHES "x86_64")
set(mxearch x64)
set(archive_name ${app}-${Monteverdi_VERSION_STRING}-win64)
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_INSTALL_PREFIX}/${archive_name}")
get_filename_component(mxeroot ${MXE_TARGET_DIR} PATH)
get_filename_component(mxeroot ${mxeroot} PATH)
file(WRITE "${CMAKE_BINARY_DIR}/_mingw/${app}/CMakeLists.txt"
"cmake_minimum_required(VERSION 2.6)
include(CMakeParseArguments)
set(Monteverdi_SOURCE_DIR \"${Monteverdi_SOURCE_DIR}\")
set(OTB_MODULES_DIR \"${OTB_MODULES_DIR}\")
set(QT_PLUGINS_DIR \"${QT_PLUGINS_DIR}\")
set(QT_TRANSLATIONS_DIR \"${QT_TRANSLATIONS_DIR}\")
set(Monteverdi_BINARY_DIR \"${CMAKE_BINARY_DIR}\")
set(CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")
set(Monteverdi_INSTALL_DATA_DIR \"${Monteverdi_INSTALL_DATA_DIR}\")
include(${CMAKE_SOURCE_DIR}/CMake/MinGWPackage.cmake)
include(${CMAKE_SOURCE_DIR}/CMake/CPackFunctions.cmake)
package_mingw(
ARCH \"${mxearch}\"
MXEROOT \"${mxeroot}\"
PREFIX_DIR \"${archive_name}\"
PEFILES \"${APP_NAME}\"
NEEDS_OTB_APPS ${with_otb_apps}
SEARCHDIRS \"\")")
set(GDAL_DATA ${MXE_TARGET_DIR}/share/gdal)
add_custom_target(configure-${app}-mingw-package
COMMAND ${CMAKE_COMMAND}
"${CMAKE_BINARY_DIR}/_mingw/${app}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/_mingw/${app}")
add_custom_target(make-${app}-mingw-package
COMMAND ${CMAKE_COMMAND}
"--build" "${CMAKE_BINARY_DIR}/_mingw/${app}" "--target" "install"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/_mingw/${app}"
DEPENDS configure-${app}-mingw-package)
find_program(ZIP_EXECUTABLE zip)
if(ZIP_EXECUTABLE)
add_custom_target(create-${app}-mingw-archive
COMMAND ${ZIP_EXECUTABLE} "-r" "${CMAKE_BINARY_DIR}/${archive_name}.zip" "${archive_name}"
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
DEPENDS make-${app}-mingw-package)
else()
message(FATAL_ERROR "Cannot find zip executable. Please add it to your path")
endif()
endif() # (CMAKE_CROSSCOMPILING)
# if(CMAKE_CROSSCOMPILING)
# if(NOT DEFINED MXE_TARGET_DIR)
# message(FATAL_ERROR "MXE_TARGET_DIR is missing")
# endif()
# if(MXE_TARGET_DIR MATCHES "i686")
# set(mxearch x86)
# set(archive_name ${app}-${Monteverdi_VERSION_STRING}-win32)
# elseif(MXE_TARGET_DIR MATCHES "x86_64")
# set(mxearch x64)
# set(archive_name ${app}-${Monteverdi_VERSION_STRING}-win64)
# endif()
# execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_INSTALL_PREFIX}/${archive_name}")
# get_filename_component(mxeroot ${MXE_TARGET_DIR} PATH)
# get_filename_component(mxeroot ${mxeroot} PATH)
# file(WRITE "${CMAKE_BINARY_DIR}/_mingw/${app}/CMakeLists.txt"
# "cmake_minimum_required(VERSION 2.6)
# include(CMakeParseArguments)
# set(Monteverdi_SOURCE_DIR \"${Monteverdi_SOURCE_DIR}\")
# set(OTB_MODULES_DIR \"${OTB_MODULES_DIR}\")
# set(QT_PLUGINS_DIR \"${QT_PLUGINS_DIR}\")
# set(QT_TRANSLATIONS_DIR \"${QT_TRANSLATIONS_DIR}\")
# set(Monteverdi_BINARY_DIR \"${CMAKE_BINARY_DIR}\")
# set(CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")
# set(Monteverdi_INSTALL_DATA_DIR \"${Monteverdi_INSTALL_DATA_DIR}\")
# include(${CMAKE_SOURCE_DIR}/CMake/MinGWPackage.cmake)
# include(${CMAKE_SOURCE_DIR}/CMake/CPackFunctions.cmake)
# package_mingw(
# ARCH \"${mxearch}\"
# MXEROOT \"${mxeroot}\"
# PREFIX_DIR \"${archive_name}\"
# PEFILES \"${APP_NAME}\"
# NEEDS_OTB_APPS ${with_otb_apps}
# SEARCHDIRS \"\")")
# set(GDAL_DATA ${MXE_TARGET_DIR}/share/gdal)
# add_custom_target(configure-${app}-mingw-package
# COMMAND ${CMAKE_COMMAND}
# "${CMAKE_BINARY_DIR}/_mingw/${app}"
# WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/_mingw/${app}")
# add_custom_target(make-${app}-mingw-package
# COMMAND ${CMAKE_COMMAND}
# "--build" "${CMAKE_BINARY_DIR}/_mingw/${app}" "--target" "install"
# WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/_mingw/${app}"
# DEPENDS configure-${app}-mingw-package)
# find_program(ZIP_EXECUTABLE zip)
# if(ZIP_EXECUTABLE)
# add_custom_target(create-${app}-mingw-archive
# COMMAND ${ZIP_EXECUTABLE} "-r" "${CMAKE_BINARY_DIR}/${archive_name}.zip" "${archive_name}"
# WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
# DEPENDS make-${app}-mingw-package)
# else()
# message(FATAL_ERROR "Cannot find zip executable. Please add it to your path")
# endif()
# endif() # (CMAKE_CROSSCOMPILING)
endif(WIN32)
......@@ -321,161 +303,87 @@ function(configure_app_package app with_otb_apps)
endif(APPLE)
################################################################################
################################################################################
################### END OF PLATFORM SPECIFIC CMAKE VARIABLES ###################
################################################################################
################################################################################
####################### install sqldrivers plugin #######################
install(FILES ${QT_PLUGINS_DIR}/sqldrivers/${APP_QTSQLITE_FILENAME}
DESTINATION ${APP_QTPLUGINS_DIR}/sqldrivers
COMPONENT Runtime)
####################### install translations #######################
get_qt_translation_files(QT_TRANSLATIONS_FILES)
install(FILES ${QT_TRANSLATIONS_FILES}
DESTINATION ${APP_I18N_DIR}
COMPONENT Resources)
####################### install GDAL data #######################
if(NOT DEFINED GDAL_DATA)
file(TO_CMAKE_PATH "$ENV{GDAL_DATA}" GDAL_DATA)
if(NOT GDAL_DATA)
if(Monteverdi_USE_CPACK)
message(FATAL_ERROR "Cannot generate installer without GDAL_DATA : GDAL_DATA")
else()
message(WARNING "Cannot generate installer without GDAL_DATA : GDAL_DATA")
endif()
endif()
endif() #(DEFINED GDAL_DATA)
# Need to include csv files provided with GDAL that contains some needed EPSG definitions
install(DIRECTORY ${GDAL_DATA}
DESTINATION ${APP_DATA_DIR}
COMPONENT Resources)
####################### Check otb applications #######################
if(with_otb_apps)
# message(FATAL_ERROR "No OTB-applications detected")
file(GLOB OTB_APPS_LIST ${OTB_MODULES_DIR}/../../../otb/applications/otbapp_*${CMAKE_SHARED_LIBRARY_SUFFIX}) # /lib/otb
if(NOT OTB_APPS_LIST)
message(FATAL_ERROR "No OTB-applications detected")
endif()
## otb apps dir /lib/otb/applications
install(DIRECTORY "${OTB_MODULES_DIR}/../../../otb/applications"
DESTINATION ${APP_OTBLIBS_DIR}
COMPONENT Runtime)
endif(with_otb_apps)
## directories to look for dependencies
set(SEARCH_DIRS)
list(APPEND SEARCH_DIRS "${QT_PLUGINS_DIR}/sqldrivers")
list(APPEND SEARCH_DIRS "${ITK_MODULES_DIR}/../../../")
list(APPEND SEARCH_DIRS "${OTB_MODULES_DIR}/../../../")
list(APPEND SEARCH_DIRS "${CMAKE_INSTALL_PREFIX}/lib/otb/")
####################### install fixup_bundle code #######################
## fixup_bundle code
if(NOT CMAKE_CROSSCOMPILING)
if(with_otb_apps)
install(CODE
"file(GLOB APP_LIBS \"${CMAKE_INSTALL_PREFIX}/${APP_OTBLIBS_DIR}/applications/otbapp_*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
list(APPEND APP_LIBS \"${CMAKE_INSTALL_PREFIX}/${APP_QTPLUGINS_DIR}/sqldrivers/${APP_QTSQLITE_FILENAME}\")
include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS ON)
fixup_bundle(\"${APP_NAME}\" \"\${APP_LIBS}\" \"${SEARCH_DIRS}\")"
COMPONENT ${app})
else() #(with_otb_apps)
install(CODE
"file(GLOB APP_LIBS \"${CMAKE_INSTALL_PREFIX}/${APP_QTPLUGINS_DIR}/sqldrivers/${APP_QTSQLITE_FILENAME}\")
include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS ON)
fixup_bundle(\"${APP_NAME}\" \"\${APP_LIBS}\" \"${SEARCH_DIRS}\")"
COMPONENT ${app})
endif() #(with_otb_apps)
endif() #(NOT CMAKE_CROSSCOMPILING)
# ################################################################################
# ################################################################################
# ################### END OF PLATFORM SPECIFIC CMAKE VARIABLES ###################
# ################################################################################
# ################################################################################
# ####################### install sqldrivers plugin #######################
# install(FILES ${QT_PLUGINS_DIR}/sqldrivers/${APP_QTSQLITE_FILENAME}
# DESTINATION ${APP_QTPLUGINS_DIR}/sqldrivers
# COMPONENT Runtime)
# ####################### install translations #######################
# get_qt_translation_files(QT_TRANSLATIONS_FILES)
# install(FILES ${QT_TRANSLATIONS_FILES}
# DESTINATION ${APP_I18N_DIR}
# COMPONENT Resources)
# ####################### install GDAL data #######################
# if(NOT DEFINED GDAL_DATA)
# file(TO_CMAKE_PATH "$ENV{GDAL_DATA}" GDAL_DATA)
# if(NOT GDAL_DATA)
# if(Monteverdi_USE_CPACK)
# message(FATAL_ERROR "Cannot generate installer without GDAL_DATA : GDAL_DATA")
# else()
# message(WARNING "Cannot generate installer without GDAL_DATA : GDAL_DATA")
# endif()
# endif()
# endif() #(DEFINED GDAL_DATA)
# # Need to include csv files provided with GDAL that contains some needed EPSG definitions
# install(DIRECTORY ${GDAL_DATA}
# DESTINATION ${APP_DATA_DIR}
# COMPONENT Resources)
# ####################### Check otb applications #######################
# if(with_otb_apps)
# # message(FATAL_ERROR "No OTB-applications detected")
# file(GLOB OTB_APPS_LIST ${OTB_MODULES_DIR}/../../../otb/applications/otbapp_*${CMAKE_SHARED_LIBRARY_SUFFIX}) # /lib/otb
# if(NOT OTB_APPS_LIST)
# message(FATAL_ERROR "No OTB-applications detected")
# endif()
# ## otb apps dir /lib/otb/applications
# install(DIRECTORY "${OTB_MODULES_DIR}/../../../otb/applications"
# DESTINATION ${APP_OTBLIBS_DIR}
# COMPONENT Runtime)
# endif(with_otb_apps)
# ## directories to look for dependencies
# set(SEARCH_DIRS)
# list(APPEND SEARCH_DIRS "${QT_PLUGINS_DIR}/sqldrivers")
# list(APPEND SEARCH_DIRS "${ITK_MODULES_DIR}/../../../")
# list(APPEND SEARCH_DIRS "${OTB_MODULES_DIR}/../../../")
# list(APPEND SEARCH_DIRS "${CMAKE_INSTALL_PREFIX}/lib/otb/")
# ####################### install fixup_bundle code #######################
# ## fixup_bundle code
# if(NOT CMAKE_CROSSCOMPILING)
# if(with_otb_apps)
# install(CODE
# "file(GLOB APP_LIBS \"${CMAKE_INSTALL_PREFIX}/${APP_OTBLIBS_DIR}/applications/otbapp_*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
# list(APPEND APP_LIBS \"${CMAKE_INSTALL_PREFIX}/${APP_QTPLUGINS_DIR}/sqldrivers/${APP_QTSQLITE_FILENAME}\")
# include(BundleUtilities)
# set(BU_CHMOD_BUNDLE_ITEMS ON)
# fixup_bundle(\"${APP_NAME}\" \"\${APP_LIBS}\" \"${SEARCH_DIRS}\")"
# COMPONENT ${app})
# else() #(with_otb_apps)
# install(CODE
# "file(GLOB APP_LIBS \"${CMAKE_INSTALL_PREFIX}/${APP_QTPLUGINS_DIR}/sqldrivers/${APP_QTSQLITE_FILENAME}\")
# include(BundleUtilities)
# set(BU_CHMOD_BUNDLE_ITEMS ON)
# fixup_bundle(\"${APP_NAME}\" \"\${APP_LIBS}\" \"${SEARCH_DIRS}\")"
# COMPONENT ${app})
# endif() #(with_otb_apps)
# endif() #(NOT CMAKE_CROSSCOMPILING)
endfunction(configure_app_package)
macro(create_monteverdi_application)
cmake_parse_arguments(APPLICATION "" "NAME;OUTPUT_NAME;COMPONENT_NAME;NEEDS_OTB_APPS" "SOURCES;LINK_LIBRARIES" ${ARGN} )
if(NOT DEFINED APPLICATION_NEEDS_OTB_APPS OR APPLICATION_NEEDS_OTB_APPS)
set(APPLICATION_NEEDS_OTB_APPS TRUE)
else()
set(APPLICATION_NEEDS_OTB_APPS FALSE)
endif()
if(WIN32)
add_executable(${APPLICATION_NAME}
WIN32
${APPLICATION_SOURCES})
elseif(APPLE)
add_executable(${APPLICATION_NAME}
MACOSX_BUNDLE
${APPLICATION_SOURCES})
else() #Linux
add_executable(${APPLICATION_NAME}
${APPLICATION_SOURCES})
endif()
set(EXECUTABLE_NAME ${APPLICATION_NAME})
if(APPLE)
string(SUBSTRING ${APPLICATION_NAME} 0 1 FIRST_LETTER)
string(TOUPPER ${FIRST_LETTER} FIRST_LETTER)
string(REGEX REPLACE "^.(.*)" "${FIRST_LETTER}\\1" APPLICATION_OUTPUT_NAME "${APPLICATION_NAME}")
endif()
if (APPLICATION_OUTPUT_NAME)
set_target_properties(${APPLICATION_NAME} PROPERTIES OUTPUT_NAME ${APPLICATION_OUTPUT_NAME})
set(EXECUTABLE_NAME ${APPLICATION_OUTPUT_NAME})
endif()
if(APPLE)
if(Monteverdi_USE_CPACK)
set(MACOS_FILES_DIR "${CMAKE_SOURCE_DIR}/Packaging/MacOS")
configure_file(${MACOS_FILES_DIR}/Info.plist.in
${CMAKE_BINARY_DIR}/Code/Application/${APPLICATION_NAME}/Info.plist
@ONLY)
configure_file(${MACOS_FILES_DIR}/StartupCommand.in
${CMAKE_BINARY_DIR}/Code/Application/${APPLICATION_NAME}/${EXECUTABLE_NAME}_start
@ONLY)
set_target_properties(${APPLICATION_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_BINARY_DIR}/Code/Application/${APPLICATION_NAME}/Info.plist")
endif(Monteverdi_USE_CPACK)
endif(APPLE)
target_link_libraries(${APPLICATION_NAME} ${APPLICATION_LINK_LIBRARIES})
#############################################################################
install(TARGETS ${APPLICATION_NAME}
BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT ${APPLICATION_COMPONENT_NAME}
RUNTIME DESTINATION ${Monteverdi_INSTALL_BIN_DIR} COMPONENT ${APPLICATION_COMPONENT_NAME}
LIBRARY DESTINATION ${Monteverdi_INSTALL_LIB_DIR} COMPONENT ${APPLICATION_COMPONENT_NAME}
ARCHIVE DESTINATION ${Monteverdi_INSTALL_LIB_DIR} COMPONENT ${APPLICATION_COMPONENT_NAME}
)
#############################################################################
if(WIN32)
if(CMAKE_CROSSCOMPILING OR Monteverdi_USE_CPACK)
configure_app_package(${APPLICATION_COMPONENT_NAME} ${APPLICATION_NEEDS_OTB_APPS})
endif()
elseif(APPLE AND Monteverdi_USE_CPACK)
configure_app_package(${APPLICATION_COMPONENT_NAME} ${APPLICATION_NEEDS_OTB_APPS})
endif()
endmacro(create_monteverdi_application)
\ No newline at end of file
macro(package_mingw)
cmake_parse_arguments(PACKAGE "" "PREFIX_DIR;ARCH;MXEROOT;NEEDS_OTB_APPS" "SEARCHDIRS;PEFILES" ${ARGN} )
cmake_parse_arguments(PACKAGE "" "PREFIX_DIR;ARCH;MXEROOT" "SEARCHDIRS;PEFILES" ${ARGN} )
if("${PACKAGE_ARCH}" STREQUAL "x86")
set(MXE_BIN_DIR "${PACKAGE_MXEROOT}/usr/i686-w64-mingw32.shared/bin")
set(MXE_OBJDUMP "${PACKAGE_MXEROOT}/usr/bin/i686-w64-mingw32.shared-objdump")
......@@ -8,38 +8,35 @@ macro(package_mingw)
set(MXE_OBJDUMP "${PACKAGE_MXEROOT}/usr/bin/x86_64-w64-mingw32.shared-objdump")
endif()
#guess install directory from OTB_MODULES_DIR
set(OTB_INSTALL_DIR ${OTB_MODULES_DIR}/../../../..)
set(OTB_APPLICATIONS_DIR ${OTB_MODULES_DIR}/../../../../lib/otb/applications)
file(GLOB MXE_GCC_LIB_DIR "${MXE_BIN_DIR}/gcc*")
list(APPEND PACKAGE_SEARCHDIRS ${MXE_GCC_LIB_DIR})
list(APPEND PACKAGE_SEARCHDIRS ${MXE_BIN_DIR})
list(APPEND PACKAGE_SEARCHDIRS "${MXE_BIN_DIR}/../qt/bin") #Qt
list(APPEND PACKAGE_SEARCHDIRS "${MXE_BIN_DIR}/../qt/lib") #Qwt
list(APPEND PACKAGE_SEARCHDIRS "${CMAKE_INSTALL_PREFIX}/bin") #mvd
list(APPEND PACKAGE_SEARCHDIRS "${OTB_APPLICATIONS_DIR}") #otb apps
list(APPEND PACKAGE_SEARCHDIRS "${OTB_INSTALL_DIR}/bin") #otbApplicationLauncher*.exe
install_common(${PACKAGE_PREFIX_DIR} ${PACKAGE_NEEDS_OTB_APPS})
if(PACKAGE_NEEDS_OTB_APPS)
list(APPEND PACKAGE_SEARCHDIRS "${OTB_MODULES_DIR}/../../../otb/applications") #otb apps
endif()
foreach(exe_file ${PACKAGE_PEFILES})
get_filename_component(base_name ${exe_file} NAME_WE)
install(FILES ${Monteverdi_SOURCE_DIR}/Packaging/Windows/${base_name}.bat
DESTINATION ${PACKAGE_PREFIX_DIR}/bin)
endforeach()
if(NOT PACKAGE_PEFILES)
list(APPEND PACKAGE_PEFILES "${CMAKE_INSTALL_PREFIX}/bin/monteverdi.exe")
list(APPEND PACKAGE_PEFILES "${CMAKE_INSTALL_PREFIX}/bin/mapla.exe")
list(APPEND PACKAGE_PEFILES "${OTB_INSTALL_DIR}/bin/otbApplicationLauncherCommandLine.exe")
list(APPEND PACKAGE_PEFILES "${OTB_INSTALL_DIR}/bin/otbApplicationLauncherQt.exe") #OTBQtWidget must exists when you are building OTB
if(EXISTS "${OTB_INSTALL_DIR}/bin/otbIceViewer.exe")
list(APPEND PACKAGE_PEFILES "${OTB_INSTALL_DIR}/bin/otbIceViewer.exe") #iceviewer
endif()
endif()
#qt4 translations
file(GLOB APP_TS_FILES ${Monteverdi_SOURCE_DIR}/i18n/*.ts) # qm files
foreach(APP_TS_FILE ${APP_TS_FILES})
get_filename_component(APP_TS_FILENAME ${APP_TS_FILE} NAME_WE)
install(FILES ${Monteverdi_BINARY_DIR}/i18n/${APP_TS_FILENAME}.qm
DESTINATION ${PACKAGE_PREFIX_DIR}/${Monteverdi_INSTALL_DATA_DIR}/i18n)
endforeach()
install_common(${PACKAGE_PREFIX_DIR})
#dependency resolution based on copydlldeps.sh from mxe by Timothy Gu
if(PACKAGE_NEEDS_OTB_APPS)
file(GLOB otbapps_list ${OTB_MODULES_DIR}/../../../otb/applications/otbapp_*dll) # /lib/otb
list(APPEND PACKAGE_PEFILES ${otbapps_list})
endif()
file(GLOB otbapps_list ${OTB_APPLICATIONS_DIR}/otbapp_*dll) # /lib/otb
list(APPEND PACKAGE_PEFILES ${otbapps_list})
set(alldlls)
set(notfound_dlls)
......@@ -55,6 +52,7 @@ macro(package_mingw)
Please consider adding their paths to SEARCHDIRS when calling package_mingw macro.")
endif()
endmacro(package_mingw)
set(SYSTEM_DLLS
......@@ -158,52 +156,4 @@ function(process_deps infile)
set(notfound_dlls "${notfound_dlls}" PARENT_SCOPE )
endif()
endfunction()
function(install_common outdir need_otb_apps)
set(APP_PREFIX_DIR "${outdir}")
set(APP_BIN_DIR "${APP_PREFIX_DIR}/bin")
set(APP_QTSQLITE_FILENAME "qsqlite4.dll")
set(APP_QTPLUGINS_DIR "${APP_PREFIX_DIR}/lib/qt4/plugins")
set(APP_OTBLIBS_DIR "${APP_PREFIX_DIR}/lib/otb")
set(APP_I18N_DIR "${APP_PREFIX_DIR}/lib/qt4/translations")
set(APP_DATA_DIR "${APP_PREFIX_DIR}/share")
install(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${APP_BIN_DIR}/qt.conf\"
\"[Paths]
Translations=../lib/qt4/translations
Plugins=../lib/qt4/plugins
\")" )
install(FILES ${QT_PLUGINS_DIR}/sqldrivers/${APP_QTSQLITE_FILENAME}
DESTINATION ${APP_QTPLUGINS_DIR}/sqldrivers)
####################### install translations #######################
get_qt_translation_files(QT_TRANSLATIONS_FILES)
install(FILES ${QT_TRANSLATIONS_FILES}
DESTINATION ${APP_I18N_DIR})
####################### install GDAL data #######################
set(GDAL_DATA ${MXE_BIN_DIR}/../share/gdal)
if(NOT EXISTS "${GDAL_DATA}/epsg.wkt")
message(FATAL_ERROR "Cannot generate package without GDAL_DATA : ${GDAL_DATA}")
endif()
install(DIRECTORY ${GDAL_DATA}
DESTINATION ${APP_DATA_DIR})
####################### Check otb applications #######################
if(need_otb_apps)
file(GLOB OTB_APPS_LIST ${OTB_MODULES_DIR}/../../../otb/applications/otbapp_*dll) # /lib/otb
if(NOT OTB_APPS_LIST)
message(FATAL_ERROR "No OTB-applications detected")
endif()
## otb apps dir /lib/otb/applications
install(DIRECTORY "${OTB_MODULES_DIR}/../../../otb/applications"
DESTINATION ${APP_OTBLIBS_DIR})
endif()
endfunction()
endfunction()
\ No newline at end of file
macro(create_monteverdi_application)
cmake_parse_arguments(APPLICATION "" "NAME;OUTPUT_NAME;COMPONENT_NAME;NEEDS_OTB_APPS" "SOURCES;LINK_LIBRARIES" ${ARGN} )
if(NOT DEFINED APPLICATION_NEEDS_OTB_APPS OR APPLICATION_NEEDS_OTB_APPS)
set(APPLICATION_NEEDS_OTB_APPS TRUE)
else()
set(APPLICATION_NEEDS_OTB_APPS FALSE)
endif()
if(WIN32)
add_executable(${APPLICATION_NAME}
WIN32
${APPLICATION_SOURCES})
elseif(APPLE)
add_executable(${APPLICATION_NAME}
MACOSX_BUNDLE
${APPLICATION_SOURCES})
else() #Linux
add_executable(${APPLICATION_NAME}
${APPLICATION_SOURCES})
endif()
set(EXECUTABLE_NAME ${APPLICATION_NAME})
if(APPLE)
string(SUBSTRING ${APPLICATION_NAME} 0 1 FIRST_LETTER)
string(TOUPPER ${FIRST_LETTER} FIRST_LETTER)
string(REGEX REPLACE "^.(.*)" "${FIRST_LETTER}\\1" APPLICATION_OUTPUT_NAME "${APPLICATION_NAME}")
endif()
if (APPLICATION_OUTPUT_NAME)
set_target_properties(${APPLICATION_NAME} PROPERTIES OUTPUT_NAME ${APPLICATION_OUTPUT_NAME})
set(EXECUTABLE_NAME ${APPLICATION_OUTPUT_NAME})
endif()
if(APPLE)
if(Monteverdi_USE_CPACK)
set(MACOS_FILES_DIR "${CMAKE_SOURCE_DIR}/Packaging/MacOS")
configure_file(${MACOS_FILES_DIR}/Info.plist.in
${CMAKE_BINARY_DIR}/Code/Application/${APPLICATION_NAME}/Info.plist
@ONLY)
configure_file(${MACOS_FILES_DIR}/StartupCommand.in
${CMAKE_BINARY_DIR}/Code/Application/${APPLICATION_NAME}/${EXECUTABLE_NAME}_start
@ONLY)
set_target_properties(${APPLICATION_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_BINARY_DIR}/Code/Application/${APPLICATION_NAME}/Info.plist")
endif(Monteverdi_USE_CPACK)
endif(APPLE)
target_link_libraries(${APPLICATION_NAME} ${APPLICATION_LINK_LIBRARIES})
#############################################################################
install(TARGETS ${APPLICATION_NAME}
BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT ${APPLICATION_COMPONENT_NAME}
RUNTIME DESTINATION ${Monteverdi_INSTALL_BIN_DIR} COMPONENT ${APPLICATION_COMPONENT_NAME}
LIBRARY DESTINATION ${Monteverdi_INSTALL_LIB_DIR} COMPONENT ${APPLICATION_COMPONENT_NAME}
ARCHIVE DESTINATION ${Monteverdi_INSTALL_LIB_DIR} COMPONENT ${APPLICATION_COMPONENT_NAME}
)
#############################################################################
endmacro(create_monteverdi_application)
\ No newline at end of file
# Get the translation files coming with Qt, and install them in the bundle
# They are loaded by Monteverdi.
function(get_qt_translation_files RESULT)
# These files are the "qt_<localename>.qm" files
# They are located in QT_TRANSLATIONS_DIR, which comes from FindQt4
file(GLOB translation_files ${QT_TRANSLATIONS_DIR}/qt_*)
# We need to remove the "qt_help_<localename>.qm" files from this list
foreach(translation_item ${translation_files})
if(${translation_item} MATCHES "qt_help")
list(REMOVE_ITEM translation_files ${translation_item})
endif()
endforeach()
set(${RESULT} ${translation_files} PARENT_SCOPE)
endfunction()
function(install_common outdir)
#a convenient cmake var for storing <prefix>
set(PKG_PREFIX_DIR "${outdir}")
#a convenient cmake var for storing <prefix>/bin
set(PKG_BIN_DIR "${PKG_PREFIX_DIR}/bin")
#name of qt's sqlite plugin. Varies with platform/OS
set(PKG_QTSQLITE_FILENAME "qsqlite4.dll")
#root folder where qt plugins are installed
set(PKG_QTPLUGINS_DIR "${PKG_PREFIX_DIR}/lib/qt4/plugins")
#root folder where otb applications are installed
set(PKG_OTBLIBS_DIR "${PKG_PREFIX_DIR}/lib/otb")
#qt4's distributes some translation of common message string used in Qt.
#This are provided with any qt installation. We reuse them in otb package
#so as not to reinvent the wheels.
set(PKG_I18N_DIR "${PKG_PREFIX_DIR}/lib/qt4/translations")
#<prefix>/share for otb i18n directory. This is different from qt's i18N directory
#which is <prefix>/share/qt4/translations.
set(PKG_OTB_I18N_DIR "${PACKAGE_PREFIX_DIR}/${Monteverdi_INSTALL_DATA_DIR}/i18n")
#<prefix>/share for gdal data files
set(PKG_DATA_DIR "${PKG_PREFIX_DIR}/share")
#place to install where qt.conf
set(PKG_QTCONF_DIR "${CMAKE_INSTALL_PREFIX}/${PKG_BIN_DIR}")
#a convenient cmake var to store the otb's install prefix
#guess install directory from OTB_MODULES_DIR
set(OTB_INSTALL_DIR ${OTB_MODULES_DIR}/../../../..)
# Just check if required variables are defined.
foreach(req
Monteverdi_SOURCE_DIR
Monteverdi_BINARY_DIR
MXE_BIN_DIR
OTB_MODULES_DIR
PACKAGE_PEFILES
QT_PLUGINS_DIR
CMAKE_INSTALL_PREFIX
PKG_QTCONF_DIR
OTB_INSTALL_DIR
)
if(NOT DEFINED ${req})
message(FATAL_ERROR "you must set ${req} before calling this method")
endif()
set(vars "${vars} ${req}=[${${req}}]\n")
endforeach(req)
#one for debugging..
install(CODE "message(\"CMake/PackageHelper.cmake:install_common(${outdir})\n${vars}\n\")")
####################### install cli and gui scripts ###########################
file(GLOB PKG_APP_SCRIPTS
${OTB_INSTALL_DIR}/bin/otbcli*
${OTB_INSTALL_DIR}/bin/otbgui*) #
list(LENGTH PKG_APP_SCRIPTS PKG_APP_SCRIPTS_LENGTH)
if (PKG_APP_SCRIPTS_LENGTH LESS 1)
message(WARNING "PKG_APP_SCRIPTS is empty: ${PKG_APP_SCRIPTS}")
endif()
install(FILES ${PKG_APP_SCRIPTS}
DESTINATION ${PKG_BIN_DIR})
foreach(exe_file ${PACKAGE_PEFILES})
#check ext is .exe
get_filename_component(FILE_EXT ${exe_file} EXT)
string(TOLOWER ${FILE_EXT} file_ext)
if( ${file_ext} STREQUAL ".exe")
get_filename_component(base_name ${exe_file} NAME_WE)
#check if a .bat exists?
if(EXISTS ${Monteverdi_SOURCE_DIR}/Packaging/Windows/${base_name}.bat)
install(FILES ${Monteverdi_SOURCE_DIR}/Packaging/Windows/${base_name}.bat
DESTINATION ${PKG_BIN_DIR})
endif()
endif()
endforeach()
install(CODE "file(WRITE \"${CMAKE_INSTALL_PREFIX}/${PKG_PREFIX_DIR}/otbenv.cmd\"
\"set CURRENT_SCRIPT_DIR=%~dp0
set PATH=%PATH%;%CURRENT_SCRIPT_DIR%\\bin
set GDAL_DATA=%CURRENT_SCRIPT_DIR%\\share\\gdal
\")" )
####################### create and install qt.conf #######################
install(CODE "file(WRITE \"${PKG_QTCONF_DIR}/qt.conf\"
\"[Paths]
Translations=../lib/qt4/translations
Plugins=../lib/qt4/plugins
\")" )
####################### install sqldriver plugin ########################
install(FILES ${QT_PLUGINS_DIR}/sqldrivers/${PKG_QTSQLITE_FILENAME}
DESTINATION ${PKG_QTPLUGINS_DIR}/sqldrivers)
####################### install translations ###########################
#get all translations already distributed with qt4
get_qt_translation_files(QT_TRANSLATIONS_FILES)
#install all files in ${QT_TRANSLATIONS_FILES}
install(FILES ${QT_TRANSLATIONS_FILES}
DESTINATION ${PKG_I18N_DIR})
#translation of monteverdi specific strings
file(GLOB APP_TS_FILES ${Monteverdi_SOURCE_DIR}/i18n/*.ts) # qm files
foreach(APP_TS_FILE ${APP_TS_FILES})
get_filename_component(APP_TS_FILENAME ${APP_TS_FILE} NAME_WE)