on linux assume datapath is always relative to cmake_install_prefix, unless you provide an absolute path; on win32/osx hardcode engine path to default installation prefixes (it gets overridden at runtime so it works even if you move the data folder)
authorkoda
Mon, 04 Mar 2013 18:27:21 +0100
changeset 8646 e31044b7fbba
parent 8645 809e328bab99
child 8647 c1bcdee46bff
on linux assume datapath is always relative to cmake_install_prefix, unless you provide an absolute path; on win32/osx hardcode engine path to default installation prefixes (it gets overridden at runtime so it works even if you move the data folder)
CMakeLists.txt
QTfrontend/CMakeLists.txt
QTfrontend/hwconsts.cpp.in
hedgewars/config.inc.in
--- a/CMakeLists.txt	Mon Mar 04 20:16:43 2013 +0400
+++ b/CMakeLists.txt	Mon Mar 04 18:27:21 2013 +0100
@@ -95,21 +95,28 @@
 if(UNIX AND NOT APPLE)
     set(target_binary_install_dir "bin")
     set(target_library_install_dir "lib")
-    set(SHAREPATH "${DATA_INSTALL_DIR}/")
+
+    string(SUBSTRING "${DATA_INSTALL_DIR}" 0 1 sharepath_start)
+    if (NOT (${sharepath_start} MATCHES "/"))
+        set(HEDGEWARS_DATADIR "${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/")
+    else()
+        set(HEDGEWARS_DATADIR "${DATA_INSTALL_DIR}/")
+    endif()
+    set(HEDGEWARS_FULL_DATADIR "${HEDGEWARS_DATADIR}")
 else()
     set(target_binary_install_dir "./")
 
     if(APPLE)
+        set(target_library_install_dir "../Frameworks/")
         set(CMAKE_INSTALL_PREFIX "Hedgewars.app/Contents/MacOS/")
-        set(SHAREPATH "../Resources/")
-        set(target_library_install_dir "../Frameworks/")
-    else()
-        if(WIN32)
-            set(target_library_install_dir "./")
-            set(SHAREPATH "./")
-            set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/misc/winutils/")
-            link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
-        endif(WIN32)
+        set(HEDGEWARS_DATADIR "../Resources/")
+        set(HEDGEWARS_FULL_DATADIR "/Applications/${CMAKE_INSTALL_PREFIX}/${HEDGEWARS_DATADIR}")
+    elseif(WIN32)
+        set(target_library_install_dir "./")
+        set(HEDGEWARS_DATADIR "./")
+        set(HEDGEWARS_FULL_DATADIR "${CMAKE_INSTALL_PREFIX}/")
+        set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/misc/winutils/")
+        link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
     endif()
 endif()
 
--- a/QTfrontend/CMakeLists.txt	Mon Mar 04 20:16:43 2013 +0400
+++ b/QTfrontend/CMakeLists.txt	Mon Mar 04 18:27:21 2013 +0100
@@ -66,14 +66,6 @@
     include_directories("/usr/local/include")
 endif(UNIX)
 
-#directory for resources, relative to bindir (on linux an absolute path is always used)
-string(SUBSTRING "${SHAREPATH}" 0 1 sharepath_start)
-if(APPLE OR WIN32 OR ${sharepath_start} MATCHES "/")
-    set(HEDGEWARS_DATADIR ${SHAREPATH})
-else()
-    set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/${SHAREPATH})
-endif()
-
 #only the cocoa version of qt supports building 64 bit apps
 if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64*") AND (NOT QT_MAC_USE_COCOA))
     message(FATAL_ERROR "Building the 64 bit version of Hedgewars *requires* the Cocoa variant of QT on Mac OS X")
--- a/QTfrontend/hwconsts.cpp.in	Mon Mar 04 20:16:43 2013 +0400
+++ b/QTfrontend/hwconsts.cpp.in	Mon Mar 04 18:27:21 2013 +0100
@@ -21,8 +21,9 @@
 #include "hwconsts.h"
 #include "weapons.h"
 
+// cDataDir gets 'Data' appended later (in main.cpp)
+QString * cDataDir = new QString("${HEDGEWARS_DATADIR}");
 QString * cProtoVer = new QString("${HEDGEWARS_PROTO_VER}");
-QString * cDataDir = new QString("${HEDGEWARS_DATADIR}");
 QString * cVersionString = new QString("${HEDGEWARS_VERSION}");
 QString * cRevisionString = new QString("${revision_number}");
 QString * cHashString = new QString("${hash_number}");
--- a/hedgewars/config.inc.in	Mon Mar 04 20:16:43 2013 +0400
+++ b/hedgewars/config.inc.in	Mon Mar 04 18:27:21 2013 +0100
@@ -26,4 +26,4 @@
       cRevisionString = '${revision_number}';
       cHashString = '${hash_number}';
       cLuaLibrary = '${LUA_LIBRARY}';
-      cDefaultPathPrefix = '${CMAKE_INSTALL_PREFIX}/${SHAREPATH}/Data';
+      cDefaultPathPrefix = '${HEDGEWARS_FULL_DATADIR}/Data';