When adding fmtlib as a subfolder to any of my projects in MSVC 2017 (Windows 10) with native cmake support (cmake: 3.11.18040201-MSVC_2) I get an error :
1> Version string portion was too short or too long.
at System.Version.VersionResult.SetFailure(ParseFailureKind failure, String argument)
at System.Version.TryParseVersion(String version, VersionResult& result)
at System.Version.Parse(String input)
at System.Version..ctor(String version)
at libcmake.CMakeProjectBase`3.<ExtractInfoGeneric>d__94`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at libcmake.CMakeLists.<ExtractInfo>d__114.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at libcmake.CMakeLists.<ParseWithoutCacheAsync>d__113.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.CMake.Project.CMakeListsUtils.<ParseAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.VisualStudio.CMake.Project.CMakeListsCache.<ParseAsync>d__28.MoveNext()
I think it is somehow related to the version requirements in the CMakeLists.txt:
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_VERSION})
endif()
When using cmake from the command line, it does not occur.
Reverted the problematic CMake commit in https://github.com/fmtlib/fmt/commit/ae4a3945f58b70711f45ae20bbf2770b03ef82ce, but please report the issue to MSVC developers since it looks like a bug in their parser.
Might be fixable from the CMake side too. I鈥檒l check this next week.
@aletschhorn, can you try replacing ${CMAKE_VERSION} with ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}? I think the problem is your CMake version (3.11.18040201-MSVC_2) has a -moreinfo on the end (which is allowed) but that is not recognized in this expression. I won't have access to my Windows VM until Monday.
I quickly checked again, whats MSVC does not like is
cmake_minimum_required(VERSION 3.1.0...3.11)
On the CMake website (https://cmake.org/cmake/help/v3.12/command/cmake_minimum_required.html) it says:
if the running version of CMake is older than 3.12, the extra ... dots will be seen as version component separators, resulting in the ...
part being ignored and preserving the pre-3.12 behavior of basing policies on .
Thus, as mentioned by @vitaut , this seems like a bug from the MSVC implementation.
Thanks @aletschhorn . I've added a request for a note in the documentation here: https://gitlab.kitware.com/cmake/cmake/issues/18178 .
FYI: This has now just been fixed with the most recent MSVC update.