From 25cbe1c06484791a06bdf138c8ec71d4033faeae Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Thu, 6 Dec 2018 20:18:27 +0100
Subject: [PATCH] Tentative fix for conda build

See #416
---
 src/config/Config.inc.in | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/config/Config.inc.in b/src/config/Config.inc.in
index 6ffce3215..b4739b647 100644
--- a/src/config/Config.inc.in
+++ b/src/config/Config.inc.in
@@ -28,8 +28,18 @@
 namespace PLMD {
 namespace config {
 
+// This is a fix to allow conda to correctly replace paths in binary files.
+// These variables should not be static or they will be optimized away!
+// I guess the compiler thinks that they could be replaced from outside
+// (even though they are const) and thus cannot optimize them.
+const char* plumed_root="@PLUMED_ROOT@";
+const char* plumed_soext="@SOEXT@";
+const char* plumed_htmldir="@htmldir@";
+const char* plumed_includedir="@includedir@";
+const char* plumed_program_name="@program_name@";
+
 std::string getSoExt() {
-  return "@SOEXT@";
+  return plumed_soext;
 }
 
 bool isInstalled() {
@@ -40,7 +50,7 @@ std::string getPlumedRoot() {
   char *env = std::getenv("PLUMED_ROOT");
   std::string ss;
   if( env == NULL) {
-    ss="@PLUMED_ROOT@";
+    ss=plumed_root;
   } else {
     ss=std::string( env );
   }
@@ -52,7 +62,7 @@ std::string getPlumedHtmldir() {
   char *env = std::getenv("PLUMED_HTMLDIR");
   std::string ss;
   if( env == NULL) {
-    ss="@htmldir@";
+    ss=plumed_htmldir;
   } else {
     ss=std::string( env );
   }
@@ -64,7 +74,7 @@ std::string getPlumedIncludedir() {
   char *env = std::getenv("PLUMED_INCLUDEDIR");
   std::string ss;
   if( env == NULL) {
-    ss="@includedir@";
+    ss=plumed_includedir;
   } else {
     ss=std::string( env );
   }
@@ -76,7 +86,7 @@ std::string getPlumedProgramName() {
   char *env = std::getenv("PLUMED_PROGRAM_NAME");
   std::string ss;
   if( env == NULL) {
-    ss="@program_name@";
+    ss=plumed_program_name;
   } else {
     ss=std::string( env );
   }
-- 
GitLab