MantisBT - CMake
View Issue Details
0015659CMakeCMakepublic2015-07-22 17:342016-03-07 09:12
Alex Lamaison 
 
normalminoralways
closedno change required 
Windows
CMake 3.1.3 
 
0015659: Visual Studio 2015: check_function_exists doesn't work for stdio functions
check_function_exists worked with previous versions of VS and correctly detected the absence of presence of stdio functions like the printf/scanf families, but with VS2015, those functions are always 'not found'

With Visual Studio 2015, those functions are now defined *inline* in stdio.h. This means that CheckFunctionExists.c, which doesn't included stdio.h, can't find any definition of the function to link with. Previously this would have linked with the symbol in the CRT.
Add check_function_exists(snprintf) to a project.
Configure with VS2015 generator.
It should say 'Looking for snprintf - found'.
Instead it says 'Looking for snprintf - not found'.
A workaround is to add legacy_stdio_definitions.lib to CMAKE_REQUIRED_LIBRARIES. However, that is not ideal because it requires knowing that library is available and required in the first place. That defeats the object of feature detection.

More info here: https://msdn.microsoft.com/en-us/library/bb531344.aspx [^]
No tags attached.
has duplicate 0015671closed  cmake does not find _vsnprintf 
has duplicate 0015772closed  snprintf on msvc14 compiler 
Issue History
2015-07-22 17:34Alex LamaisonNew Issue
2015-07-23 08:41Brad KingNote Added: 0039164
2015-07-29 16:01Alex LamaisonNote Added: 0039187
2015-07-30 08:47Brad KingStatusnew => resolved
2015-07-30 08:47Brad KingResolutionopen => no change required
2015-07-30 08:58Brad KingRelationship addedhas duplicate 0015671
2015-10-07 11:02Gregor JasnyRelationship addedhas duplicate 0015772
2016-03-07 09:12Robert MaynardNote Added: 0040603
2016-03-07 09:12Robert MaynardStatusresolved => closed

Notes
(0039164)
Brad King   
2015-07-23 08:41   
Use CheckSymbolExists instead. That allows one to include a header.
(0039187)
Alex Lamaison   
2015-07-29 16:01   
Thanks. That worked :)
(0040603)
Robert Maynard   
2016-03-07 09:12   
Closing resolved issues that have not been updated in more than 4 months.