mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Remove the Dll finding code from within the Main CMake
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
This commit is contained in:
parent
c7a3cb68f5
commit
32714faf24
2 changed files with 42 additions and 46 deletions
|
@ -427,55 +427,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
set(MAKENSIS makensis)
|
set(MAKENSIS makensis)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# next figure out the DLLs we need to include in the installer
|
|
||||||
# since this needs to run at install time we create a new cmake
|
|
||||||
# script that then gets executed at install time with install(CODE...)
|
|
||||||
file(WRITE ${CMAKE_BINARY_DIR}/dlllist.cmake "
|
|
||||||
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()
|
|
||||||
")
|
|
||||||
# the script we created above is now added as a command to run at
|
# the script we created above is now added as a command to run at
|
||||||
# install time - so this ensures that subsurface.exe has been
|
# install time - so this ensures that subsurface.exe has been
|
||||||
# built before this is run
|
# built before this is run
|
||||||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DSTAGING=${WINDOWSSTAGING} -P ${CMAKE_BINARY_DIR}/dlllist.cmake)")
|
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DSTAGING=${WINDOWSSTAGING} -P cmake/Modules/dlllist.cmake)")
|
||||||
|
|
||||||
# create the subsurface-x.y.z.exe installer - this needs to depend
|
# create the subsurface-x.y.z.exe installer - this needs to depend
|
||||||
# on the install target but cmake doesn't allow that, so we depend
|
# on the install target but cmake doesn't allow that, so we depend
|
||||||
|
|
41
cmake/Modules/dlllist.cmake
Normal file
41
cmake/Modules/dlllist.cmake
Normal file
|
@ -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()
|
Loading…
Add table
Reference in a new issue