CMake linux: copy LD_PRELOAD script

Copy package/linux/dfhack to the games directory; it's the same as the
normal df script, but sets LD_PRELOAD properly.

Also, CMAkeLists.txt now checks to see that the output directory is set
to the game directory, and fatally fails if it isn't.
develop
Matthew Cline 2011-07-12 17:25:27 -07:00
parent b5a6087da5
commit a30a4a2720
3 changed files with 30 additions and 0 deletions

@ -28,6 +28,14 @@ ENDIF()
SET(DFHACK_OUTPUT_DIR "${dfhack_BINARY_DIR}/bin" CACHE STRING "Where should be the produced libraries and binaries stored.")
SET(DFHACK_PLUGIN_OUTPUT_DIR "${DFHACK_OUTPUT_DIR}/plugins")
IF(UNIX)
# Make sure output directory is properly set
IF (NOT EXISTS "${DFHACK_OUTPUT_DIR}/df" OR
NOT EXISTS "${DFHACK_OUTPUT_DIR}/libs/Dwarf_Fortress")
message(FATAL_ERROR "DFHACK_OUTPUT_DIR must be directory containg game")
ENDIF()
ENDIF()
## where to put things during the build (force MSVC to behave)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${DFHACK_OUTPUT_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${DFHACK_OUTPUT_DIR})

@ -144,6 +144,15 @@ COMMAND ${CMAKE_COMMAND} -E make_directory ${DFHACK_PLUGIN_OUTPUT_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${dfhack_SOURCE_DIR}/Memory.xml ${DFHACK_OUTPUT_DIR})
ADD_DEPENDENCIES(dfhack prepare)
# Copy our version of the df launch script which sets LD_PRELOAD
IF(UNIX)
ADD_CUSTOM_TARGET( prepare_UNIX
DEPENDS ${dfhack_SOURCE_DIR}/package/linux/dfhack
COMMAND ${CMAKE_COMMAND} -E make_directory ${DFHACK_OUTPUT_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${dfhack_SOURCE_DIR}/package/linux/dfhack ${DFHACK_OUTPUT_DIR})
ADD_DEPENDENCIES(dfhack prepare_UNIX)
ENDIF()
install(TARGETS dfhack
LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION}) #linux: lib

@ -0,0 +1,13 @@
#!/bin/sh
# NOTE: This is dfhack's modification of the normal invocation script,
# changed to properly set LD_PRELOAD so as to run DFHACK.
DF_DIR=$(dirname "$0")
cd "${DF_DIR}"
export SDL_DISABLE_LOCK_KEYS=1 # Work around for bug in Debian/Ubuntu SDL patch.
#export SDL_VIDEO_CENTERED=1 # Centre the screen. Messes up resizing.
export LD_PRELOAD=./libdfhack.so
./libs/Dwarf_Fortress $* # Go, go, go! :)