summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-02-21 20:54:51 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-02-21 20:54:51 (GMT)
commit7bcd2829812c651e009c55660f0c14ee73896746 (patch)
treeb96dce7e2cc0fb69737b37386be9ac63d18a9e89 /Source
parentee9fd3d3d3040ea66f29c492d4434826d13770be (diff)
parent4fbdce2b79b28566ae2c6708c99af5e0e8e0177b (diff)
downloadCMake-7bcd2829812c651e009c55660f0c14ee73896746.zip
CMake-7bcd2829812c651e009c55660f0c14ee73896746.tar.gz
CMake-7bcd2829812c651e009c55660f0c14ee73896746.tar.bz2
Merge topic 'try-compile-random-name'
4fbdce2 try_compile: Use random executable file name (#12957)
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCoreTryCompile.cxx13
1 files changed, 9 insertions, 4 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index dca2fb3..7d84ba6 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -26,6 +26,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
const char* sourceDirectory = argv[2].c_str();
const char* projectName = 0;
const char* targetName = 0;
+ char targetNameBuf[64];
int extraArgs = 0;
// look for CMAKE_FLAGS and store them
@@ -281,16 +282,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
cmakeFlags.push_back(flag);
}
+ /* Use a random file name to avoid rapid creation and deletion
+ of the same executable name (some filesystems fail on that). */
+ sprintf(targetNameBuf, "cmTryCompileExec%u",
+ cmSystemTools::RandomSeed());
+ targetName = targetNameBuf;
+
/* Put the executable at a known location (for COPY_FILE). */
fprintf(fout, "SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
this->BinaryDirectory.c_str());
/* Create the actual executable. */
- fprintf(fout, "ADD_EXECUTABLE(cmTryCompileExec \"%s\")\n",source.c_str());
- fprintf(fout,
- "TARGET_LINK_LIBRARIES(cmTryCompileExec ${LINK_LIBRARIES})\n");
+ fprintf(fout, "ADD_EXECUTABLE(%s \"%s\")\n", targetName, source.c_str());
+ fprintf(fout, "TARGET_LINK_LIBRARIES(%s ${LINK_LIBRARIES})\n",targetName);
fclose(fout);
projectName = "CMAKE_TRY_COMPILE";
- targetName = "cmTryCompileExec";
// if the source is not in CMakeTmp
if(source.find("CMakeTmp") == source.npos)
{