summaryrefslogtreecommitdiff
blob: f67e57f1b9c4b5011958e24270219964232dca4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Respect DFHACK_DATA_DESTINATION

From: eroen <dfhack@occam.eroen.eu>


---
 CMakeLists.txt         |    2 +-
 library/CMakeLists.txt |    3 +++
 library/Core.cpp       |   12 +++++++++---
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9a9a03ca..61a66815 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -197,7 +197,7 @@ ENDIF()
 # external tools will be installed here:
 SET(DFHACK_BINARY_DESTINATION .)
 # dfhack data goes here:
-SET(DFHACK_DATA_DESTINATION hack)
+SET(DFHACK_DATA_DESTINATION hack CACHE INTERNAL "")
 # plugin libs go here:
 SET(DFHACK_PLUGIN_DESTINATION hack/plugins)
 # dfhack header files go here:
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index d64b7429..124083b2 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -79,6 +79,9 @@ RemoteServer.cpp
 RemoteTools.cpp
 )
 
+set_property( SOURCE "Core.cpp" APPEND PROPERTY COMPILE_DEFINITIONS
+	"DFHACK_DATA_DESTINATION=\"${DFHACK_DATA_DESTINATION}\"" )
+
 SET(MAIN_SOURCES_WINDOWS
 Console-windows.cpp
 Hooks-windows.cpp
diff --git a/library/Core.cpp b/library/Core.cpp
index 15d4be72..296a5fa3 100644
--- a/library/Core.cpp
+++ b/library/Core.cpp
@@ -78,6 +78,7 @@ using namespace DFHack;
 #include <stdio.h>
 #include <iomanip>
 #include <stdlib.h>
+#include <string.h>
 #include <fstream>
 #include <thread>
 #include <mutex>
@@ -553,6 +554,7 @@ void Core::getScriptPaths(std::vector<std::string> *dest)
     }
     dest->push_back(df_path + "/raw/scripts");
     dest->push_back(df_path + "/hack/scripts");
+    dest->push_back(DFHACK_DATA_DESTINATION "/scripts");
     for (auto it = script_paths[1].begin(); it != script_paths[1].end(); ++it)
         dest->push_back(*it);
 }
@@ -1580,7 +1582,11 @@ void Core::fatal (std::string output)
 std::string Core::getHackPath()
 {
 #ifdef LINUX_BUILD
-    return p->getPath() + "/hack/";
+    if(strncmp(DFHACK_DATA_DESTINATION, "hack", 5) == 0)
+        // This is the default value
+        return p->getPath() + "/hack/";
+    else
+        return DFHACK_DATA_DESTINATION "/";
 #else
     return p->getPath() + "\\hack\\";
 #endif
@@ -1612,9 +1618,9 @@ bool Core::Init()
 
     // find out what we are...
     #ifdef LINUX_BUILD
-        const char * path = "hack/symbols.xml";
+        const char * path = DFHACK_DATA_DESTINATION "/symbols.xml";
     #else
-        const char * path = "hack\\symbols.xml";
+        const char * path = DFHACK_DATA_DESTINATION "\\symbols.xml";
     #endif
     auto local_vif = dts::make_unique<DFHack::VersionInfoFactory>();
     cerr << "Identifying DF version.\n";