From cf0c0e182441e442db78ded1a7139818502ae066 Mon Sep 17 00:00:00 2001
From: palange <palange@lindenlab.com>
Date: Mon, 2 Nov 2009 12:12:32 -0800
Subject: Added build time script to help deploy shared libs for an arbitrary
 executable. indra/cmake/DeploySharedLibs.cmake is the script.
 LLSharedLibs.cmake contains a macro to ease adding DeployShaerdLibs to a
 targets build. Example usage to the mac-crash-reporter. Multiplatform and
 more to come soon. Reviewed by brad.

---
 indra/cmake/DeploySharedLibs.cmake | 67 ++++++++++++++++++++++++++++++++++++++
 indra/cmake/LLSharedLibs.cmake     | 31 ++++++++++++++++++
 2 files changed, 98 insertions(+)
 create mode 100644 indra/cmake/DeploySharedLibs.cmake
 create mode 100644 indra/cmake/LLSharedLibs.cmake

(limited to 'indra/cmake')

diff --git a/indra/cmake/DeploySharedLibs.cmake b/indra/cmake/DeploySharedLibs.cmake
new file mode 100644
index 0000000000..a7e772bd75
--- /dev/null
+++ b/indra/cmake/DeploySharedLibs.cmake
@@ -0,0 +1,67 @@
+# DeploySharedLibs.cmake
+# This is a script to be run at build time! Its not part of the cmake configuration!
+# See indra/cmake/LLSharedLibs.cmake for a macro that simplifies adding a command to a target to run this script.
+
+# This  script requires a few cmake variable to be set on the command line:
+# BIN_NAME= The full path the the binary to search for dependecies.
+# SEARCH_DIRS= The full paths to dirs to search for dependencies.
+# DST_PATH= The full path where the dependecies will be copied. 
+include(GetPrerequisites)
+message("Getting recursive dependencies for file: ${BIN_NAME}")
+set(EXCLUDE_SYSTEM 1)
+set(RECURSE 1)
+get_filename_component(EXE_PATH ${BIN_NAME} PATH)
+
+get_prerequisites( ${BIN_NAME} RESULTS ${EXCLUDE_SYSTEM} ${RECURSE} "${EXE_PATH}" "${SEARCH_DIRS}" )
+
+foreach(DEP ${RESULTS})
+  Message("Processing dependency: ${DEP}")
+  get_filename_component(DEP_FILE ${DEP} NAME)
+  set(DEP_FILES ${DEP_FILES} ${DEP_FILE})
+endforeach(DEP)
+
+if(DEP_FILES)
+  list(REMOVE_DUPLICATES DEP_FILES)
+endif(DEP_FILES)
+
+foreach(DEP_FILE ${DEP_FILES})
+  if(FOUND_FILES)
+	list(FIND FOUND_FILES ${DEP_FILE} FOUND)
+  else(FOUND_FILES)
+	set(FOUND -1)
+  endif(FOUND_FILES)
+
+  if(FOUND EQUAL -1)
+	find_path(DEP_PATH ${DEP_FILE} PATHS ${SEARCH_DIRS} NO_DEFAULT_PATH)
+	if(DEP_PATH)
+	  set(FOUND_FILES ${FOUND_FILES} "${DEP_PATH}/${DEP_FILE}")
+	  set(DEP_PATH NOTFOUND) #reset DEP_PATH for the next find_path call.
+	else(DEP_PATH)
+	  set(MISSING_FILES ${MISSING_FILES} ${DEP_FILE})
+	endif(DEP_PATH)
+  endif(FOUND EQUAL -1)
+endforeach(DEP_FILE)
+
+if(MISSING_FILES)
+  message("Missing:")
+  foreach(FILE ${MISSING_FILES})
+	message("  ${FILE}")
+  endforeach(FILE)
+  message("Searched in:")
+  foreach(SEARCH_DIR ${SEARCH_DIRS})
+	message("  ${SEARCH_DIR}")
+  endforeach(SEARCH_DIR)
+  message(FATAL_ERROR "Failed")
+endif(MISSING_FILES)
+
+if(FOUND_FILES)
+  foreach(FILE ${FOUND_FILES})
+	get_filename_component(DST_FILE ${FILE} NAME)
+	set(DST_FILE "${DST_PATH}/${DST_FILE}")
+	message("Copying ${FILE} to ${DST_FILE}")
+	execute_process(
+	  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE} ${DST_FILE}
+	  )
+  endforeach(FILE ${FOUND_FILES})
+endif(FOUND_FILES)
+message("Success!")
diff --git a/indra/cmake/LLSharedLibs.cmake b/indra/cmake/LLSharedLibs.cmake
new file mode 100644
index 0000000000..3be22ab401
--- /dev/null
+++ b/indra/cmake/LLSharedLibs.cmake
@@ -0,0 +1,31 @@
+# ll_deploy_sharedlibs_command
+# target_exe: the cmake target of the executable for which the shared libs will be deployed.
+# search_dirs: a list of dirs to search for the dependencies
+# dst_path: path to copy deps to, relative to the output location of the target_exe
+macro(ll_deploy_sharedlibs_command target_exe search_dirs dst_path) 
+	get_target_property(OUTPUT_LOCATION ${target_exe} LOCATION)
+
+	if(DARWIN)
+	  get_target_property(IS_BUNDLE ${target_exe} MACOSX_BUNDLE)
+	  if(IS_BUNDLE)
+		get_filename_component(TARGET_FILE ${OUTPUT_LOCATION} NAME)
+		set(OUTPUT_PATH ${OUTPUT_LOCATION}.app/Contents/MacOS)
+		set(OUTPUT_LOCATION ${OUTPUT_PATH}/${TARGET_FILE})
+	  endif(IS_BUNDLE)
+	else(APPLE)
+	  message(FATAL_ERROR "Only darwin currently supported!")
+	endif(DARWIN)
+
+	add_custom_command(
+	  TARGET ${target_exe} POST_BUILD
+	  COMMAND ${CMAKE_COMMAND} 
+	  ARGS
+        "-DBIN_NAME=\"${OUTPUT_LOCATION}\""
+		"-DSEARCH_DIRS=\"${search_dirs}\""
+		"-DDST_PATH=\"${OUTPUT_PATH}/${dst_path}\""
+		"-P"
+		"${CMAKE_SOURCE_DIR}/cmake/DeploySharedLibs.cmake"
+	  )
+
+endmacro(ll_deploy_sharedlibs_command)
+
-- 
cgit v1.2.3


