|
| 1 | +# Customized install script for fftw test program; analyzes all the shared library dependencies and installs |
| 2 | +# the dependencies into the package |
| 3 | +include( GetPrerequisites ) |
| 4 | + |
| 5 | +# message( testLocation ": @testLocation@" ) |
| 6 | + |
| 7 | +# The Microsoft IDE presents a challenge because the full configuration is not known at cmake time |
| 8 | +# This logic allows us to 'substitute' the proper confguration at install time |
| 9 | +if( "${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "Debug" ) |
| 10 | + string( REPLACE "\$(Configuration)" "Debug" fixedTestLocation "@testLocation@" ) |
| 11 | +elseif( "${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "Release" ) |
| 12 | + string( REPLACE "\$(Configuration)" "Release" fixedTestLocation "@testLocation@" ) |
| 13 | +elseif( "${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "MinSizeRel" ) |
| 14 | + string( REPLACE "\$(Configuration)" "MinSizeRel" fixedTestLocation "@testLocation@" ) |
| 15 | +elseif( "${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "RelwithDebInfo" ) |
| 16 | + string( REPLACE "\$(Configuration)" "RelwithDebInfo" fixedTestLocation "@testLocation@" ) |
| 17 | +endif( ) |
| 18 | + |
| 19 | +# message( fixedTestLocation ": ${fixedTestLocation}" ) |
| 20 | +# Get the directory that the test executable resides in; this helps get_prerequisites( ) find dependent libraries |
| 21 | +get_filename_component( testName "${fixedTestLocation}" NAME ) |
| 22 | +string( REPLACE ${testName} "" testDir ${fixedTestLocation} ) |
| 23 | +string( REGEX REPLACE "/+$" "" testDir ${testDir} ) |
| 24 | +# message( testDir ": ${testDir}" ) |
| 25 | + |
| 26 | +set( installPath "" ) |
| 27 | +if( WIN32 ) |
| 28 | + set( installPath "${CMAKE_INSTALL_PREFIX}/bin@SUFFIX_BIN@" ) |
| 29 | +else( ) |
| 30 | + set( installPath "${CMAKE_INSTALL_PREFIX}/lib@SUFFIX_LIB@" ) |
| 31 | +endif( ) |
| 32 | + |
| 33 | +# Only search for dependencies that have ROOT defined |
| 34 | +set( depList "" ) |
| 35 | + |
| 36 | +if( EXISTS "@FFTW_ROOT@" ) |
| 37 | + list( APPEND depList "@FFTW_ROOT@/lib@SUFFIX_LIB@" ) |
| 38 | +endif( ) |
| 39 | + |
| 40 | +if( EXISTS "@GTEST_ROOT@" ) |
| 41 | + list( APPEND depList "@GTEST_ROOT@/lib@SUFFIX_LIB@" ) |
| 42 | +endif( ) |
| 43 | + |
| 44 | +if( EXISTS "${testDir}" ) |
| 45 | + list( APPEND depList "${testDir}" ) |
| 46 | +endif( ) |
| 47 | + |
| 48 | +# message( STATUS "depList: ${depList}" ) |
| 49 | + |
| 50 | +# This retrieves a list of shared library dependencies from the target; they are not full path names |
| 51 | +# Skip system dependencies and skip recursion |
| 52 | +get_prerequisites( ${fixedTestLocation} testDependencies 1 0 "" "${depList}" ) |
| 53 | + |
| 54 | +# Loop on queried library dependencies and copy them into package |
| 55 | +foreach( dep ${testDependencies} ) |
| 56 | + # This converts the dependency into a full path |
| 57 | + gp_resolve_item( "${fixedTestLocation}" "${dep}" "" "${depList}" dep_test_path ) |
| 58 | + |
| 59 | + # In linux, the dep_test_path may point to a symbolic link, we also need to copy real file |
| 60 | + get_filename_component( dep_realpath "${dep_test_path}" REALPATH ) |
| 61 | + get_filename_component( dep_name "${dep_test_path}" NAME ) |
| 62 | + # message( STATUS "depName: ${dep_name}" ) |
| 63 | + # message( STATUS "depFullPath: ${dep_test_path}" ) |
| 64 | + # message( STATUS "dep_realpath: ${dep_realpath}" ) |
| 65 | + |
| 66 | + if( NOT EXISTS ${installPath}/${dep_name} ) |
| 67 | + file( INSTALL ${dep_test_path} ${dep_realpath} |
| 68 | + USE_SOURCE_PERMISSIONS |
| 69 | + DESTINATION ${installPath} |
| 70 | + ) |
| 71 | + endif( ) |
| 72 | +endforeach( ) |
0 commit comments