From e9b5bd907f5b50b17d65ebe2fa50760d322c537c Mon Sep 17 00:00:00 2001
From: Christopho <christopho@solarus-games.org>
Date: Fri, 12 Aug 2016 10:12:54 +0200
Subject: [PATCH] Update cmake file to previous fixes from zsdx

---
 CMakeLists.txt | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7bafe7a..f6286c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,16 @@ project(ZELDA_ROTH_SE)
 
 set(quest_name "zelda_roth_se")
 
+set(SOLARUS_INSTALL_DATAROOTDIR "share" CACHE PATH "dataroot dir")
+set(SOLARUS_INSTALL_DATADIR "${SOLARUS_INSTALL_DATAROOTDIR}/solarus" CACHE PATH "data dir")
+set(SOLARUS_INSTALL_BINDIR "bin" CACHE PATH "bin dir")
+
+if (IS_ABSOLUTE ${SOLARUS_INSTALL_DATADIR})
+  set(SOLARUS_INSTALL_ABSOLUTE_DATADIR ${SOLARUS_INSTALL_DATADIR})
+else()
+  set(SOLARUS_INSTALL_ABSOLUTE_DATADIR ${CMAKE_INSTALL_PREFIX}/${SOLARUS_INSTALL_DATADIR})
+endif()
+
 # data files list
 file(GLOB_RECURSE data_files
   RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/data
@@ -47,7 +57,7 @@ add_custom_target(${quest_name}_data
 add_custom_command(
   OUTPUT ${quest_name}
   COMMAND echo '\#!/bin/sh' > ${quest_name}
-  COMMAND echo 'solarus-run ${CMAKE_INSTALL_PREFIX}/share/solarus/${quest_name} $*' >> ${quest_name}
+  COMMAND echo 'solarus-run ${SOLARUS_INSTALL_ABSOLUTE_DATADIR}/${quest_name} $$*' >> ${quest_name}
 )
 add_custom_target(${quest_name}_command
   ALL
@@ -56,11 +66,11 @@ add_custom_target(${quest_name}_command
 
 # install the data archive
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/data.solarus
-  DESTINATION share/solarus/${quest_name}
+  DESTINATION ${SOLARUS_INSTALL_DATADIR}/${quest_name}
 )
 
 # install the script
 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${quest_name}
-  DESTINATION bin
+  DESTINATION ${SOLARUS_INSTALL_BINDIR}
 )