LLSharedLibs.cmake
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:3k
源码类别:

游戏引擎

开发平台:

C++ Builder

  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.   
  7.   if(DARWIN)
  8.     set(SEARCH_DIRS "${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/Resources")
  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(SEARCH_DIRS "${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}" "$ENV{SystemRoot}/system32")
  19.   elseif(LINUX)
  20.     set(SEARCH_DIRS "${SHARED_LIB_STAGING_DIR}")
  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.   if(SHARED_LIB_STAGING_DIR)
  38.     # target gets written to the DLL staging directory.
  39.     # Also this directory is shared with RunBuildTest.cmake, y'know, for the tests.
  40.     set_target_properties(${DSO_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${SHARED_LIB_STAGING_DIR})
  41.     if(NOT WINDOWS)
  42.       get_target_property(DSO_PATH ${DSO_TARGET} LOCATION)
  43.       get_filename_component(DSO_FILE ${DSO_PATH} NAME)
  44.       if(DARWIN)
  45.         set(SHARED_LIB_STAGING_DIR_CONFIG ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR}/Resources)
  46.       else(DARWIN)
  47.         set(SHARED_LIB_STAGING_DIR_CONFIG ${SHARED_LIB_STAGING_DIR}/${CMAKE_CFG_INTDIR})
  48.       endif(DARWIN)
  49.       # *TODO - maybe make this a symbolic link? -brad
  50.       add_custom_command(
  51.         TARGET ${DSO_TARGET} POST_BUILD
  52.         COMMAND ${CMAKE_COMMAND}
  53.         ARGS
  54.           -E
  55.           copy_if_different
  56.           ${DSO_PATH}
  57.           ${SHARED_LIB_STAGING_DIR_CONFIG}/${DSO_FILE}
  58.           COMMENT "Copying llcommon to the staging folder."
  59.         )
  60.     endif(NOT WINDOWS)
  61.   endif(SHARED_LIB_STAGING_DIR)
  62.   if (DARWIN)
  63.     set_target_properties(${DSO_TARGET} PROPERTIES
  64.       BUILD_WITH_INSTALL_RPATH 1
  65.       INSTALL_NAME_DIR "@executable_path/../Resources"
  66.       )
  67.   endif(DARWIN)
  68. endmacro(ll_stage_sharedlib)