summaryrefslogtreecommitdiff
path: root/external/clBLAS/src/tests/copyTestDependencies.cmake.in
blob: 7e47fc7f92cf04fa20689b24ad6096c97586036d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Customized install script for fftw test program; analyzes all the shared library dependencies and installs
# the dependencies into the package
include( GetPrerequisites )

#    message( testLocation ": @testLocation@" )

# The Microsoft IDE presents a challenge because the full configuration is not known at cmake time
# This logic allows us to 'substitute' the proper confguration at install time
if( "${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "Debug" )
    string( REPLACE "\$(Configuration)" "Debug" fixedTestLocation "@testLocation@" )
elseif( "${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "Release" )
    string( REPLACE "\$(Configuration)" "Release" fixedTestLocation "@testLocation@" )
elseif( "${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "MinSizeRel" )
    string( REPLACE "\$(Configuration)" "MinSizeRel" fixedTestLocation "@testLocation@" )
elseif( "${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "RelwithDebInfo" )
    string( REPLACE "\$(Configuration)" "RelwithDebInfo" fixedTestLocation "@testLocation@" )
endif( )

#    message( fixedTestLocation ": ${fixedTestLocation}" )
# Get the directory that the test executable resides in; this helps get_prerequisites( ) find dependent libraries
get_filename_component( testDir "${fixedTestLocation}" PATH )
#    message( testDir ": ${testDir}" )

set( installPath "" )
if( WIN32 )
    set( installPath "${CMAKE_INSTALL_PREFIX}/bin@SUFFIX_BIN@" )
else( )
    set( installPath "${CMAKE_INSTALL_PREFIX}/lib@SUFFIX_LIB@" )
endif( )

# Only search for dependencies that have ROOT defined
set( depList "" )

#This logic assumes that clBLAS CMakeLists.txt has been called
get_filename_component( acmlDir "@ACML_LIBRARIES@" PATH )

if( EXISTS "${acmlDir}" )
    list( APPEND depList "${acmlDir}" )
#    message( "acmlDir: ${acmlDir}" )
endif( )

#This logic assumes that FindGTest.cmake has been called
get_filename_component( gtestDir "@GTEST_LIBRARY@" PATH )
get_filename_component( gtestDirDebug "@GTEST_LIBRARY_DEBUG@" PATH )

if( EXISTS "${gtestDir}" )
    list( APPEND depList "${gtestDir}" )
#    message( "gtestDir: ${gtestDir}" )
endif( )

string( COMPARE NOTEQUAL "${gtestDir}" "${gtestDirDebug}" gtestDiffDirs )
if( ${gtestDiffDirs} AND EXISTS "${gtestDirDebug}" )
    list( APPEND depList "${gtestDirDebug}" )
#    message( "gtestDirDebug: ${gtestDirDebug}" )
endif( )

#This logic assumes that FindOpenCL.cmake has been called
get_filename_component( openclDir "@OPENCL_LIBRARIES@" PATH )

if( EXISTS "${openclDir}" )
    if( WIN32 )
        # On Windows, we need to substitute the lib/ directory for the bin/ directory; the former holds the .lib and the latter holds the .dll
        STRING( REGEX REPLACE "/lib/" "/bin/" openclDir ${openclDir} )
    endif( )

    list( APPEND depList "${openclDir}" )
#    message( "openclDir: ${openclDir}" )
endif( )
 
if( EXISTS "${testDir}" )
    list( APPEND depList "${testDir}" )
    # On linux, the .so files are not staged with the rest of the executables
    if( UNIX )
       list( APPEND depList "${testDir}/../library" )
    endif( )
endif( )

# message( "depList: ${depList}" )

# This retrieves a list of shared library dependencies from the target; they are not full path names
# Skip system dependencies and skip recursion
get_prerequisites( ${fixedTestLocation} testDependencies 1 0 "" "${depList}" )

# Loop on queried library dependencies and copy them into package
foreach( dep ${testDependencies} )
    # This converts the dependency into a full path
    gp_resolve_item( "${fixedTestLocation}" "${dep}" "" "${depList}" dep_test_path )

    # In linux, the dep_test_path may point to a symbolic link, we also need to copy real file
    get_filename_component( dep_realpath "${dep_test_path}" REALPATH )
    get_filename_component( dep_name "${dep_test_path}" NAME )
    # message( STATUS "depName: ${dep_name}" )
    # message( STATUS "depFullPath: ${dep_test_path}" )
    # message( STATUS "dep_realpath: ${dep_realpath}" )

    if( NOT EXISTS ${installPath}/${dep_name} )
        file( INSTALL ${dep_test_path} ${dep_realpath}
              USE_SOURCE_PERMISSIONS
              DESTINATION ${installPath}
            )
    endif( )
endforeach( )