We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2108

Summary: CMake does not set X11 includes properly for sdl2-config and friends
Product: SDL Reporter: Marcus von Appen <mva>
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2    
Version: HG 2.1   
Hardware: All   
OS: All   

Description Marcus von Appen 2013-09-22 08:11:19 UTC
The autotools-based code uses X_CFLAGS and some hackish x_includes code to add some necessary includes to SDL_CFLAGS for proper X11 and OpenGL include handling.

At the moment, the cmake-baed build code does not do that. Below is a patch, which provides the necessary changes to add a proper include to the SDL_CFLAGS.


diff -r 6a145dedc972 cmake/sdlchecks.cmake
--- a/cmake/sdlchecks.cmake	Sat Sep 14 11:25:52 2013 -0700
+++ b/cmake/sdlchecks.cmake	Sun Sep 22 10:06:20 2013 +0200
@@ -304,6 +304,11 @@
       endif()
     endforeach()
 
+    find_path(X_INCLUDEDIR X11/Xlib.h)
+    if(X_INCLUDEDIR)
+      set(X_CFLAGS "-I${X_INCLUDEDIR}")
+    endif()
+
     check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
     check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H)
     check_include_file(X11/extensions/XInput2.h HAVE_XINPUT_H)
@@ -345,6 +350,7 @@
         endif(HAVE_SHMAT)
         if(NOT HAVE_SHMAT)
           add_definitions(-DNO_SHARED_MEMORY)
+          set(X_CFLAGS "${X_CFLAGS} -DNO_SHARED_MEMORY")
         endif(NOT HAVE_SHMAT)
       endif(NOT HAVE_SHMAT)
 
@@ -367,6 +373,8 @@
         endif(HAVE_X11_SHARED)
       endif(X11_SHARED)
 
+      set(SDL_CFLAGS "${SDL_CFLAGS} ${X_CFLAGS}")
+
       set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
       check_c_source_compiles("
           #include <X11/Xlib.h>
Comment 1 Sam Lantinga 2013-10-18 07:50:19 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/4be86f76e710