Skip to content

Commit

Permalink
cmake: Look in popular places for X11 headers, export this info prope…
Browse files Browse the repository at this point in the history
…rly.

Fixes CMake not being able to find X11 on FreeBSD (which generally has the
headers in /usr/local/include/X11).

List of other popular places borrowed from CMake's FindX11 module.

This worked on the configure script because of magic in the AC_PATH_X macro.

Fixes Bugzilla #4815.
  • Loading branch information
icculus committed Jun 24, 2018
1 parent 59574fe commit c70db0c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cmake/sdlchecks.cmake
Expand Up @@ -381,9 +381,21 @@ macro(CheckX11)
FindLibraryAndSONAME("${_LIB}")
endforeach()

find_path(X_INCLUDEDIR X11/Xlib.h)
find_path(X_INCLUDEDIR X11/Xlib.h
/usr/pkg/xorg/include
/usr/X11R6/include
/usr/X11R7/include
/usr/local/include/X11
/usr/include/X11
/usr/openwin/include
/usr/openwin/share/include
/opt/graphics/OpenGL/include
/opt/X11/include
)

if(X_INCLUDEDIR)
set(X_CFLAGS "-I${X_INCLUDEDIR}")
list(APPEND EXTRA_CFLAGS "-I${X_INCLUDEDIR}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${X_INCLUDEDIR}")
endif()

check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
Expand Down Expand Up @@ -420,7 +432,7 @@ macro(CheckX11)
endif()
if(NOT HAVE_SHMAT)
add_definitions(-DNO_SHARED_MEMORY)
set(X_CFLAGS "${X_CFLAGS} -DNO_SHARED_MEMORY")
list(APPEND EXTRA_CFLAGS "-DNO_SHARED_MEMORY")
endif()
endif()

Expand All @@ -439,8 +451,6 @@ macro(CheckX11)
endif()
endif()

set(SDL_CFLAGS "${SDL_CFLAGS} ${X_CFLAGS}")

set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
check_c_source_compiles("
#include <X11/Xlib.h>
Expand Down

0 comments on commit c70db0c

Please sign in to comment.