View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011565CMakeCMakepublic2010-12-02 16:352016-06-10 14:31
ReporterDaniel Richard G. 
Assigned ToKitware Robot 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionFixed in Version 
Summary0011565: CHECK_{FUNCTION,LIBRARY}_EXISTS() macros need a way to specify function declaration
DescriptionI want to check for the existence of a library+function. On Windows, however, the function must be declared using the WINAPI keyword (which is available after #including<windows.h>) in order for the linker to find it. This keyword changes the symbol that the linker looks for in a manner that cannot otherwise be represented in valid C code, so there is no alternative to its use.

There is currently no way to shoehorn this keyword into the C file used by the CHECK_{FUNCTION,LIBRARY}_EXISTS() macros, or otherwise to modify the trivial "char foo();" function declaration therein; the best you can do is create a custom C file and invoke TRY_COMPILE() yourself.
TagsNo tags attached.
Attached Files

 Relationships
related to 0010090closedBrad King check_prototype_definition() - Check if the protoype we expect is correct 

  Notes
(0024777)
David Cole (manager)
2011-01-17 12:57

I suggest invoking try_compile yourself with exactly the right details according to what you're looking for.

Do you have a suggestion for making this a more general purpose facility? A concrete proposed patch, including documentation and testing...?

Are you currently using a home-made CMake macro or function of any sort?
(0024781)
Daniel Richard G. (reporter)
2011-01-17 13:17
edited on: 2011-01-17 13:20

I'm using try_compile() directly at the moment, but it seems silly to have to do that when all you want to change is a small part of the function declaration.

What about a new variable that can be set before calling the function to modify the declaration? Where you could do e.g.

    set(CMAKE_REQUIRED_DECLARATION "WINAPI int")

and that gets used in the C code instead of "char"?

Of course, that would also need the Windows header... maybe something like

    set(CMAKE_REQUIRED_PREAMBLE "#ifdef WIN32\n#include<windows.h>\n#endif")

as well?

(0025820)
Brad King (manager)
2011-03-18 14:11

Please see the fix to issue 0010090:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4f252abe [^]

Is this sufficient?
(0025823)
Daniel Richard G. (reporter)
2011-03-18 14:41

In my particular case, I'm checking for a function in a library for which no header file is available. (I.e. the consuming code provides the prototype.)

A link stage is still necessary, especially here when it's with a non-default ABI.
(0041767)
Kitware Robot (administrator)
2016-06-10 14:28

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2010-12-02 16:35 Daniel Richard G. New Issue
2011-01-17 12:57 David Cole Note Added: 0024777
2011-01-17 12:57 David Cole Assigned To => David Cole
2011-01-17 12:57 David Cole Status new => assigned
2011-01-17 13:17 Daniel Richard G. Note Added: 0024781
2011-01-17 13:20 Daniel Richard G. Note Edited: 0024781
2011-01-17 14:34 David Cole Relationship added related to 0010090
2011-02-09 13:58 David Cole Status assigned => backlog
2011-02-09 13:59 David Cole Assigned To David Cole =>
2011-03-18 14:11 Brad King Note Added: 0025820
2011-03-18 14:41 Daniel Richard G. Note Added: 0025823
2016-06-10 14:28 Kitware Robot Note Added: 0041767
2016-06-10 14:28 Kitware Robot Status backlog => resolved
2016-06-10 14:28 Kitware Robot Resolution open => moved
2016-06-10 14:28 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team