cmake: Look in popular places for X11 headers, export this info properly.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 24 Jun 2018 15:12:18 -0400
changeset 12030c0c4ba22a685
parent 12029 dfebed374d73
child 12031 b6c4568cc10b
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.
cmake/sdlchecks.cmake
     1.1 --- a/cmake/sdlchecks.cmake	Sun Jun 24 13:57:22 2018 -0400
     1.2 +++ b/cmake/sdlchecks.cmake	Sun Jun 24 15:12:18 2018 -0400
     1.3 @@ -381,9 +381,21 @@
     1.4          FindLibraryAndSONAME("${_LIB}")
     1.5      endforeach()
     1.6  
     1.7 -    find_path(X_INCLUDEDIR X11/Xlib.h)
     1.8 +    find_path(X_INCLUDEDIR X11/Xlib.h
     1.9 +        /usr/pkg/xorg/include
    1.10 +        /usr/X11R6/include
    1.11 +        /usr/X11R7/include
    1.12 +        /usr/local/include/X11
    1.13 +        /usr/include/X11
    1.14 +        /usr/openwin/include
    1.15 +        /usr/openwin/share/include
    1.16 +        /opt/graphics/OpenGL/include
    1.17 +        /opt/X11/include
    1.18 +    )
    1.19 +
    1.20      if(X_INCLUDEDIR)
    1.21 -      set(X_CFLAGS "-I${X_INCLUDEDIR}")
    1.22 +      list(APPEND EXTRA_CFLAGS "-I${X_INCLUDEDIR}")
    1.23 +      list(APPEND CMAKE_REQUIRED_INCLUDES "${X_INCLUDEDIR}")
    1.24      endif()
    1.25  
    1.26      check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
    1.27 @@ -420,7 +432,7 @@
    1.28          endif()
    1.29          if(NOT HAVE_SHMAT)
    1.30            add_definitions(-DNO_SHARED_MEMORY)
    1.31 -          set(X_CFLAGS "${X_CFLAGS} -DNO_SHARED_MEMORY")
    1.32 +          list(APPEND EXTRA_CFLAGS "-DNO_SHARED_MEMORY")
    1.33          endif()
    1.34        endif()
    1.35  
    1.36 @@ -439,8 +451,6 @@
    1.37          endif()
    1.38        endif()
    1.39  
    1.40 -      set(SDL_CFLAGS "${SDL_CFLAGS} ${X_CFLAGS}")
    1.41 -
    1.42        set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
    1.43        check_c_source_compiles("
    1.44            #include <X11/Xlib.h>