cmake: Look in popular places for X11 headers, export this info properly.

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.
Ryan C. Gordon 2018-06-24 15:12:18 -04:00
parent 59574fe2f0
commit c70db0cabf
1 changed files with 15 additions and 5 deletions

View File

@ -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)
@ -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()
@ -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>