diff options
-rw-r--r-- | Source/cmCoreTryCompile.cxx | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 8d41f00..d90b574 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -283,7 +283,6 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, std::vector<std::string> linkOptions; std::string libsToLink = " "; bool useOldLinkLibs = true; - char targetNameBuf[64]; bool didOutputVariable = false; bool didCopyFile = false; bool didCopyFileError = false; @@ -419,6 +418,16 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, return -1; } + if (this->SrcFileSignature) { + projectName = "CMAKE_TRY_COMPILE"; + /* Use a random file name to avoid rapid creation and deletion + of the same executable name (some filesystems fail on that). */ + char targetNameBuf[64]; + snprintf(targetNameBuf, sizeof(targetNameBuf), "cmTC_%05x", + cmSystemTools::RandomSeed() & 0xFFFFF); + targetName = targetNameBuf; + } + if (didCopyFile && copyFile.empty()) { this->Makefile->IssueMessage(MessageType::FATAL_ERROR, "COPY_FILE must be followed by a file path"); @@ -733,12 +742,6 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, cmJoin(compileDefs, "]==] [==[").c_str()); } - /* Use a random file name to avoid rapid creation and deletion - of the same executable name (some filesystems fail on that). */ - snprintf(targetNameBuf, sizeof(targetNameBuf), "cmTC_%05x", - cmSystemTools::RandomSeed() & 0xFFFFF); - targetName = targetNameBuf; - if (!targets.empty()) { std::string fname = "/" + std::string(targetName) + "Targets.cmake"; cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile, @@ -895,7 +898,6 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, libsToLink.c_str()); } fclose(fout); - projectName = "CMAKE_TRY_COMPILE"; } // Forward a set of variables to the inner project cache. |