[cmake-developers] [CMake 0015659]: Visual Studio 2015: check_function_exists doesn't work for stdio functions

Mantis Bug Tracker mantis at public.kitware.com
Wed Jul 22 17:34:52 EDT 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=15659 
====================================================================== 
Reported By:                Alex Lamaison
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15659
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-07-22 17:34 EDT
Last Modified:              2015-07-22 17:34 EDT
====================================================================== 
Summary:                    Visual Studio 2015: check_function_exists doesn't
work for stdio functions
Description: 
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.

Steps to Reproduce: 
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'.

Additional Information: 
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
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-07-22 17:34 Alex Lamaison  New Issue                                    
======================================================================



More information about the cmake-developers mailing list