[CMake] Problem with CHECK_FUNCTION_EXISTS and strcasecmp

Mateusz Loskot mateusz at loskot.net
Sat Mar 13 13:03:56 EST 2010


Michael Surette wrote:
> I am updating the CMake build files for a cross-platform project.  One
> of the tests is for strcasecmp for which I use CHECK_FUNCTION_EXISTS. If
> it's not found the code generates its own function by that name.
> 
> This works well with GCC under Linux, including cross-compiling with
> MinGW, as well as MinGW under Windows.
> 
> Testing this with MSVS 2008 Express under Windows XP, it fails to find
> the function but gives errors and fails when I try to build.
> 
> If I manually edit the config.h file generated by CMake so that it
> misreports that there is a strcasecmp function available it compiles well.
> 
> My conclusion is that either this function exists or a macro is defining
> it, but it's not being found by CHECK_FUNCTION_EXISTS.  I've greped
> through the header files, but find no reference to it.
> 
> How can I find this function reliably?

CMake macro is right because Visual C++ does not define strcasecmp.
This function is defined by POSIX (not even C99). Visual C++ does not
implement POSIX. For Visual C++, you should look for equivalents, it is:
_stricmp or _strnicmp

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org


More information about the CMake mailing list