PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/cmake/DeploySharedLibs.cmake

https://bitbucket.org/lindenlab/viewer-beta/
CMake | 73 lines | 53 code | 11 blank | 9 comment | 7 complexity | 0c31a31a7e4e2cf4969275f6b45d6202 MD5 | raw file
 1# DeploySharedLibs.cmake
 2# This is a script to be run at build time! Its not part of the cmake configuration!
 3# See indra/cmake/LLSharedLibs.cmake for a macro that simplifies adding a command to a target to run this script.
 4
 5# This  script requires a few cmake variable to be set on the command line:
 6# BIN_NAME= The full path the the binary to search for dependecies.
 7# SEARCH_DIRS= The full paths to dirs to search for dependencies.
 8# DST_PATH= The full path where the dependecies will be copied. 
 9
10# *FIX:Mani - I pulled in the CMake 2.8 GetPrerequisites.cmake script here, because it works on windows where 2.6 did not.
11# Once we have officially upgraded to 2.8 we can just use that version of GetPrerequisites.cmake.
12get_filename_component(current_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
13include(${current_dir}/GetPrerequisites_2_8.cmake)
14
15message("Getting recursive dependencies for file: ${BIN_NAME}")
16
17set(EXCLUDE_SYSTEM 1)
18set(RECURSE 1)
19get_filename_component(EXE_PATH ${BIN_NAME} PATH)
20
21get_prerequisites( ${BIN_NAME} RESULTS ${EXCLUDE_SYSTEM} ${RECURSE} "${EXE_PATH}" "${SEARCH_DIRS}" )
22
23foreach(DEP ${RESULTS})
24  Message("Processing dependency: ${DEP}")
25  get_filename_component(DEP_FILE ${DEP} NAME)
26  set(DEP_FILES ${DEP_FILES} ${DEP_FILE})
27endforeach(DEP)
28
29if(DEP_FILES)
30  list(REMOVE_DUPLICATES DEP_FILES)
31endif(DEP_FILES)
32
33foreach(DEP_FILE ${DEP_FILES})
34  if(FOUND_FILES)
35    list(FIND FOUND_FILES ${DEP_FILE} FOUND)
36  else(FOUND_FILES)
37    set(FOUND -1)
38  endif(FOUND_FILES)
39
40  if(FOUND EQUAL -1)
41    find_path(DEP_PATH ${DEP_FILE} PATHS ${SEARCH_DIRS} NO_DEFAULT_PATH)
42    if(DEP_PATH)
43      set(FOUND_FILES ${FOUND_FILES} "${DEP_PATH}/${DEP_FILE}")
44      set(DEP_PATH NOTFOUND) #reset DEP_PATH for the next find_path call.
45    else(DEP_PATH)
46      set(MISSING_FILES ${MISSING_FILES} ${DEP_FILE})
47    endif(DEP_PATH)
48  endif(FOUND EQUAL -1)
49endforeach(DEP_FILE)
50
51if(MISSING_FILES)
52  message("Missing:")
53  foreach(FILE ${MISSING_FILES})
54    message("  ${FILE}")
55  endforeach(FILE)
56  message("Searched in:")
57  foreach(SEARCH_DIR ${SEARCH_DIRS})
58    message("  ${SEARCH_DIR}")
59  endforeach(SEARCH_DIR)
60  message(FATAL_ERROR "Failed")
61endif(MISSING_FILES)
62
63if(FOUND_FILES)
64  foreach(FILE ${FOUND_FILES})
65    get_filename_component(DST_FILE ${FILE} NAME)
66    set(DST_FILE "${DST_PATH}/${DST_FILE}")
67    message("Copying ${FILE} to ${DST_FILE}")
68    execute_process(
69      COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE} ${DST_FILE}
70      )
71  endforeach(FILE ${FOUND_FILES})
72endif(FOUND_FILES)
73message("Success!")