From 2a79326ff63d26f6f7d51ae195dfc7ab4600b407 Mon Sep 17 00:00:00 2001
From: "Mark Palange (Mani)" <palange@lindenlab.com>
Date: Mon, 2 Nov 2009 14:23:40 -0800
Subject: Removed tabs. Fixed errant 'else(APPLE)'

---
 indra/cmake/LLSharedLibs.cmake | 44 +++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

(limited to 'indra/cmake')

diff --git a/indra/cmake/LLSharedLibs.cmake b/indra/cmake/LLSharedLibs.cmake
index 3be22ab401..a8c81609bb 100644
--- a/indra/cmake/LLSharedLibs.cmake
+++ b/indra/cmake/LLSharedLibs.cmake
@@ -3,29 +3,29 @@
 # search_dirs: a list of dirs to search for the dependencies
 # dst_path: path to copy deps to, relative to the output location of the target_exe
 macro(ll_deploy_sharedlibs_command target_exe search_dirs dst_path) 
-	get_target_property(OUTPUT_LOCATION ${target_exe} LOCATION)
+  get_target_property(OUTPUT_LOCATION ${target_exe} LOCATION)
 
-	if(DARWIN)
-	  get_target_property(IS_BUNDLE ${target_exe} MACOSX_BUNDLE)
-	  if(IS_BUNDLE)
-		get_filename_component(TARGET_FILE ${OUTPUT_LOCATION} NAME)
-		set(OUTPUT_PATH ${OUTPUT_LOCATION}.app/Contents/MacOS)
-		set(OUTPUT_LOCATION ${OUTPUT_PATH}/${TARGET_FILE})
-	  endif(IS_BUNDLE)
-	else(APPLE)
-	  message(FATAL_ERROR "Only darwin currently supported!")
-	endif(DARWIN)
-
-	add_custom_command(
-	  TARGET ${target_exe} POST_BUILD
-	  COMMAND ${CMAKE_COMMAND} 
-	  ARGS
-        "-DBIN_NAME=\"${OUTPUT_LOCATION}\""
-		"-DSEARCH_DIRS=\"${search_dirs}\""
-		"-DDST_PATH=\"${OUTPUT_PATH}/${dst_path}\""
-		"-P"
-		"${CMAKE_SOURCE_DIR}/cmake/DeploySharedLibs.cmake"
-	  )
+  if(DARWIN)
+    get_target_property(IS_BUNDLE ${target_exe} MACOSX_BUNDLE)
+    if(IS_BUNDLE)
+      get_filename_component(TARGET_FILE ${OUTPUT_LOCATION} NAME)
+      set(OUTPUT_PATH ${OUTPUT_LOCATION}.app/Contents/MacOS)
+      set(OUTPUT_LOCATION ${OUTPUT_PATH}/${TARGET_FILE})
+    endif(IS_BUNDLE)
+  else(DARWIN)
+    message(FATAL_ERROR "Only darwin currently supported!")
+  endif(DARWIN)
+  
+  add_custom_command(
+    TARGET ${target_exe} POST_BUILD
+    COMMAND ${CMAKE_COMMAND} 
+    ARGS
+    "-DBIN_NAME=\"${OUTPUT_LOCATION}\""
+    "-DSEARCH_DIRS=\"${search_dirs}\""
+    "-DDST_PATH=\"${OUTPUT_PATH}/${dst_path}\""
+    "-P"
+    "${CMAKE_SOURCE_DIR}/cmake/DeploySharedLibs.cmake"
+    )
 
 endmacro(ll_deploy_sharedlibs_command)
 
-- 
cgit v1.2.3