summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt8
-rw-r--r--library/CMakeLists.txt9
-rwxr-xr-xpackage/linux/dfhack13
3 files changed, 30 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93db2e81..b2484924 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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})
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index 4586ef6a..25e4bb2a 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -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
diff --git a/package/linux/dfhack b/package/linux/dfhack
new file mode 100755
index 00000000..8484a3e5
--- /dev/null
+++ b/package/linux/dfhack
@@ -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! :)