Commit 0ffe49b5 authored by Rashad Kanavath's avatar Rashad Kanavath
Browse files

WIP: JIRA 976 OSX redistributable package

parent f3d531d6
......@@ -21,7 +21,7 @@ set(WINDOWS_SYSTEM_DLLS
wsock32.dll
winspool.drv)
SET(UNIX_SYSTEM_DLLS
set(LINUX_SYSTEM_DLLS
libm.so
libc.so
libstdc*
......@@ -41,18 +41,30 @@ SET(UNIX_SYSTEM_DLLS
libGL.so*
libGLU.so*
)
set(SYSTEM_DLLS "${UNIX_SYSTEM_DLLS}")
if(WIN32 OR CMAKE_CROSSCOMPILING)
set(SYSTEM_DLLS "${WINDOWS_SYSTEM_DLLS}")
set(APPLE_SYSTEM_DLLS
libSystem.*
libiconv*
)
if(UNIX)
if(APPLE)
set(SYSTEM_DLLS "${APPLE_SYSTEM_DLLS}")
else()
set(SYSTEM_DLLS "${LINUX_SYSTEM_DLLS}")
endif()
else(UNIX)
if(WIN32 OR CMAKE_CROSSCOMPILING)
set(SYSTEM_DLLS "${WINDOWS_SYSTEM_DLLS}")
endif()
endif()
## http://www.cmake.org/Wiki/CMakeMacroListOperations
macro(is_system_dll matched value)
set(${matched})
string(TOLOWER ${value} value_)
foreach (pattern ${SYSTEM_DLLS})
string(TOLOWER ${pattern} pattern_)
if(${value_} MATCHES ${pattern_})
if("${value_}" MATCHES "${pattern_}")
set(${matched} TRUE)
endif()
endforeach()
......@@ -249,9 +261,16 @@ macro(empty_package_staging_directory)
endmacro()
function(configure_package)
set(EXE_EXT "")
set(LIB_EXT "*so")
set(SCR_EXT ".sh")
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")
......@@ -288,7 +307,7 @@ function(configure_package)
list(APPEND PKG_PEFILES
"${CMAKE_INSTALL_PREFIX}/bin/${EXE_FILE}${EXE_EXT}")
endif()
if(DEFINED Monteverdi_SOURCE_DIR)
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}
......
macro(superbuild_package)
cmake_parse_arguments(PKG "" "STAGE_DIR;XDK" "SEARCHDIRS" ${ARGN} )
find_program(OBJDUMP_PROGRAM "objdump")
if(NOT EXISTS ${OBJDUMP_PROGRAM})
message(FATAL_ERROR "objdump executable not found. please check OBJDUMP_PROGRAM is set to correct cross compiled executable")
if(APPLE)
set(loader_program_names otool)
set(LOADER_PROGRAM_ARGS "-l")
else()
set(loader_program_names objdump)
set(LOADER_PROGRAM_ARGS "-p")
endif()
find_program(LOADER_PROGRAM "${loader_program_names}")
if(NOT EXISTS ${LOADER_PROGRAM})
message(FATAL_ERROR "${loader_program_names} not found. please check LOADER_PROGRAM variable is set correctly")
endif()
include(GetPrerequisites)
......@@ -32,7 +38,6 @@ macro(superbuild_package)
set(PKG_SO_FILES)
configure_package()
############# install client configure script ################
configure_file(${PACKAGE_SUPPORT_FILES_DIR}/pkgsetup.in
${CMAKE_BINARY_DIR}/pkgsetup @ONLY)
......@@ -59,9 +64,13 @@ macro(superbuild_package)
endmacro(superbuild_package)
function(process_deps infile)
if(APPLE)
if( "${infile}" MATCHES "@rpath")
string(REGEX REPLACE "@rpath." "" infile "${infile}")
endif()
endif()
get_filename_component(bn ${infile} NAME)
list_contains(contains "${bn}" "${alldlls}")
if(NOT contains)
......@@ -124,9 +133,25 @@ function(process_deps infile)
endif() #is_valid
endforeach()
endif(is_executable)
execute_process(COMMAND ${OBJDUMP_PROGRAM} "-p" "${SEARCHDIR}/${infile}" OUTPUT_VARIABLE dump_out)
string(REGEX MATCHALL "NEEDED\\ *[A-Za-z(0-9\\.0-9)+_\\-]*" needed_dlls "${dump_out}")
string(REGEX REPLACE "NEEDED" "" needed_dlls "${needed_dlls}")
execute_process(
COMMAND ${LOADER_PROGRAM} ${LOADER_PROGRAM_ARGS} "${SEARCHDIR}/${infile}"
RESULT_VARIABLE loader_rv
OUTPUT_VARIABLE loader_ov
ERROR_VARIABLE loader_ev
)
if(loader_rv)
message(FATAL_ERROR "loader_ev=${loader_ev}\n PACKAGE-OTB: result_variable is '${loader_rv}'")
endif()
if(APPLE)
string(REGEX REPLACE "[^\n]+cmd LC_LOAD_DYLIB\n[^\n]+\n[^\n]+name ([^\n]+).\\(offset[^\n]+\n" "rpath \\1\n" loader_ov "${loader_ov}")
string(REGEX MATCHALL "rpath [^\n]+" loader_ov "${loader_ov}")
string(REGEX REPLACE "rpath " "" needed_dlls "${loader_ov}")
else()
string(REGEX MATCHALL "NEEDED\\ *[A-Za-z(0-9\\.0-9)+_\\-]*" loader_ov "${loader_ov}")
string(REGEX REPLACE "NEEDED" "" needed_dlls "${loader_ov}")
endif()
foreach(needed_dll ${needed_dlls})
string(STRIP ${needed_dll} needed_dll)
process_deps(${needed_dll})
......@@ -135,11 +160,11 @@ function(process_deps infile)
endif(NOT DLL_FOUND)
endforeach()
if(NOT DLL_FOUND)
is_system_dll(iss "${infile}")
if(NOT iss)
set(notfound_dlls "${notfound_dlls};${infile}")
endif()
if(NOT DLL_FOUND)
is_system_dll(iss "${infile}")
if(NOT iss)
set(notfound_dlls "${notfound_dlls};${infile}")
endif()
else(NOT DLL_FOUND)
set( alldlls "${alldlls};${bn}" PARENT_SCOPE )
endif(NOT DLL_FOUND)
......
Supports Markdown
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