aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/CMakeLists.txt7
-rw-r--r--wsutil/filesystem.c15
2 files changed, 20 insertions, 2 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt
index 8b9cf011d8..84a3e1465e 100644
--- a/wsutil/CMakeLists.txt
+++ b/wsutil/CMakeLists.txt
@@ -249,7 +249,12 @@ if(NOT ${ENABLE_STATIC})
)
endif()
-add_definitions( -DTOP_SRCDIR=\"${CMAKE_SOURCE_DIR}\" )
+# Export build-time datadir (note: the macro "DATAFILE_DIR" is defined in
+# config.h and points to the install-time data directory, hence the different
+# name).
+set_property(SOURCE filesystem.c APPEND PROPERTY
+ COMPILE_DEFINITIONS BUILD_TIME_DATAFILE_DIR="${DATAFILE_DIR}"
+)
CHECKAPI(
NAME
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index a7b2329f90..4fffcd4016 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -886,7 +886,20 @@ get_datafile_dir(void)
* Use the top-level source directory as the datafile directory
* because most of our data files (radius/, COPYING) are there.
*/
- datafile_dir = g_strdup(TOP_SRCDIR);
+#ifdef TOP_SRCDIR
+ /*
+ * When TOP_SRCDIR is defined, assume autotools where files are not
+ * copied to the build directory. This fallback location is relied on by
+ * wslua_get_actual_filename().
+ */
+ datafile_dir = TOP_SRCDIR;
+#else
+ /*
+ * Otherwise assume CMake. Here, data files (console.lua, radius/, etc.)
+ * are copied to the build directory during the build.
+ */
+ datafile_dir = BUILD_TIME_DATAFILE_DIR;
+#endif
return datafile_dir;
} else {
if (g_getenv("WIRESHARK_DATA_DIR") && !started_with_special_privs()) {