Commit f1a829fc authored by Rashad Kanavath's avatar Rashad Kanavath

PKG: keep packaging scripts in one place

parent 4c063200
if(WIN32 OR CMAKE_CROSSCOMPILING)
add_custom_target(PACKAGE-TOOLS)
return()
endif()
include(ExternalProject)
if(NOT __EXTERNAL_PACKAGE_TOOLS__)
set(__EXTERNAL_PACKAGE_TOOLS__ 1)
......
......@@ -5,8 +5,6 @@ macro(super_package)
set(loader_program_names "${MXE_ARCH}-w64-mingw32.shared-objdump")
set(loader_program_PATHS "${MXE_MXEROOT}/usr/bin")
set(LOADER_PROGRAM_ARGS "-p")
#guess install directory from OTB_MODULES_DIR
set(OTB_INSTALL_DIR ${OTB_MODULES_DIR}/../../../..)
set(DEPENDENCIES_INSTALL_DIR "${MXE_MXEROOT}/usr/${MXE_ARCH}-w64-mingw32.shared")
else()
if(APPLE)
......@@ -18,8 +16,6 @@ macro(super_package)
set(LOADER_PROGRAM_ARGS "-p")
set(loader_program_PATHS /usr/bin) # a path that is already listed in default path on Linux
endif()
#both OTB_INSTALL_DIR DEPENDENCIES_INSTALL_DIR are same for superbuild
set(OTB_INSTALL_DIR ${PKG_INSTALL_PREFIX})
set(DEPENDENCIES_INSTALL_DIR ${PKG_INSTALL_PREFIX})
endif()
......@@ -355,6 +351,7 @@ function(install_monteverdi_files)
# Just check if required variables are defined.
foreach(req
Monteverdi_SOURCE_DIR
PACKAGE_SUPPORT_FILES_DIR
QT_PLUGINS_DIR
PKG_STAGE_BIN_DIR
PKG_QTSQLITE_FILENAME
......@@ -370,14 +367,16 @@ function(install_monteverdi_files)
#install icon file for .app file. Monteverdi and Mapla has same icon!
if(APPLE)
install(FILES ${Monteverdi_SOURCE_DIR}/Packaging/MacOS/Monteverdi.icns
install(FILES ${PACKAGE_SUPPORT_FILES_DIR}/Monteverdi.icns
DESTINATION ${PKG_STAGE_DIR})
endif()
####################### install mingw qt.conf ##########################
if(EXISTS ${Monteverdi_SOURCE_DIR}/Packaging/Windows/mingw/qt.conf)
install(FILES ${Monteverdi_SOURCE_DIR}/Packaging/Windows/mingw/qt.conf
DESTINATION ${PKG_STAGE_BIN_DIR})
if(WIN32 OR CMAKE_CROSSCOMPILING)
####################### install mingw qt.conf ##########################
if(EXISTS ${PACKAGE_SUPPORT_FILES_DIR}/qt.conf)
install(FILES ${PACKAGE_SUPPORT_FILES_DIR}/qt.conf
DESTINATION ${PKG_STAGE_BIN_DIR})
endif()
endif()
####################### install sqldriver plugin ########################
......@@ -412,21 +411,23 @@ endmacro()
# over *pkgsetup.in
function(configure_package)
if(UNIX)
set(EXE_EXT "")
set(SCR_EXT ".sh")
if(APPLE)
set(LIB_EXT "*dylib")
else()
set(LIB_EXT "*so")
endif()
endif()
if(WIN32 OR CMAKE_CROSSCOMPILING)
set(EXE_EXT ".exe")
set(LIB_EXT "*dll")
set(SCR_EXT ".bat")
endif()
else() #(WIN32 OR CMAKE_CROSSCOMPILING)
if(UNIX)
set(EXE_EXT "")
set(SCR_EXT ".sh")
set(LIB_EXT "*so")
#Q: why apple changed this one?
#A: To break compatibility with others and make money!
if(APPLE)
set(LIB_EXT "*dylib")
endif() #APPLE
endif() #UNIX
endif() #(WIN32 OR CMAKE_CROSSCOMPILING)
#This must exist in any OTB Installation minimal or full
set(VAR_IN_PKGSETUP_CONFIGURE "bin/otbApplicationLauncherCommandLine")
......@@ -435,41 +436,30 @@ function(configure_package)
message(FATAL_ERROR "${OTB_INSTALL_DIR}/bin/otbApplicationLauncherCommandLine${EXE_EXT} not found.")
endif()
foreach(EXE_FILE otbApplicationLauncherQt
foreach(EXE_FILE
otbApplicationLauncherQt
iceViewer
otbTestDriver)
otbTestDriver
monteverdi
mapla)
if(EXISTS "${OTB_INSTALL_DIR}/bin/${EXE_FILE}${EXE_EXT}")
#see the first comment about VAR_IN_PKGSETUP_CONFIGURE
set(VAR_IN_PKGSETUP_CONFIGURE "${VAR_IN_PKGSETUP_CONFIGURE} bin/${EXE_FILE}${EXE_EXT}")
list(APPEND PKG_PEFILES
"${OTB_INSTALL_DIR}/bin/${EXE_FILE}${EXE_EXT}")
else()
message(WARNING "'${OTB_INSTALL_DIR}/bin/${EXE_FILE}${EXE_EXT}'(not found. skipping)")
endif()
endforeach()
foreach(EXE_FILE monteverdi
mapla)
if(EXISTS "${OTB_INSTALL_DIR}/bin/${EXE_FILE}${EXE_EXT}")
#VAR_IN_PKGSETUP_CONFIGURE might seem a bit redundant variable if you
#consider PKG_PEFILES which also has same content.
#But VAR_IN_PKGSETUP_CONFIGURE goes into pkgsetup.in for Linux standalone binaries
# and other one (PKG_PEFILES) is for dependency resolution in
# process_deps() function
set(VAR_IN_PKGSETUP_CONFIGURE "${VAR_IN_PKGSETUP_CONFIGURE} bin/${EXE_FILE}${EXE_EXT}")
list(APPEND PKG_PEFILES
"${OTB_INSTALL_DIR}/bin/${EXE_FILE}${EXE_EXT}")
endif()
#For Unixes we write the startup script in the *pkgsetup.in
if(WIN32 OR CMAKE_CROSSCOMPILING)
if(DEFINED Monteverdi_SOURCE_DIR)
if(EXISTS ${Monteverdi_SOURCE_DIR}/Packaging/${EXE_FILE}${SCR_EXT})
install(PROGRAMS
${Monteverdi_SOURCE_DIR}/Packaging/${EXE_FILE}${SCR_EXT}
DESTINATION
"${PKG_STAGE_DIR}")
endif()
endif()
endif(WIN32 OR CMAKE_CROSSCOMPILING)
endforeach()
#For Unixes we write the startup script in the *pkgsetup.in
if(WIN32 OR CMAKE_CROSSCOMPILING)
install(PROGRAMS
"${PACKAGE_SUPPORT_FILES_DIR}/${EXE_FILE}${SCR_EXT}"
DESTINATION
"${PKG_STAGE_DIR}")
endif(WIN32 OR CMAKE_CROSSCOMPILING)
file(GLOB OTB_APPS_LIST ${OTB_APPLICATIONS_DIR}/otbapp_${LIB_EXT}) # /lib/otb
......@@ -734,4 +724,4 @@ function(process_deps infile)
endif(NOT DLL_FOUND)
set(notfound_dlls "${notfound_dlls}" PARENT_SCOPE )
endif()
endfunction()
\ No newline at end of file
endfunction()
# cpack has a built-in target called 'package'. In our case we create two standalone installers with
# and uses a custom target named packages.
# stop generation of msvc packages for windows. 04-apr-2016. point OTB.
##### check if standalone project ######
if(NOT PROJECT_NAME)
cmake_minimum_required(VERSION 2.6)
......@@ -6,160 +11,108 @@ if(NOT PROJECT_NAME)
endif()
set(OUT_OF_SOURCE_BUILD FALSE)
if(PROJECT_NAME STREQUAL "OTBPackaging")
set(OUT_OF_SOURCE_BUILD TRUE)
endif()
option(GENERATE_PACKAGE "Generate OTB package" ON)
option(GENERATE_XDK "Generate XDK for OTB development" OFF)
if(NOT GENERATE_PACKAGE AND NOT GENERATE_XDK)
#well. we don't have any businees here. Let's move on..
return()
endif()
#TODO: remove afer monteverdi is merged to OTB.
if(WIN32 OR CMAKE_CROSSCOMPILING)
set(MXE_TARGET_DIR "" CACHE PATH "path to mxe directory")
set(OTB_SOURCE_DIR "" CACHE PATH "path to otb source directory")
find_program(ZIP_EXECUTABLE zip)
if(NOT ZIP_EXECUTABLE)
message(FATAL_ERROR "Cannot find zip executable. Please add it to your path")
endif()
endif()
include(${CMAKE_CURRENT_SOURCE_DIR}/PMacros.cmake)
if(OUT_OF_SOURCE_BUILD)
if(BUILD_TESTING)
include(CTest)
endif()
set(SUPERBUILD_BINARY_DIR "" CACHE PATH "path to superbuild binary directory")
option(GENERATE_XDK "Generate XDK for OTB development" OFF)
# From parent scope (SuperBuild) we have
# ENABLE_MONTEVERDI, DOWNLOAD_LOCATION, SB_INSTALL_PREFIX
option(ENABLE_MONTEVERDI "enable monteverdi" ON)
set(DOWNLOAD_LOCATION "" CACHE PATH "path to superbuild binary directory")
set(SB_INSTALL_PREFIX "" CACHE PATH "path to superbuild install directory")
else()
# SUPERBUILD_BINARY_DIR is only set in Packaging/CMakeLists.txt and not available
# in the parent scope like others. So we need to set it as CMAKE_BINARY_DIR
# if doing packages from source tree.
set(SUPERBUILD_BINARY_DIR ${CMAKE_BINARY_DIR})
endif()
set(CMAKE_INSTALL_PREFIX "${SB_INSTALL_PREFIX}")
set(PKG_INSTALL_PREFIX "${SB_INSTALL_PREFIX}")
if(NOT WIN32)
#set CMAKE_INSTALL_PREFIX and PKG_INSTALL_PREFIX to SB_INSTALL_PREFIX for convenience.
set(CMAKE_INSTALL_PREFIX "${SB_INSTALL_PREFIX}")
endif()
#used in PackageHelper.cmake (don't change)
set(PKG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
set(PACKAGE_NAME OTB)
set(PACKAGE_LONG_NAME OrfeoToolBox)
if(UNIX)
if(APPLE)
set(PACKAGE_PLATFORM_NAME "Darwin")
else()
set(PACKAGE_PLATFORM_NAME "Linux")
if(WIN32 OR CMAKE_CROSSCOMPILING)
set(PACKAGE_PLATFORM_NAME "win")
if(MXE_TARGET_DIR MATCHES "i686")
set(MXE_ARCH "i686")
set(PACKAGE_ARCH "32")
elseif(MXE_TARGET_DIR MATCHES "x86_64")
set(MXE_ARCH "x86_64")
set(PACKAGE_ARCH "64") #helper for ARCHIVE_NAME
endif()
endif()
set(PACKAGE_ARCH 32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PACKAGE_ARCH 64)
endif()
get_filename_component(MXE_MXEROOT ${MXE_TARGET_DIR} PATH)
get_filename_component(MXE_MXEROOT ${MXE_MXEROOT} PATH)
set(PACKAGE_VERSION_STRING ${OTB_VERSION_MAJOR}.${OTB_VERSION_MINOR}.${OTB_VERSION_PATCH})
else() #(WIN32 OR CMAKE_CROSSCOMPILING)
if(UNIX)
set(PACKAGE_ARCH 32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PACKAGE_ARCH 64)
endif()
if(APPLE)
set(PACKAGE_PLATFORM_NAME "Darwin")
else()
set(PACKAGE_PLATFORM_NAME "Linux")
endif()
get_version("${OTB_SUPERBUILD_SOURCE_DIR}/CMake/External_itk.cmake" "ITK_SB_VERSION" ITK_SB_VERSION)
get_version("${OTB_SOURCE_DIR}/CMakeLists.txt" "OTB_VERSION_" OTB_VERSION_STRING)
set(PACKAGE_VERSION_STRING ${get_version_OTB_VERSION_STRING})
endif(UNIX)
endif() #(WIN32 OR CMAKE_CROSSCOMPILING)
get_filename_component(OTB_SUPERBUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PATH)
get_filename_component(OTB_SOURCE_DIR ${OTB_SUPERBUILD_SOURCE_DIR} PATH)
include(version_macro.cmake)
get_version("${OTB_SUPERBUILD_SOURCE_DIR}/CMake/External_itk.cmake" "ITK_SB_VERSION" ITK_SB_VERSION)
get_version("${OTB_SOURCE_DIR}/CMakeLists.txt" "OTB_VERSION_" OTB_VERSION_STRING)
set(PACKAGE_LIST OTB)
if(GENERATE_XDK)
list(APPEND PACKAGE_LIST XDK)
endif()
set(OTB_SUPERBUILD_SOURCE_DIR ${OTB_SOURCE_DIR}/SuperBuild)
include(${OTB_SUPERBUILD_SOURCE_DIR}/CMake/External_pkgtools.cmake)
foreach(PACKAGE ${PACKAGE_LIST})
#message( "-- To get ${PACKAGE} package. Run 'make PACKAGE-${PACKAGE}'")
message( "-- Configuring ${PACKAGE} package")
set(PACKAGE_PROJECT_DIR ${CMAKE_BINARY_DIR}/${PACKAGE}-PACKAGE)
set(PACKAGE_PROJECT_DIR ${CMAKE_BINARY_DIR}/${pkg}-PACKAGE)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${PACKAGE_PROJECT_DIR}/build")
macro_setup_cmake_sources(OTB)
if(GENERATE_XDK)
macro_setup_cmake_sources(XDK)
endif()
#Easy way to have the write "PACKAGE_PROJECT_DIR/src/PACKAGE-${PACKAGE}/CMakeLists.txt"
#inside foreach()
if("${PACKAGE}" STREQUAL "XDK")
set(PACKAGE_PLATFORM_NAME "xdk-${PACKAGE_PLATFORM_NAME}")
set(PKG_GENERATE_XDK ON)
else()
set(PKG_GENERATE_XDK OFF)
endif()
set(PACKAGE-configure_DEPENDS PACKAGE-TOOLS)
macro_update_dependencies_list(PACKAGE-configure_DEPENDS)
set(ARCHIVE_NAME ${PACKAGE_NAME}-${get_version_OTB_VERSION_STRING}-${PACKAGE_PLATFORM_NAME}${PACKAGE_ARCH})
file(WRITE "${PACKAGE_PROJECT_DIR}/src/PACKAGE-${PACKAGE}/CMakeLists.txt"
"cmake_minimum_required(VERSION 2.6)
include(CMakeParseArguments)
set(PKG_INSTALL_PREFIX \"${PKG_INSTALL_PREFIX}\")
set(CMAKE_INSTALL_PREFIX \"${PKG_INSTALL_PREFIX}\")
set(DOWNLOAD_LOCATION \"${DOWNLOAD_LOCATION}\")
set(PACKAGE_SUPPORT_FILES_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\")
set(Monteverdi_SOURCE_DIR \"${SUPERBUILD_BINARY_DIR}/MVD/src/MVD\")
set(Monteverdi_BINARY_DIR \"${SUPERBUILD_BINARY_DIR}/MVD/build\")
set(OTB_INSTALL_DIR \"${SUPERBUILD_BINARY_DIR}/OTB/build\")
set(QT_PLUGINS_DIR \"${PKG_INSTALL_PREFIX}/plugins\")
set(QT_TRANSLATIONS_DIR \"${PKG_INSTALL_PREFIX}/translations\")
set(ITK_VERSION_STRING \"${get_version_ITK_SB_VERSION}\")
set(PKG_GENERATE_XDK ${PKG_GENERATE_XDK})
include(\"${OTB_SUPERBUILD_SOURCE_DIR}/CMake/PackageHelper.cmake\")
super_package(STAGE_DIR \"${ARCHIVE_NAME}\")")
#we have a dependency to PACKAGE_TOOLS always. check External_pkgtools.cmake
set(PACKAGE-${PACKAGE}-configure_EXTRA_DEPENDS PACKAGE-TOOLS)
#if we are building packages seperately we need to check OTB and MVD buil
if(OUT_OF_SOURCE_BUILD)
add_custom_target(PACKAGE-${PACKAGE}-check-otb
COMMAND ${CMAKE_COMMAND} --build "${SUPERBUILD_BINARY_DIR}/OTB/build"
WORKING_DIRECTORY "${SUPERBUILD_BINARY_DIR}/OTB/build"
)
if(ENABLE_MONTEVERDI)
add_custom_target(PACKAGE-${PACKAGE}-check-monteverdi
COMMAND ${CMAKE_COMMAND} --build "${SUPERBUILD_BINARY_DIR}/MVD/build"
WORKING_DIRECTORY "${SUPERBUILD_BINARY_DIR}/MVD/build"
DEPENDS PACKAGE-${PACKAGE}-check-otb
)
list(APPEND
PACKAGE-${PACKAGE}-configure_EXTRA_DEPENDS
PACKAGE-${PACKAGE}-check-monteverdi)
else(ENABLE_MONTEVERDI)
#just add only check-otb target to extra depends
list(APPEND
PACKAGE-${PACKAGE}-configure_EXTRA_DEPENDS
PACKAGE-${PACKAGE}-check-otb)
endif(ENABLE_MONTEVERDI)
else(OUT_OF_SOURCE_BUILD)
list(APPEND
PACKAGE-${PACKAGE}-configure_EXTRA_DEPENDS
OTB)
if(ENABLE_MONTEVERDI)
list(APPEND
PACKAGE-${PACKAGE}-configure_EXTRA_DEPENDS
MVD)
endif(ENABLE_MONTEVERDI)
endif(OUT_OF_SOURCE_BUILD)
set(PACKAGE-${PACKAGE}-configure_EXTRA_DEPENDS)
add_custom_target(PACKAGE-${PACKAGE}-configure
COMMAND ${CMAKE_COMMAND}
"${PACKAGE_PROJECT_DIR}/src/PACKAGE-${PACKAGE}"
WORKING_DIRECTORY "${PACKAGE_PROJECT_DIR}/build"
DEPENDS
${PACKAGE-${PACKAGE}-configure_EXTRA_DEPENDS}
)
add_custom_target(PACKAGE-${PACKAGE}-build
COMMAND ${CMAKE_COMMAND}
"--build" "${PACKAGE_PROJECT_DIR}/build" "--target" "install"
WORKING_DIRECTORY "${PACKAGE_PROJECT_DIR}/build"
DEPENDS PACKAGE-${PACKAGE}-configure
)
add_custom_target(PACKAGE-${PACKAGE}
ALL DEPENDS
COMMAND
${MAKESELF_SCRIPT}
"--target"
"${ARCHIVE_NAME}"
"${PKG_INSTALL_PREFIX}/${ARCHIVE_NAME}"
"${ARCHIVE_NAME}.run"
"${PACKAGE_LONG_NAME} ${get_version_OTB_VERSION_STRING}"
"./pkgsetup"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS PACKAGE-${PACKAGE}-build
)
add_custom_target(PACKAGE-${PACKAGE}-clean
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/${PACKAGE}-PACKAGE"
COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.run"
COMMAND ${CMAKE_COMMAND} "${CMAKE_BINARY_DIR}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
)
endforeach()
\ No newline at end of file
macro_create_targets_for_package(OTB)
if(GENERATE_XDK)
macro_create_targets_for_package(XDK)
endif()
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Mapla launcher to set up proper environment
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Set locale numeric to C
@set LC_NUMERIC=C
:: Get the directory of the current script
@set CURRENT_SCRIPT_DIR=%~dp0
:: Set GDAL_DATA env. variable
@set GDAL_DATA=%CURRENT_SCRIPT_DIR%share\gdal
:: Set GEOTIFF_CSV env. variable
@set GEOTIFF_CSV=%CURRENT_SCRIPT_DIR%share\epsg_csv
:: Performance issue: do not set ITK_AUTOLOAD_PATH to avoid loading of OTB-Applications.
@set OTB_APPLICATION_PATH=%CURRENT_SCRIPT_DIR%lib\otb\applications
:: Set current dir to HOME dir because Monteverdi generates temporary files and need write access
@cd %HOMEDRIVE%%HOMEPATH%
:: Start Monteverdi
@start "Monteverdi Application Launcher" /B "%CURRENT_SCRIPT_DIR%bin\mapla.exe" %*
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Monteverdi launcher to set up proper environment
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Set locale numeric to C
@set LC_NUMERIC=C
:: Get the directory of the current script
@set CURRENT_SCRIPT_DIR=%~dp0
:: Set GDAL_DATA env. variable
@set GDAL_DATA=%CURRENT_SCRIPT_DIR%share\gdal
:: Set GEOTIFF_CSV env. variable
@set GEOTIFF_CSV=%CURRENT_SCRIPT_DIR%share\epsg_csv
:: Performance issue: do not set ITK_AUTOLOAD_PATH to avoid loading of OTB-Applications.
@set OTB_APPLICATION_PATH=%CURRENT_SCRIPT_DIR%lib\otb\applications
:: Set current dir to HOME dir because Monteverdi generates temporary files and need write access
@cd %HOMEDRIVE%%HOMEPATH%
:: Start Monteverdi
@start "Monteverdi Viewer" /B "%CURRENT_SCRIPT_DIR%bin\monteverdi.exe" %*
macro(macro_setup_cmake_sources pkg)
message( "-- Configuring ${pkg} package")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${PACKAGE_PROJECT_DIR}/build")
#Easy way to have the write "PACKAGE_PROJECT_DIR/src/CMakeLists.txt"
#inside foreach()
if("${pkg}" STREQUAL "XDK")
set(PACKAGE_PLATFORM_NAME "xdk-${PACKAGE_PLATFORM_NAME}")
set(PKG_GENERATE_XDK ON)
else()
set(PKG_GENERATE_XDK OFF)
endif()
#set archive name inside loop
set(ARCHIVE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION_STRING}-${PACKAGE_PLATFORM_NAME}${PACKAGE_ARCH})
if(WIN32 OR CMAKE_CROSSCOMPILING)
set(cache_Monteverdi_SOURCE_DIR "${Monteverdi_SOURCE_DIR}")
set(cache_Monteverdi_BINARY_DIR "${Monteverdi_BINARY_DIR}")
set(cache_QT_PLUGINS_DIR "${QT_PLUGINS_DIR}")
set(cache_QT_TRANSLATIONS_DIR "${QT_TRANSLATIONS_DIR}")
set(cache_PKG_INSTALL_PREFIX "${PKG_INSTALL_PREFIX}")
set(cache_CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
#guess install directory from OTB_MODULES_DIR
set(cache_OTB_INSTALL_DIR "${OTB_MODULES_DIR}/../../../..")
set(cache_ITK_VERSION_STRING)
set(EXTRA_CACHE_CONFIG "
set(CMAKE_CROSSCOMPILING ON)
set(MXE_ARCH \"${MXE_ARCH}\")
set(MXE_MXEROOT \"${MXE_MXEROOT}\")")
else() #unixes
set(cache_Monteverdi_SOURCE_DIR "${SUPERBUILD_BINARY_DIR}/MVD/src/MVD")
set(cache_Monteverdi_BINARY_DIR "${SUPERBUILD_BINARY_DIR}/MVD/build")
set(cache_PACKAGE_SUPPORT_FILES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Files")
set(cache_QT_PLUGINS_DIR "${PKG_INSTALL_PREFIX}/plugins")
set(cache_QT_TRANSLATIONS_DIR "${PKG_INSTALL_PREFIX}/translations")
set(cache_PKG_INSTALL_PREFIX "${PKG_INSTALL_PREFIX}")
set(cache_CMAKE_INSTALL_PREFIX "${PKG_INSTALL_PREFIX}")
set(cache_OTB_INSTALL_DIR "${SUPERBUILD_BINARY_DIR}/OTB/build")
set(cache_ITK_VERSION_STRING "${get_version_ITK_SB_VERSION}")
set(EXTRA_CACHE_CONFIG)
endif()
file(WRITE "${PACKAGE_PROJECT_DIR}/src/CMakeLists.txt"
"cmake_minimum_required(VERSION 2.6)
include(CMakeParseArguments)
include(CMakeDetermineSystem)
set(Monteverdi_SOURCE_DIR \"${cache_Monteverdi_SOURCE_DIR}\")
set(Monteverdi_BINARY_DIR \"${cache_Monteverdi_BINARY_DIR}\")
set(PACKAGE_SUPPORT_FILES_DIR \"${OTB_SOURCE_DIR}/SuperBuild/Packaging\")
set(QT_PLUGINS_DIR \"${cache_QT_PLUGINS_DIR}\")
set(QT_TRANSLATIONS_DIR \"${cache_QT_TRANSLATIONS_DIR}\")
set(PKG_INSTALL_PREFIX \"${cache_PKG_INSTALL_PREFIX}\")
set(CMAKE_INSTALL_PREFIX \"${cache_CMAKE_INSTALL_PREFIX}\")
set(OTB_INSTALL_DIR ${cache_OTB_INSTALL_DIR})
set(ITK_VERSION_STRING \"${cache_ITK_VERSION_STRING}\")
set(Monteverdi_INSTALL_DATA_DIR \"share/otb\")
set(PKG_GENERATE_XDK ${PKG_GENERATE_XDK})
${EXTRA_CACHE_CONFIG}
include(\"${OTB_SUPERBUILD_SOURCE_DIR}/CMake/PackageHelper.cmake\")
super_package(STAGE_DIR \"${ARCHIVE_NAME}\")" )
endmacro()
macro(macro_update_dependencies_list list_variable)
if(WIN32 OR CMAKE_CROSSCOMPILING)
add_custom_target(PACKAGE-check)
else() #Unxies Using SuperBuild
if(OUT_OF_SOURCE_BUILD)
if(ENABLE_MONTEVERDI)
add_custom_target(PACKAGE-check
COMMAND ${CMAKE_COMMAND} --build "${SUPERBUILD_BINARY_DIR}/MVD/build"
WORKING_DIRECTORY "${SUPERBUILD_BINARY_DIR}/MVD/build"
DEPENDS PACKAGE-check-otb
)
else()
add_custom_target(PACKAGE-check
COMMAND ${CMAKE_COMMAND} --build "${SUPERBUILD_BINARY_DIR}/OTB/build"
WORKING_DIRECTORY "${SUPERBUILD_BINARY_DIR}/OTB/build"
)
endif(ENABLE_MONTEVERDI)
else(OUT_OF_SOURCE_BUILD)
add_custom_target(PACKAGE-check)
endif(OUT_OF_SOURCE_BUILD)
endif()
list(APPEND ${list_variable} PACKAGE-check)
endmacro()
macro(macro_create_targets_for_package pkg)
#configure
add_custom_target(PACKAGE-${pkg}-configure
COMMAND ${CMAKE_COMMAND}
"${PACKAGE_PROJECT_DIR}/src"
WORKING_DIRECTORY "${PACKAGE_PROJECT_DIR}/build"
DEPENDS ${PACKAGE-configure_DEPENDS}
)
#build
add_custom_target(PACKAGE-${pkg}-build
COMMAND ${CMAKE_COMMAND}
"--build" "${PACKAGE_PROJECT_DIR}/build" "--target" "install"
WORKING_DIRECTORY "${PACKAGE_PROJECT_DIR}/build"
DEPENDS PACKAGE-${pkg}-configure
)
#create package
# creation of package is different from windows and unix like
if(WIN32 OR CMAKE_CROSSCOMPILING)
add_custom_target(PACKAGE-${pkg}
COMMAND ${ZIP_EXECUTABLE}
"-r" "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.zip" "${PKG_INSTALL_PREFIX}/${ARCHIVE_NAME}"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS PACKAGE-${pkg}-build
)
else()
add_custom_target(PACKAGE-${pkg}
ALL DEPENDS
COMMAND ${MAKESELF_SCRIPT}
"--target"
"${ARCHIVE_NAME}"
"${PKG_INSTALL_PREFIX}/${ARCHIVE_NAME}"
"${ARCHIVE_NAME}.run"
"${PACKAGE_LONG_NAME} ${PACKAGE_VERSION_STRING}"
"./pkgsetup"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS PACKAGE-${pkg}-build
)
endif()
#clean
add_custom_target(PACKAGE-${pkg}-clean
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/${PACKAGE}-PACKAGE"
COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}${PACKAGE_EXTENSION}"
COMMAND ${CMAKE_COMMAND} "${CMAKE_BINARY_DIR}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
)
endmacro(macro_create_targets_for_package)
#macro: get_version
#args :
# input_file - Input cmake file where the version variable is set via cmake set() command.
# Example: ${OTB_SUPERBUILD_SOURCE_DIR}/CMake/External_itk.cmake
#match_string - A match string to filter out required set() commands.
# Example: "ITK_SB_VERSION" will get all set(ITK_SB_VERSION_MAJOR)
# set(ITK_SB_VERSION_MINOR) set(ITK_SB_VERSION_PATCH)
# cmake_var_to_check - Name of variable that has the version string stored using set(..)
# command inside the input_file.
# Example: ITK_SB_VERSION. This is same as match_string but not always
# Sample usage:
# get_version(
# "${OTB_SUPERBUILD_SOURCE_DIR}/CMake/External_itk.cmake"
# "ITK_SB_VERSION"
# ITK_SB_VERSION)
macro(get_version input_file match_string check_cmake_var)
if(EXISTS "${input_file}")
file(STRINGS "${input_file}" _version_vars REGEX "set\\\(${match_string}")
set(temp_file_name "${CMAKE_BINARY_DIR}/CMakeFiles/version_vars_${match_string}.cmake")
file(WRITE "${temp_file_name}" "#version\n")
foreach(_version_var ${_version_vars})
file(APPEND "${temp_file_name}" "${_version_var}\n")
endforeach()
include("${temp_file_name}")
if(${check_cmake_var})
set(get_version_${check_cmake_var} "${${check_cmake_var}}")
else()
message(FATAL_ERROR "macro(get_version): Cannot find ${check_cmake_var}!")
endif()
else()
message(FATAL_ERROR "macro(get_version): File '${input_file}' does not exists")
endif()
endmacro()
#macro: get_version
#args :
# input_file - Input cmake file where the version variable is set via cmake set() command.
# Example: ${OTB_SUPERBUILD_SOURCE_DIR}/CMake/External_itk.cmake
#match_string - A match string to filter out required set() commands.
# Example: "ITK_SB_VERSION" will get all set(ITK_SB_VERSION_MAJOR)
# set(ITK_SB_VERSION_MINOR) set(ITK_SB_VERSION_PATCH)
# cmake_var_to_check - Name of variable that has the version string stored using set(..)
# command inside the input_file.
# Example: ITK_SB_VERSION. This is same as match_string but not always
# Sample usage:
# get_version(