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

/indra/cmake/LLSharedLibs.cmake

https://bitbucket.org/lindenlab/viewer-beta/
CMake | 73 lines | 58 code | 7 blank | 8 comment | 5 complexity | b16ef863b66816f3ece372dcbac225ae MD5 | raw file
 1# ll_deploy_sharedlibs_command
 2# target_exe: the cmake target of the executable for which the shared libs will be deployed.
 3macro(ll_deploy_sharedlibs_command target_exe) 
 4  get_target_property(TARGET_LOCATION ${target_exe} LOCATION)
 5  get_filename_component(OUTPUT_PATH ${TARGET_LOCATION} PATH)
 6  
 7  if(DARWIN)
 8    SET_TEST_PATH(SEARCH_DIRS)
 9    get_target_property(IS_BUNDLE ${target_exe} MACOSX_BUNDLE)
10    if(IS_BUNDLE)
11      # If its a bundle the exe is not in the target location, this should find it.
12      get_filename_component(TARGET_FILE ${TARGET_LOCATION} NAME)
13      set(OUTPUT_PATH ${TARGET_LOCATION}.app/Contents/MacOS)
14      set(TARGET_LOCATION ${OUTPUT_PATH}/${TARGET_FILE})
15      set(OUTPUT_PATH ${OUTPUT_PATH}/../Resources)
16    endif(IS_BUNDLE)
17  elseif(WINDOWS)
18    SET_TEST_PATH(SEARCH_DIRS)
19    LIST(APPEND SEARCH_DIRS "$ENV{SystemRoot}/system32")
20  elseif(LINUX)
21    SET_TEST_PATH(SEARCH_DIRS)
22    set(OUTPUT_PATH ${OUTPUT_PATH}/lib)
23  endif(DARWIN)
24
25  add_custom_command(
26    TARGET ${target_exe} POST_BUILD
27    COMMAND ${CMAKE_COMMAND} 
28    ARGS
29    "-DBIN_NAME=\"${TARGET_LOCATION}\""
30    "-DSEARCH_DIRS=\"${SEARCH_DIRS}\""
31    "-DDST_PATH=\"${OUTPUT_PATH}\""
32    "-P"
33    "${CMAKE_SOURCE_DIR}/cmake/DeploySharedLibs.cmake"
34    )
35
36endmacro(ll_deploy_sharedlibs_command)
37
38# ll_stage_sharedlib
39# Performs config and adds a copy command for a sharedlib target.
40macro(ll_stage_sharedlib DSO_TARGET)
41  # target gets written to the DLL staging directory.
42  # Also this directory is shared with RunBuildTest.cmake, y'know, for the tests.
43  set_target_properties(${DSO_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SHARED_LIB_STAGING_DIR})
44  if(NOT WINDOWS)
45    get_target_property(DSO_PATH ${DSO_TARGET} LOCATION)
46    get_filename_component(DSO_FILE ${DSO_PATH} NAME)
47    if(DARWIN)
48      set(SHARED_LIB_STAGING_DIR_CONFIG ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/Resources)
49    else(DARWIN)
50      set(SHARED_LIB_STAGING_DIR_CONFIG ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR})
51    endif(DARWIN)
52
53      # *TODO - maybe make this a symbolic link? -brad
54      add_custom_command(
55        TARGET ${DSO_TARGET} POST_BUILD
56        COMMAND ${CMAKE_COMMAND}
57        ARGS
58          -E
59          copy_if_different
60          ${DSO_PATH}
61          ${SHARED_LIB_STAGING_DIR_CONFIG}/${DSO_FILE}
62          COMMENT "Copying llcommon to the staging folder."
63        )
64    endif(NOT WINDOWS)
65
66  if (DARWIN)
67    set_target_properties(${DSO_TARGET} PROPERTIES
68      BUILD_WITH_INSTALL_RPATH 1
69      INSTALL_NAME_DIR "@executable_path/../Resources"
70      )
71  endif(DARWIN)
72
73endmacro(ll_stage_sharedlib)