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