Commit 2659c48f authored by Mark Olesen's avatar Mark Olesen
Browse files

COMP: change foamVersion::configuredProjectDir to function (#1712)

- exhibited apparent issues with initialization order (on some
  installations of gcc-4.8.5) when a variable was used.
parent 02517e97
......@@ -143,10 +143,14 @@ static inline bool groupResourceDir(Foam::fileName& queried)
#endif
// Compile-time paths
queried = Foam::foamVersion::configuredProjectDir/Foam::string("site/etc");
if (queried.size() > 8 && Foam::isDir(queried))
queried = Foam::foamVersion::configuredProjectDir();
if (queried.size())
{
return true;
queried /= "site/etc";
if (Foam::isDir(queried))
{
return true;
}
}
queried.clear();
......@@ -175,16 +179,23 @@ static inline bool projectResourceDir(Foam::fileName& queried)
// Compile-time paths
queried = Foam::foamVersion::configuredEtcDir;
if (Foam::isDir(queried))
queried = Foam::foamVersion::configuredEtcDir();
if (queried.size())
{
return true;
if (Foam::isDir(queried))
{
return true;
}
}
queried = Foam::foamVersion::configuredProjectDir/Foam::word("etc");
if (queried.size() > 3 && Foam::isDir(queried))
queried = Foam::foamVersion::configuredProjectDir();
if (queried.size())
{
return true;
queried /= "etc";
if (Foam::isDir(queried))
{
return true;
}
}
queried.clear();
......
......@@ -114,6 +114,8 @@ const std::string Foam::foamVersion::version
};
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
unsigned Foam::foamVersion::labelByteSize(const std::string& str)
{
return getTaggedSize("label=", str) / 8;
......@@ -126,20 +128,27 @@ unsigned Foam::foamVersion::scalarByteSize(const std::string& str)
}
const std::string Foam::foamVersion::configuredProjectDir
// These two are defined as functions to avoid static initialization
// order problems with older gcc.
std::string Foam::foamVersion::configuredProjectDir()
{
#ifdef FOAM_CONFIGURED_PROJECT_DIR
FOAM_CONFIGURED_PROJECT_DIR
return FOAM_CONFIGURED_PROJECT_DIR ;
#else
return std::string{};
#endif
};
}
const std::string Foam::foamVersion::configuredEtcDir
std::string Foam::foamVersion::configuredEtcDir()
{
#ifdef FOAM_CONFIGURED_PROJECT_ETC
FOAM_CONFIGURED_PROJECT_ETC
return FOAM_CONFIGURED_PROJECT_ETC ;
#else
return std::string{};
#endif
};
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -30,7 +30,7 @@ License
// Static data members are constructed in global.Cver
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
bool Foam::foamVersion::patched()
{
......
......@@ -126,12 +126,14 @@ namespace Foam
void printBuildInfo(const bool full=true);
//- Compile-time definition of the OpenFOAM project directory
// Usually not defined - functional equivalent to WM_PROJECT_DIR
extern const std::string configuredProjectDir;
//- or empty if not defined.
// Functional equivalent to WM_PROJECT_DIR.
std::string configuredProjectDir();
//- Compile-time definition of the OpenFOAM etc/ directory
// Usually not defined - functional equivalent to WM_PROJECT_DIR/etc
extern const std::string configuredEtcDir;
//- or empty if not defined.
// Functional equivalent to WM_PROJECT_DIR/etc
std::string configuredEtcDir();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment