Skip to content

cmake: strcasestr detection fails #7026

@sezero

Description

@sezero

Happens with both SDL2 and SDL3: see CI ubuntu configuration logs. In github CI
with android and macos, it seems to detect, though.

Doesn't work for me locally, either.

From my CMakeError.log:

Determining if the strcasestr exist failed with the following output:
Change Dir: /home/sezero/SDL/b/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/gmake" "cmTC_97dce/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_97dce.dir/build.make CMakeFiles/cmTC_97dce.dir/build
gmake[1]: Entering directory `/home/sezero/SDL/b/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_97dce.dir/CheckSymbolExists.c.o
/usr/bin/cc   -idirafter "/home/sezero/SDL/src/video/khronos"    -o CMakeFiles/cmTC_97dce.dir/CheckSymbolExists.c.o   -c /home/sezero/SDL/b/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sezero/SDL/b/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function ‘main’:
/home/sezero/SDL/b/CMakeFiles/CMakeTmp/CheckSymbolExists.c:14: error: ‘strcasestr’ undeclared (first use in this function)
/home/sezero/SDL/b/CMakeFiles/CMakeTmp/CheckSymbolExists.c:14: error: (Each undeclared identifier is reported only once
/home/sezero/SDL/b/CMakeFiles/CMakeTmp/CheckSymbolExists.c:14: error: for each function it appears in.)
gmake[1]: *** [CMakeFiles/cmTC_97dce.dir/CheckSymbolExists.c.o] Error 1
gmake[1]: Leaving directory `/home/sezero/SDL/b/CMakeFiles/CMakeTmp'
gmake: *** [cmTC_97dce/fast] Error 2

File /home/sezero/SDL/b/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <stddef.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <wchar.h>
#include <float.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef strcasestr
  return ((int*)(&strcasestr))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Building that test source as it is does fail indeed, but with -D_GNU_SOURCE=1
it succeeds: We need that define when detecting strcasestr -- or with all of
libc function calls' detection.

I don't have a patch.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions