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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index b822c7a..b62c20f 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -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>