diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-09-19 18:36:46 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-09-19 18:36:46 (GMT) |
commit | b17cfc7584c0641a7b0dd3f0201f738873bcb6b0 (patch) | |
tree | 7a9a5d10ff239f5369fb306c5b1d79402279dc73 /Source | |
parent | dd6122c6f56105cdaad92c9e1a98127e1e60b3aa (diff) | |
download | CMake-b17cfc7584c0641a7b0dd3f0201f738873bcb6b0.zip CMake-b17cfc7584c0641a7b0dd3f0201f738873bcb6b0.tar.gz CMake-b17cfc7584c0641a7b0dd3f0201f738873bcb6b0.tar.bz2 |
Fix try compile with second signature, remove cmake lists from cache so that multiple tests work
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmTryCompileCommand.cxx | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 319adb0..9e243a5 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -16,13 +16,14 @@ =========================================================================*/ #include "cmTryCompileCommand.h" #include "cmCacheManager.h" +#include "cmListFileCache.h" int cmTryCompileCommand::CoreTryCompileCode( cmMakefile *mf, std::vector<std::string> const& argv, bool clean) { // which signature were we called with ? - bool srcFileSignature = true; - int i; + bool srcFileSignature = false; + unsigned int i; // where will the binaries be stored const char* binaryDirectory = argv[1].c_str(); @@ -30,25 +31,13 @@ int cmTryCompileCommand::CoreTryCompileCode( const char* projectName = 0; const char* targetName = 0; std::string tmpString; - - // compute the binary dir when TRY_COMPILE is called with a src file - // signature - if (srcFileSignature) - { - tmpString = argv[1] + "/CMakeTmp"; - binaryDirectory = tmpString.c_str(); - } - // make sure the binary directory exists - cmSystemTools::MakeDirectory(binaryDirectory); - - // do not allow recursive try Compiles - if (!strcmp(binaryDirectory,mf->GetHomeOutputDirectory())) + + // do we have a srcfile signature + if (argv.size() == 3 || argv[3] == "CMAKE_FLAGS" || argv[3] == "COMPILE_DEFINITIONS") { - cmSystemTools::Error("Attempt at a recursive or nested TRY_COMPILE", - binaryDirectory); - return -1; + srcFileSignature = true; } - + // look for CMAKE_FLAGS and store them std::vector<std::string> cmakeFlags; for (i = 3; i < argv.size(); ++i) @@ -62,15 +51,11 @@ int cmTryCompileCommand::CoreTryCompileCode( } break; } - else - { - srcFileSignature = false; - } } // look for COMPILE_DEFINITIONS and store them std::vector<std::string> compileFlags; - for (i = 0; i < argv.size(); ++i) + for (i = 3; i < argv.size(); ++i) { if (argv[i] == "COMPILE_DEFINITIONS") { @@ -90,6 +75,25 @@ int cmTryCompileCommand::CoreTryCompileCode( } } + // compute the binary dir when TRY_COMPILE is called with a src file + // signature + if (srcFileSignature) + { + tmpString = argv[1] + "/CMakeTmp"; + binaryDirectory = tmpString.c_str(); + } + // make sure the binary directory exists + cmSystemTools::MakeDirectory(binaryDirectory); + + // do not allow recursive try Compiles + if (!strcmp(binaryDirectory,mf->GetHomeOutputDirectory())) + { + cmSystemTools::Error("Attempt at a recursive or nested TRY_COMPILE", + binaryDirectory); + return -1; + } + + std::string outFileName = tmpString + "/CMakeLists.txt"; // which signature are we using? If we are using var srcfile bindir if (srcFileSignature) { @@ -102,7 +106,6 @@ int cmTryCompileCommand::CoreTryCompileCode( sourceDirectory = binaryDirectory; // now create a CMakeList.txt file in that directory - std::string outFileName = tmpString + "/CMakeLists.txt"; FILE *fout = fopen(outFileName.c_str(),"w"); if (!fout) { @@ -150,7 +153,7 @@ int cmTryCompileCommand::CoreTryCompileCode( // if They specified clean then we clean up what we can if (srcFileSignature && clean) - { + { cmDirectory dir; dir.Load(binaryDirectory); size_t fileNum; @@ -164,7 +167,8 @@ int cmTryCompileCommand::CoreTryCompileCode( fullPath += dir.GetFile(fileNum); cmSystemTools::RemoveFile(fullPath.c_str()); } - } + } + cmListFileCache::GetInstance()->FlushCache(outFileName.c_str()); } return res; |