summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefile.cxx9
-rw-r--r--Source/cmMakefile.h3
-rw-r--r--Source/cmTryCompileCommand.cxx30
-rw-r--r--Source/cmTryCompileCommand.h4
4 files changed, 36 insertions, 10 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index ec8871b..106d373 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1339,7 +1339,8 @@ void cmMakefile::ExpandSourceListArguments(
}
int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
- const char *projectName, const char *targetName)
+ const char *projectName, const char *targetName,
+ const std::vector<std::string> *cmakeArgs)
{
// does the binary directory exist ? If not create it...
if (!cmSystemTools::FileIsDirectory(bindir))
@@ -1377,7 +1378,11 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
cm.SetStartOutputDirectory(bindir);
cm.SetCMakeCommand(cmakeCommand.c_str());
cm.LoadCache();
-
+ // if cmake args were provided then pass them in
+ if (cmakeArgs)
+ {
+ cm.SetCacheArgs(*cmakeArgs);
+ }
// to save time we pass the EnableLanguage info directly
gg->EnableLanguagesFromGenerator(m_LocalGenerator->GetGlobalGenerator(),
this);
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index c14a4e3..56b5080 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -84,7 +84,8 @@ public:
* loaded commands, not as part of the usual build process.
*/
int TryCompile(const char *srcdir, const char *bindir,
- const char *projectName, const char *targetName);
+ const char *projectName, const char *targetName,
+ const std::vector<std::string> *cmakeArgs);
/**
* Specify the makefile generator. This is platform/compiler
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index 9128756..52f10dd 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -25,6 +25,27 @@ bool cmTryCompileCommand::InitialPass(std::vector<std::string> const& argv)
return false;
}
+ // which signature were we called with ?
+ bool srcFileSignature = true;
+
+ // look for CMAKE_FLAGS and store them
+ std::vector<std::string> cmakeFlags;
+ int i;
+ for (i = 3; i < argv.size(); ++i)
+ {
+ if (argv[i] == "CMAKE_FLAGS")
+ {
+ for (; i < argv.size(); ++i)
+ {
+ cmakeFlags.push_back(argv[i]);
+ }
+ }
+ else
+ {
+ srcFileSignature = false;
+ }
+ }
+
// where will the binaries be stored
const char* binaryDirectory = argv[1].c_str();
const char* sourceDirectory = argv[2].c_str();
@@ -34,12 +55,11 @@ bool cmTryCompileCommand::InitialPass(std::vector<std::string> const& argv)
// compute the binary dir when TRY_COMPILE is called with a src file
// signature
- if (argv.size() == 3)
+ if (srcFileSignature)
{
tmpString = argv[1] + "/CMakeTmp";
binaryDirectory = tmpString.c_str();
}
-
// make sure the binary directory exists
cmSystemTools::MakeDirectory(binaryDirectory);
@@ -52,7 +72,7 @@ bool cmTryCompileCommand::InitialPass(std::vector<std::string> const& argv)
}
// which signature are we using? If we are using var srcfile bindir
- if (argv.size() == 3)
+ if (srcFileSignature)
{
// remove any CMakeCache.txt files so we will have a clean test
std::string ccFile = tmpString + "/CMakeCache.txt";
@@ -93,13 +113,13 @@ bool cmTryCompileCommand::InitialPass(std::vector<std::string> const& argv)
// actually do the try compile now that everything is setup
int res = m_Makefile->TryCompile(sourceDirectory, binaryDirectory,
- projectName, targetName);
+ projectName, targetName, &cmakeFlags);
// set the result var to the return value to indicate success or failure
m_Makefile->AddDefinition(argv[0].c_str(), (res == 0 ? "TRUE" : "FALSE"));
// if we created a directory etc, then cleanup after ourselves
- if (argv.size() == 3)
+ if (srcFileSignature)
{
cmDirectory dir;
dir.Load(binaryDirectory);
diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h
index 8658ac8..1b3bf0b 100644
--- a/Source/cmTryCompileCommand.h
+++ b/Source/cmTryCompileCommand.h
@@ -62,11 +62,11 @@ public:
virtual const char* GetFullDocumentation()
{
return
- "TRY_COMPILE(RESULT_VAR bindir srcdir projectName <targetName>)\n"
+ "TRY_COMPILE(RESULT_VAR bindir srcdir projectName <CMAKE_FLAGS <Flags>>)\n"
"Try compiling a program. Return the success or failure in RESULT_VAR "
"If <target name> is specified then build just that target "
"otherwise the all or ALL_BUILD target is built.\n"
- "TRY_COMPILE(RESULT_VAR bindir srcfile)\n"
+ "TRY_COMPILE(RESULT_VAR bindir srcfile <CMAKE_FLAGS <Flags>>)\n"
"Try compiling a srcfile. Return the success or failure in RESULT_VAR.";
}