From a8a40dee19e37c5390279728f49336e2d3654e6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kamil=20Krzy=C5=BCanowski?= <kamnxt@kamnxt.com>
Date: Wed, 14 Jan 2015 20:38:40 +0000
Subject: Use a variable for the data directory instead of hardcoded share


diff --git a/CMakeLists.txt b/CMakeLists.txt
index d28e8ab..6ec9512 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,6 +98,9 @@ SET(PLUGIN_PERMISSIONS WORLD_EXECUTE GROUP_EXECUTE OWNER_EXECUTE WORLD_READ GROU
 #Our main directory is scribus
 SET(MAIN_DIR_NAME "scribus")
 
+#Set the directory to use for data (share on Linux)
+SET(DATA_DIR CACHE STRING "share")
+
 ##############################################################################################################
 ########## check for the CPU we build for                                                           ##########
 
@@ -274,25 +277,25 @@ ENDIF (APPLEBUNDLE)
 #Setp all the directories we will use
 #MAN
 CMAKE_POLICY(SET CMP0005 OLD)
-SET(MANDIR "share/man/")
+SET(MANDIR "${DATA_DIR}/man/")
 IF(WANT_VERSIONING)
-    SET(SHAREDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/")
+    SET(SHAREDIR "${DATA_DIR}/${MAIN_DIR_NAME}${TAG_VERSION}/")
 ELSE(WANT_VERSIONING)
-    SET(SHAREDIR "share/${MAIN_DIR_NAME}/")
+    SET(SHAREDIR "${DATA_DIR}/${MAIN_DIR_NAME}/")
 ENDIF(WANT_VERSIONING)
 ADD_DEFINITIONS("-DSHAREDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SHAREDIR}\\\"")
 
 #SHARE - use the default on Apple as TAG_VERSION is empty
 IF(WIN32 OR OS2)
-  SET(DOCDIR "share/doc/")
+  SET(DOCDIR "${DATA_DIR}/doc/")
 ELSE (WIN32 OR OS2)
   IF(TAG_VERSION OR BUILD_OSX_BUNDLE)
-    SET(DOCDIR "share/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
+    SET(DOCDIR "${DATA_DIR}/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
   ELSE(TAG_VERSION OR BUILD_OSX_BUNDLE)
         IF(NOT WANT_VERSIONING)
-            SET(DOCDIR "share/doc/${MAIN_DIR_NAME}/")
+            SET(DOCDIR "${DATA_DIR}/doc/${MAIN_DIR_NAME}/")
         ELSE(NOT WANT_VERSIONING)
-            SET(DOCDIR "share/doc/${MAIN_DIR_NAME}-${VERSION}/")
+            SET(DOCDIR "${DATA_DIR}/doc/${MAIN_DIR_NAME}-${VERSION}/")
         ENDIF(NOT WANT_VERSIONING)
   ENDIF (TAG_VERSION OR BUILD_OSX_BUNDLE)
 ENDIF (WIN32 OR OS2)
@@ -300,30 +303,30 @@ ADD_DEFINITIONS("-DDOCDIR=\\\"${CMAKE_INSTALL_PREFIX}/${DOCDIR}\\\"")
 
 #ICON
 IF(WIN32)
-  SET(ICONDIR "share/icons/")
+  SET(ICONDIR "${DATA_DIR}/icons/")
 ELSE(WIN32)
-  SET(ICONDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/icons/")
+  SET(ICONDIR "${DATA_DIR}/${MAIN_DIR_NAME}${TAG_VERSION}/icons/")
 ENDIF(WIN32)
 ADD_DEFINITIONS("-DICONDIR=\\\"${CMAKE_INSTALL_PREFIX}/${ICONDIR}\\\"")
 
 #SAMPLES
-SET(SAMPLESDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
+SET(SAMPLESDIR "${DATA_DIR}/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
 ADD_DEFINITIONS("-DSAMPLESDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SAMPLESDIR}\\\"")
 
 #SCRIPTS
-SET(SCRIPTSDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
+SET(SCRIPTSDIR "${DATA_DIR}/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
 ADD_DEFINITIONS("-DSCRIPTSDIR=\\\"${CMAKE_INSTALL_PREFIX}/${SCRIPTSDIR}\\\"")
 
 #TEMPLATES
 IF(WIN32)
-  SET(TEMPLATEDIR "share/templates/")
+  SET(TEMPLATEDIR "${DATA_DIR}/templates/")
 ELSE(WIN32)
-  SET(TEMPLATEDIR "share/${MAIN_DIR_NAME}${TAG_VERSION}/templates/")
+  SET(TEMPLATEDIR "${DATA_DIR}/${MAIN_DIR_NAME}${TAG_VERSION}/templates/")
 ENDIF(WIN32)
 ADD_DEFINITIONS("-DTEMPLATEDIR=\\\"${CMAKE_INSTALL_PREFIX}/${TEMPLATEDIR}\\\"")
 
 #DESKTOP
-SET(DESKTOPDIR "share/applications/")
+SET(DESKTOPDIR "${DATA_DIR}/applications/")
 ADD_DEFINITIONS("-DDESKTOPDIR=\\\"${CMAKE_INSTALL_PREFIX}/${DESKTOPDIR}\\\"")
 
 # APPLICATION_DATA_DIR
@@ -377,8 +380,8 @@ ELSE (WANT_NORPATH OR WANT_DISTROBUILD)
 ENDIF (WANT_NORPATH OR WANT_DISTROBUILD)
 
 # Set the XDG mime stuff
-SET(MIMEDIR "share/mime/packages/")
-SET(MIMELNKDIR "share/mimelnk/application/")
+SET(MIMEDIR "${DATA_DIR}/mime/packages/")
+SET(MIMELNKDIR "${DATA_DIR}/mimelnk/application/")
 
 ##############################################################################################################
 ########## Build Setup                                                                              ##########
-- 
1.8.3.4

