summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-11-17 19:31:26 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-16 08:00:31 -0800
commit32714faf2450fc075cd78627ef65d3afc83ab13e (patch)
tree3b24d68498f442338764564251caa739d1b612da /cmake
parentc7a3cb68f5ebb3a40dbacb6b7860cbaa44a36fa3 (diff)
downloadsubsurface-32714faf2450fc075cd78627ef65d3afc83ab13e.tar.gz
Remove the Dll finding code from within the Main CMake
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/dlllist.cmake41
1 files changed, 41 insertions, 0 deletions
diff --git a/cmake/Modules/dlllist.cmake b/cmake/Modules/dlllist.cmake
new file mode 100644
index 000000000..0bf621a8a
--- /dev/null
+++ b/cmake/Modules/dlllist.cmake
@@ -0,0 +1,41 @@
+message(STATUS "processing dlllist.cmake")
+
+# figure out which command to use for objdump
+execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -dumpmachine
+ OUTPUT_VARIABLE OBJDUMP
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# figure out where we should search for libraries
+execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -print-search-dirs
+ COMMAND sed -nE "/^libraries: =/{s///;s,/lib/?\\\(:|\\\$\\\$\\\),/bin\\\\1,g;p;q;}"
+ OUTPUT_VARIABLE ADDPATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# since cmake doesn't appear to give us a variable with
+# all libraries we link against, grab the link.txt script
+# instead and drop the command name from it (before the
+# first space) -- this will fail if the full path for the
+# linker used contains a space...
+execute_process(
+ COMMAND tail -1 CMakeFiles/subsurface.dir/link.txt
+ COMMAND cut -d\\ -f 2-
+ OUTPUT_VARIABLE LINKER_LINE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# finally run our win-ldd.pl script against that to
+# collect all the required dlls
+execute_process(
+ COMMAND sh -c "OBJDUMP=${OBJDUMP}-objdump PATH=$ENV{PATH}:${ADDPATH} perl ${CMAKE_SOURCE_DIR}/scripts/win-ldd.pl ${SUBSURFACE_TARGET}.exe ${LINKER_LINE}"
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ OUTPUT_VARIABLE DLLS
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# replace newlines with semicolons so this is a cmake list
+string(REPLACE "\\n" ";" DLLLIST ${DLLS})
+# executing 'install' as a command seems hacky, but you
+# can't use the install() cmake function in a script
+foreach(DLL ${DLLLIST})
+ execute_process(COMMAND install ${DLL} ${STAGING})
+endforeach()