MantisBT - CMake
View Issue Details
0015363CMakeCMakepublic2015-01-21 13:452015-06-01 08:38
Moshe Rubin 
 
highmajoralways
closednot fixable 
MS Windows Microsoft Windows 8.1 Pro6.3.9600 Build 9
CMake 3.1 
 
0015363: CMake 3.1.0 with "Visual Studio 12 2013 ARM" generator for WP8.1 fails to compile simple test program if path length > 91 chars
When running CMake with the "Visual Studio 12 2013 ARM" generator to create a Windows Phone 8.1 project file, the run will fail with the message:

<quote>
The C compiler "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/x86_arm/cl.exe" is not able to compile a simple test program.
</quote>

I have been able to confirm that CMake will fail consistently if the full path to the folder from which CMake is being run is greater than ninety (90) characters. If equal to, or less, than 90 characters, the run succeeds.

I have only been able to consistently reproduce this problem with the "Visual Studio 12 2013 ARM" generator.
I attach a Windows batch file called "cmake-mantis.bat" that will reproduce the two cases, successful and unsuccessful. Here are the steps:

(1) Copy the Windows batch file "cmake-matis.bat" to any folder in the file system.

(2) "cd" to above folder.

(3) To reproduce an unsuccessful run, execute the following command:

    cmake-mantis.bat bad

    In this case, the folder from where CMake is execute is:

    %TEMP%\CMakeTest\12345678901234567890\12345678901234567890\12345678901234567890\12345678901234567890\12345678901234567890

(4) To reproduce a successful run, execute the following command:

    cmake-mantis.bat good

    In this case, the folder from which CMake is executed is:

    %TEMP%\CMakeTest

(5) The batch file leaves the try_compile build trees intact for debugging purposes.
I added the "--trace" command line option for both the 'good' and the 'bad' runs and have uploaded them as the files "foo.good" and "foo.bad". Doing a diff on them both shows the following strange phenomenon: both logs are essentially identical (except for folder names) until foo.good:2649 and foo.bad:2650. At this point, inexplicably, CMAKE_C_COMPILER_WORKS is TRUE in foo.good but FALSE in goo.bad:

Starting at line 2649 in foo.good:

<snippet>
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCCompiler.cmake(56): if(NOT CMAKE_C_COMPILER_WORKS )
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCCompiler.cmake(65): else()
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCCompiler.cmake(66): if(C_TEST_WAS_RUN )
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCCompiler.cmake(67): PrintTestCompilerStatus(C -- works )
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCompilerCommon.cmake(16): if(CMAKE_GENERATOR MATCHES Make )
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCompilerCommon.cmake(18): else()
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCompilerCommon.cmake(19): message(STATUS Check for working ${LANG} compiler using: ${CMAKE_GENERATOR}${MSG} )
-- Check for working C compiler using: Visual Studio 12 2013 ARM -- works
</snippet>

Starting at line 2650 in foo.bad:

<snippet>
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCCompiler.cmake(56): if(NOT CMAKE_C_COMPILER_WORKS )
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCCompiler.cmake(57): PrintTestCompilerStatus(C -- broken )
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCompilerCommon.cmake(16): if(CMAKE_GENERATOR MATCHES Make )
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCompilerCommon.cmake(18): else()
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeTestCompilerCommon.cmake(19): message(STATUS Check for working ${LANG} compiler using: ${CMAKE_GENERATOR}${MSG} )
-- Check for working C compiler using: Visual Studio 12 2013 ARM -- broken
</snippet>

There are no differences in the traces leading up to these points to explain the discrepancy.
No tags attached.
zip CMake-Mantis-15363.zip (50,295) 2015-01-21 13:47
https://public.kitware.com/Bug/file/5353/CMake-Mantis-15363.zip
log CMakeError.log (7,061) 2015-01-21 23:48
https://public.kitware.com/Bug/file/5354/CMakeError.log
Issue History
2015-01-21 13:45Moshe RubinNew Issue
2015-01-21 13:47Moshe RubinFile Added: CMake-Mantis-15363.zip
2015-01-21 14:57Brad KingNote Added: 0037764
2015-01-21 23:48Moshe RubinFile Added: CMakeError.log
2015-01-21 23:52Moshe RubinNote Added: 0037767
2015-01-22 09:01Brad KingNote Added: 0037769
2015-01-22 09:01Brad KingStatusnew => resolved
2015-01-22 09:01Brad KingResolutionopen => not fixable
2015-01-22 15:11Moshe RubinNote Added: 0037781
2015-06-01 08:38Robert MaynardNote Added: 0038854
2015-06-01 08:38Robert MaynardStatusresolved => closed

Notes
(0037764)
Brad King   
2015-01-21 14:57   
Look at the CMakeFiles/CMakeError.log file for details about the failed check. Please attach the file here.
(0037767)
Moshe Rubin   
2015-01-21 23:52   
I've uploaded the CMakeError.log file. Indeed, it has the following lines:

<snippet>
C:\Program Files (x86)
\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1697,5): warning
MSB3101: Could not write state file
"cmTryCompileExec363798746.dir\Debug\cmTryCompileExec363798746.vcxprojResolveA
ssemblyReference.cache". The specified path, file name, or both are too long.
The fully qualified file name must be less than 260 characters, and the
directory name must be less than 248 characters.

[C:\Users\moshe\AppData\Local\Temp\CMakeTest\12345678901234567890\123456789012
34567890\12345678901234567890\12345678901234567890\12345678901234567890\WinPho
ne8\CMakeFiles\CMakeTmp\cmTryCompileExec363798746.vcxproj]

C:\Program Files (x86)
\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(308,5): error
MSB3491: Could not write lines to file
"cmTryCompileExec363798746.dir\Debug\cmTryCom.B7ABD048.tlog\cmTryCompileExec36
3798746.lastbuildstate". The specified path, file name, or both are too long.
The fully qualified file name must be less than 260 characters, and the
directory name must be less than 248 characters.

[C:\Users\moshe\AppData\Local\Temp\CMakeTest\12345678901234567890\123456789012
34567890\12345678901234567890\12345678901234567890\12345678901234567890\WinPho
ne8\CMakeFiles\CMakeTmp\cmTryCompileExec363798746.vcxproj]
</snippet>

If CMake adds lower layers to the folder path, reaching the file system path length limits, can a CMake user be told up front what the maximum path length is for his/her use?
(0037769)
Brad King   
2015-01-22 09:01   
Re 0015363:0037767: Unfortunately that would be very difficult to compute. In this case it is actually msbuild that tries to access a path longer than the one CMake generated by appending some extra content like "cmTryCompileExec363798746.vcxprojResolveAssemblyReference.cache".

CMake already has extensive logic to try to allow longer build tree paths by remapping where object files go so they fit under the limit. Unfortunately we cannot predict where all the other msbuild files go.

My typical build directories are not much more than 50 characters long at the top.
(0037781)
Moshe Rubin   
2015-01-22 15:11   
Brad,

Thanks for the explanation. In this case there is nothing to do about it other thank keep the top folder within 50 characters. You might want to consider documenting this somewhere.

I will therefore consider this issue "resolved".
(0038854)
Robert Maynard   
2015-06-01 08:38   
Closing resolved issues that have not been updated in more than 4 months.