MantisBT - CMake
View Issue Details
0015772CMakeCMakepublic2015-10-07 09:102016-03-07 09:12
Garcia Sylvain 
 
normalminoralways
closedduplicate 
PCWindows7
CMake 3.3.2 
 
0015772: snprintf on msvc14 compiler
The CheckFunctionExits module does not detect the new msvc14's snprintf function.
Run 'cmake -G"Visual Studio 14 2015" .' on the attached CMakeLists.txt
No tags attached.
duplicate of 0015659closed  Visual Studio 2015: check_function_exists doesn't work for stdio functions 
txt CMakeLists.txt (353) 2015-10-07 09:10
https://public.kitware.com/Bug/file/5536/CMakeLists.txt
Issue History
2015-10-07 09:10Garcia SylvainNew Issue
2015-10-07 09:10Garcia SylvainFile Added: CMakeLists.txt
2015-10-07 09:22Nils GladitzNote Added: 0039526
2015-10-07 09:52Garcia SylvainNote Added: 0039527
2015-10-07 10:05Nils GladitzNote Added: 0039528
2015-10-07 10:10Garcia SylvainNote Added: 0039529
2015-10-07 11:02Gregor JasnyRelationship addedduplicate of 0015659
2015-10-07 11:03Gregor JasnyStatusnew => resolved
2015-10-07 11:03Gregor JasnyResolutionopen => duplicate
2015-10-07 11:03Gregor JasnyAssigned To => Gregor Jasny
2015-10-07 11:03Gregor JasnyAssigned ToGregor Jasny =>
2016-03-07 09:12Robert MaynardNote Added: 0040604
2016-03-07 09:12Robert MaynardStatusresolved => closed

Notes
(0039526)
Nils Gladitz   
2015-10-07 09:22   
CheckFunctionExists checks if the symbol exists at link time.
I think vs2015 defines snprinf inline and hence does not export any such symbol to be found at link time.

Try using CheckSymbolExists instead.
(0039527)
Garcia Sylvain   
2015-10-07 09:52   
Ty for answer, neverthless CheckSymbolExists does not work.
I have just been able to detect it using CheckSharedFunctionExists:

CHECK_SHARED_FUNCTION_EXISTS(snprintf "stdio.h" kernel32 "" HAVE_SNPRINTF)

with the module CheckSharedFunctionExists from https://github.com/matpow2/openal-soft-chowdren/blob/master/cmake/CheckSharedFunctionExists.cmake [^]
(0039528)
Nils Gladitz   
2015-10-07 10:05   
CheckSymbolExists works for me:

--------------------------------------
cmake_minimum_required(VERSION 3.3)
include(CheckSymbolExists)
check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF)
message("[${HAVE_SNPRINTF}]")
message("[${CMAKE_CXX_COMPILER_VERSION}]")
--------------------------------------
...
[1]
[19.0.23026.0]
...
--------------------------------------

Maybe you still had results cached from a previous run?
(0039529)
Garcia Sylvain   
2015-10-07 10:10   
Ok, my bad. It works !
Thank you and sorry for disruption.
(0040604)
Robert Maynard   
2016-03-07 09:12   
Closing resolved issues that have not been updated in more than 4 months.