try_compile: Use shorter test executable name with consistent length

Since commit v2.8.8~176^2 (try_compile: Use random executable file name,
2012-02-13) the length of the test executable name in generated
try_compile projects has been longer and unpredictable.  With Visual
Studio on windows, the tools try to create paths like:

 CMakeFiles/CMakeTmp/$tgt.dir/Debug/$tgt.tlog/$tgt.lastbuildstate

With the target name repeated up to 3 times, we must make it short and
of consistent length to avoid overrunning the 260 character limit
imposed by VS tools.
This commit is contained in:
Brad King 2015-02-10 10:21:55 -05:00
parent 2fd44b082b
commit f3e9eeedf4
1 changed files with 2 additions and 2 deletions

View File

@ -383,8 +383,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
/* 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());
sprintf(targetNameBuf, "cmTC_%05x",
cmSystemTools::RandomSeed() & 0xFFFFF);
targetName = targetNameBuf;
if (!targets.empty())