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

PKG: Generate single windows archive with OTB and Monteverdi

parent 9d6d5a23
This diff is collapsed.
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)
install(FILES ${Monteverdi_BINARY_DIR}/i18n/${APP_TS_FILENAME}.qm
DESTINATION ${PKG_OTB_I18N_DIR})
endforeach()
####################### 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} ${MXE_BIN_DIR}")
endif()
install(DIRECTORY ${GDAL_DATA}
DESTINATION ${PKG_DATA_DIR})
####################### Check otb applications ########################
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()
####################### Install otb applications ######################
install(DIRECTORY "${OTB_MODULES_DIR}/../../../otb/applications"
DESTINATION ${PKG_OTBLIBS_DIR})
endfunction()
......@@ -7,6 +7,12 @@ if(POLICY CMP0040)
cmake_policy(SET CMP0040 OLD)
endif()
# CMP0040 : from CMake 3.0 or higher,
# old behaviour is to link to qtmain if explicitly said so.
if(POLICY CMP0020)
cmake_policy(SET CMP0020 OLD)
endif()
#----------------------------------------------------------------------------
# Modules
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} )
......@@ -220,7 +226,7 @@ include( PreventInstallOnBuildTree )
include( DeployQtConf )
#function to create installer for applications
include( CPackFunctions )
include( MonteverdiApplicationMacros )
#----------------------------------------------------------------------------
# Configure files with settings for use by the build.
......@@ -284,37 +290,99 @@ endif()
#cpack has a built-in target called 'package'. In our case we create two standalone installers with
#and uses a custom target named packages.
if(WIN32)
#RK: two packages
create_cpack_config()
if(Monteverdi_USE_CPACK)
add_custom_target(packages
COMMAND ${CMAKE_COMMAND} "--build" "${CMAKE_BINARY_DIR}" "--target" "install"
COMMAND ${CMAKE_CPACK_COMMAND} "--config" "${CMAKE_BINARY_DIR}/CPackConfig-Monteverdi.cmake" "--verbose")
# add_custom_target(PACKAGE_Mapla
# COMMAND ${CMAKE_CPACK_COMMAND}
# "--config" "${CMAKE_BINARY_DIR}/CPackConfig-Mapla.cmake" "--verbose"
# DEPENDS PACKAGE_Monteverdi)
# create_cpack_config()
endif() # (Monteverdi_USE_CPACK)
# stop generation of msvc packages for windows. 04-apr-2016. point OTB.
#TODO: fix after 5.4.0 release.
#set(PKG_NAME ${PROJECT_NAME})
set(PKG_NAME OTB)
set(PACKAGE_VERSION_STRING ${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH})
if(CMAKE_CROSSCOMPILING)
#print MXE_TARGET_DIR for the sake of debugging. This is visible on on dashboard log
if(DEFINED MXE_TARGET_DIR)
message(STATUS "MXE_TARGET_DIR = ${MXE_TARGET_DIR}")
endif() # (DEFINED MXE_TARGET_DIR)
if(NOT DEFINED MXE_TARGET_DIR)
message(FATAL_ERROR "MXE_TARGET_DIR is missing")
endif()
find_program(ZIP_EXECUTABLE zip)
if(NOT ZIP_EXECUTABLE)
message(FATAL_ERROR "Cannot find zip executable. Please add it to your path")
endif()
##### End of checking required tools and platform. (cross-compile with zip)
#define the name of final archive based on build architecture. win32 or win64?
if(MXE_TARGET_DIR MATCHES "i686")
set(mxearch x86)
set(archive_name ${PKG_NAME}-${PACKAGE_VERSION_STRING}-win32)
elseif(MXE_TARGET_DIR MATCHES "x86_64")
set(mxearch x64)
set(archive_name ${PKG_NAME}-${PACKAGE_VERSION_STRING}-win64)
endif()
#empty build directory
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_INSTALL_PREFIX}/${archive_name}")
#create a CMakeLists.txt with some contents for packaging.
#This will let us run packaging as a seperate project!
get_filename_component(mxeroot ${MXE_TARGET_DIR} PATH)
get_filename_component(mxeroot ${mxeroot} PATH)
file(WRITE "${CMAKE_BINARY_DIR}/_mingw/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/PackageHelper.cmake)
package_mingw(
ARCH \"${mxearch}\"
MXEROOT \"${mxeroot}\"
PREFIX_DIR \"${archive_name}\"
SEARCHDIRS \"\")")
add_custom_target(InstallProject
COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}" --target install
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
#custom targets to configure , build and create package.
add_custom_target(configure-mingw-package
COMMAND ${CMAKE_COMMAND}
"${CMAKE_BINARY_DIR}/_mingw"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/_mingw"
DEPENDS InstallProject)
add_custom_target(make-mingw-package
COMMAND ${CMAKE_COMMAND}
"--build" "${CMAKE_BINARY_DIR}/_mingw" "--target" "install"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/_mingw"
DEPENDS configure-mingw-package)
#add custom target that create mapla and monteverdi2 archives.
add_custom_target(packages
COMMAND ${CMAKE_COMMAND} -E touch mingw-package
COMMAND ${ZIP_EXECUTABLE} "-r" "${CMAKE_BINARY_DIR}/${archive_name}.zip" "${archive_name}"
WORKING_DIRECTORY "${CMAKE_INSTALL_PREFIX}"
DEPENDS
create-Monteverdi-mingw-archive
create-Mapla-mingw-archive)
DEPENDS make-mingw-package)
endif() # (CMAKE_CROSSCOMPILING)
endif() # (WIN32)
if(UNIX)
#TODO:
if(APPLE)
#TODO:
endif()
endif()
#For MacOS and Windows platform, we create a custom target called packages to generate packages
#For linux: the packages are provided via respective package management tool. (deb, rpm etc..)
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