get executable directory at runtime rather than configure time
authorkoda
Mon, 24 Dec 2012 15:41:45 +0100
changeset 8323 ab0b618bdf13
parent 8322 50369fa5053b
child 8324 e0dcf5b0e1b1
get executable directory at runtime rather than configure time
QTfrontend/CMakeLists.txt
QTfrontend/hwconsts.cpp.in
QTfrontend/hwconsts.h
QTfrontend/main.cpp
--- a/QTfrontend/CMakeLists.txt	Mon Dec 24 03:00:18 2012 +0100
+++ b/QTfrontend/CMakeLists.txt	Mon Dec 24 15:41:45 2012 +0100
@@ -41,8 +41,6 @@
     include_directories("/usr/local/include")
 endif(UNIX)
 
-#directory containing hw executables
-set(HEDGEWARS_BINDIR ${CMAKE_INSTALL_PREFIX}/${target_binary_install_dir})
 #directory for resources, relative to the one above on certain platforms/configurations
 if(DEFINED DATA_INSTALL_DIR OR WIN32 OR APPLE)
     set(HEDGEWARS_DATADIR ${SHAREPATH})
--- a/QTfrontend/hwconsts.cpp.in	Mon Dec 24 03:00:18 2012 +0100
+++ b/QTfrontend/hwconsts.cpp.in	Mon Dec 24 15:41:45 2012 +0100
@@ -22,10 +22,9 @@
 
 QString * cProtoVer = new QString("${HEDGEWARS_PROTO_VER}");
 QString * cDataDir = new QString("${HEDGEWARS_DATADIR}");
-QString * cConfigDir = new QString("");
 QString * cVersionString = new QString("${HEDGEWARS_VERSION}");
 
-QDir * bindir = new QDir("${HEDGEWARS_BINDIR}");
+QDir * bindir = new QDir();
 QDir * cfgdir = new QDir();
 QDir * datadir = new QDir();
 
--- a/QTfrontend/hwconsts.h	Mon Dec 24 03:00:18 2012 +0100
+++ b/QTfrontend/hwconsts.h	Mon Dec 24 15:41:45 2012 +0100
@@ -26,7 +26,6 @@
 extern QString * cProtoVer;
 extern QString * cVersionString;
 extern QString * cDataDir;
-extern QString * cConfigDir;
 
 extern QDir * bindir;
 extern QDir * cfgdir;
--- a/QTfrontend/main.cpp	Mon Dec 24 03:00:18 2012 +0100
+++ b/QTfrontend/main.cpp	Mon Dec 24 15:41:45 2012 +0100
@@ -175,9 +175,14 @@
     if(parsedArgs.contains("config-dir"))
     {
         QFileInfo f(parsedArgs["config-dir"]);
-        *cConfigDir = f.absoluteFilePath();
+        cfgdir->setPath(f.absoluteFilePath());
         custom_config = true;
     }
+    else
+    {
+        cfgdir->setPath(QDir::homePath());
+        custom_config = false;
+    }
 
     app.setStyle(new QPlastiqueStyle());
 
@@ -190,14 +195,10 @@
     qRegisterMetaType<HWTeam>("HWTeam");
 
     // workaround over NSIS installer which modifies the install path
-    bindir->cd("./");
+    //bindir->cd("./");
+    bindir->cd(QCoreApplication::applicationDirPath());
 
-    if(cConfigDir->length() == 0)
-        cfgdir->setPath(cfgdir->homePath());
-    else
-        cfgdir->setPath(*cConfigDir);
-
-    if(cConfigDir->length() == 0)
+    if(custom_config == false)
     {
 #ifdef __APPLE__
         checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars");