CMake-based build system for SDL2

Dear all,

as discussed elsewhere, there are ideas to create a cmake-based build
system for SDL2. Find my very own attempt for it attached to this mail.

The script is in a state to build static and shared SDL2 libraries on
BSD and Linux systems. The resulting libraries were not tested yet and
the script will be refined over the next days (and weeks).

Apply the patch with

patch -p1 < /location/of/cmake_20120817.diff

Afterwards create an off-source build directory, so we do not clutter the
HG checkout and run cmake:

mkdir build

cd build

cmake …

[cmake output ahead]

Once executed successfully, you are presented with a set of SDL2 compile
and runtime options that were detected, enabled or disabled. The script
closely resembles the configure script logic when detecting SDL2
options.

To enable or disable certain options, provide a -D:BOOL=ON|OFF
flag (below an example for disabling the video subsystem):

cmake -DVIDEO:BOOL=OFF …

You can find the supported options near the top of the CMakeLists.txt
file. You also can use the ccmake utility for a curses-based interface
that presents you the configurable options or cmake-gui for a
GUI-based interface, depending on how it is installed on your OS.

Known issues:

  • configure/autotools internally use several defaults that can vary
    depending on platforms. Their usefulness will be evaluated and take
    into consideration later on
  • X11 vidmode and screensaver support detection seems to have a small
    glitch, depending on the X11 version and installation - those should
    be fixed soon
  • dlopen options might behave differently from configure - I could not
    find out the intended logic from the configure script (see the TODO
    in CMakeLists.txt)
  • mprotect check might not work as supposed
    [- different option scenarios were not thoroughly tested yet]
  • SDL2.pc, SDL2.spec and sdl-config might contain errors
  • no installation support yet

If you run into issues with the script or output, please provide the
following information:

  • console output
  • CMakeFiles/CMakeError.log
  • CMakeFiles/CMakeOutput.log
  • exact OS version and versions of the installed depdendencies to be used

Note that CMakeFiles/CMakeError.log and CMakeFiles/CMakeOutput.log might
contain sensitive information about the environment. If you are working
in a company with policies limiting/restricting those information, make
sure to strip them from the files beforehand.

Cheers
Marcus
-------------- next part --------------
A non-text attachment was scrubbed…
Name: cmake_20120817.diff
Type: text/x-diff
Size: 78568 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120818/937534c3/attachment.diff
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120818/937534c3/attachment.pgp

It’s just a comment, but there’s an on going effort in cmake to use a
NON SHOUTING SYNTAX and use lower case for all directives (see the
recent cmake dev discussions about code freeze). It makes for much
nicer cmake files; since this is the direction cmake is going, perhaps
doing that would make sense here?~
Doug.

On Sat, Aug 18, 2012 at 6:39 AM, Marcus von Appen wrote:

Dear all,

as discussed elsewhere, there are ideas to create a cmake-based build
system for SDL2. Find my very own attempt for it attached to this mail.

The script is in a state to build static and shared SDL2 libraries on
BSD and Linux systems. The resulting libraries were not tested yet and
the script will be refined over the next days (and weeks).

Apply the patch with

patch -p1 < /location/of/cmake_20120817.diff

Afterwards create an off-source build directory, so we do not clutter the
HG checkout and run cmake:

mkdir build

cd build

cmake …

[cmake output ahead]

Once executed successfully, you are presented with a set of SDL2 compile
and runtime options that were detected, enabled or disabled. The script
closely resembles the configure script logic when detecting SDL2
options.

To enable or disable certain options, provide a -D:BOOL=ON|OFF
flag (below an example for disabling the video subsystem):

cmake -DVIDEO:BOOL=OFF …

You can find the supported options near the top of the CMakeLists.txt
file. You also can use the ccmake utility for a curses-based interface
that presents you the configurable options or cmake-gui for a
GUI-based interface, depending on how it is installed on your OS.

Known issues:

  • configure/autotools internally use several defaults that can vary
    depending on platforms. Their usefulness will be evaluated and take
    into consideration later on
  • X11 vidmode and screensaver support detection seems to have a small
    glitch, depending on the X11 version and installation - those should
    be fixed soon
  • dlopen options might behave differently from configure - I could not
    find out the intended logic from the configure script (see the TODO
    in CMakeLists.txt)
  • mprotect check might not work as supposed
    [- different option scenarios were not thoroughly tested yet]
  • SDL2.pc, SDL2.spec and sdl-config might contain errors
  • no installation support yet

If you run into issues with the script or output, please provide the
following information:

  • console output
  • CMakeFiles/CMakeError.log
  • CMakeFiles/CMakeOutput.log
  • exact OS version and versions of the installed depdendencies to be used

Note that CMakeFiles/CMakeError.log and CMakeFiles/CMakeOutput.log might
contain sensitive information about the environment. If you are working
in a company with policies limiting/restricting those information, make
sure to strip them from the files beforehand.

Cheers
Marcus


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Marcus, I’ll peek at this tonight when I have some time :)On Sat, Aug 18, 2012 at 5:12 AM, Doug <douglas.linder at gmail.com> wrote:

It’s just a comment, but there’s an on going effort in cmake to use a
NON SHOUTING SYNTAX and use lower case for all directives (see the
recent cmake dev discussions about code freeze). It makes for much
nicer cmake files; since this is the direction cmake is going, perhaps
doing that would make sense here?

~
Doug.

On Sat, Aug 18, 2012 at 6:39 AM, Marcus von Appen wrote:

Dear all,

as discussed elsewhere, there are ideas to create a cmake-based build
system for SDL2. Find my very own attempt for it attached to this mail.

The script is in a state to build static and shared SDL2 libraries on
BSD and Linux systems. The resulting libraries were not tested yet and
the script will be refined over the next days (and weeks).

Apply the patch with

patch -p1 < /location/of/cmake_20120817.diff

Afterwards create an off-source build directory, so we do not clutter the
HG checkout and run cmake:

mkdir build

cd build

cmake …

[cmake output ahead]

Once executed successfully, you are presented with a set of SDL2 compile
and runtime options that were detected, enabled or disabled. The script
closely resembles the configure script logic when detecting SDL2
options.

To enable or disable certain options, provide a -D:BOOL=ON|OFF
flag (below an example for disabling the video subsystem):

cmake -DVIDEO:BOOL=OFF …

You can find the supported options near the top of the CMakeLists.txt
file. You also can use the ccmake utility for a curses-based interface
that presents you the configurable options or cmake-gui for a
GUI-based interface, depending on how it is installed on your OS.

Known issues:

  • configure/autotools internally use several defaults that can vary
    depending on platforms. Their usefulness will be evaluated and take
    into consideration later on
  • X11 vidmode and screensaver support detection seems to have a small
    glitch, depending on the X11 version and installation - those should
    be fixed soon
  • dlopen options might behave differently from configure - I could not
    find out the intended logic from the configure script (see the TODO
    in CMakeLists.txt)
  • mprotect check might not work as supposed
    [- different option scenarios were not thoroughly tested yet]
  • SDL2.pc, SDL2.spec and sdl-config might contain errors
  • no installation support yet

If you run into issues with the script or output, please provide the
following information:

  • console output
  • CMakeFiles/CMakeError.log
  • CMakeFiles/CMakeOutput.log
  • exact OS version and versions of the installed depdendencies to be used

Note that CMakeFiles/CMakeError.log and CMakeFiles/CMakeOutput.log might
contain sensitive information about the environment. If you are working
in a company with policies limiting/restricting those information, make
sure to strip them from the files beforehand.

Cheers
Marcus


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Dear all,

an updated version of the CMake-based build system is available, which
adresses the following issues:

  • proper -m machine flag handling for LLVM/CLang compilers
  • use libtool-like library versioning
  • X11 vidmode and screensaver detection works properly now
  • fixed DirectFB detection
  • fixed FusionSound detection
  • use lower-case directives as suggested by Doug
  • [untested] basic installation support

Known issues:

  • configure/autotools internally use several defaults that can vary
    depending on platforms. Their usefulness will be evaluated and take
    into consideration later on
  • dlopen options might behave differently from configure - I could not
    find out the intended logic from the configure script (see the TODO
    in CMakeLists.txt)
  • mprotect check might not work as supposed
    [- different option scenarios were not thoroughly tested yet]
  • SDL2.pc, SDL2.spec and sdl-config might contain errors

You can find the patch at

http://www.sysfault.org/tmp/cmake_20120818.diff

Cheers
Marcus
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120818/717e12c8/attachment.pgp

an updated version of the CMake-based build system is available, which
adresses the following issues:

This is very exciting stuff, I can’t wait to dig into it!

–ryan.

Working great for me. I particularly like:

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR “Prevented in-tree built. This is bad practice.”)
endif()

Yes, so complete agree~ :slight_smile:

Couple of other comments:

  1. Similarly to lowercase syntax, preferred end*() syntax is no
    expression in the closing block. It just make maintaining files easier
    (if you have if(XXX && YYY) and endif(XXX && YYY) you have to make two
    changes every time you touch the statement; ending with endif() is
    better unless you have nasty un-nested if statements with no
    indentation).

  2. As one of the irritating things about cmake UNIX matches for osx,
    so you probably want to put your blocks either as:

if(APPLE)

elseif(UNIX)

endif()

or

if(UNIX AND NOT APPLE)

endif()

  1. Also seems you missed the file/cocoa .m files, and the frameworks
    to link against.

Patch attached.~
Doug.

On Sat, Aug 18, 2012 at 9:14 PM, Marcus von Appen wrote:

Dear all,

an updated version of the CMake-based build system is available, which
adresses the following issues:

  • proper -m machine flag handling for LLVM/CLang compilers
  • use libtool-like library versioning
  • X11 vidmode and screensaver detection works properly now
  • fixed DirectFB detection
  • fixed FusionSound detection
  • use lower-case directives as suggested by Doug
  • [untested] basic installation support

Known issues:

  • configure/autotools internally use several defaults that can vary
    depending on platforms. Their usefulness will be evaluated and take
    into consideration later on
  • dlopen options might behave differently from configure - I could not
    find out the intended logic from the configure script (see the TODO
    in CMakeLists.txt)
  • mprotect check might not work as supposed
    [- different option scenarios were not thoroughly tested yet]
  • SDL2.pc, SDL2.spec and sdl-config might contain errors

You can find the patch at

http://www.sysfault.org/tmp/cmake_20120818.diff

Cheers
Marcus


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-------------- next part --------------
— CMakeLists.txt 2012-08-20 10:04:21.000000000 +0800
+++ …/CMakeLists.txt 2012-08-20 10:03:32.000000000 +0800
@@ -64,7 +64,7 @@
# TODO: validate this
set(WINDOWS_CE TRUE)
endif()
-elseif(UNIX)
+elseif(UNIX AND NOT APPLE)
if(CMAKE_SYSTEM_NAME MATCHES “.Linux")
set(LINUX TRUE)
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.
”)
@@ -150,6 +150,13 @@
option(${_OPT} “Enable the ${_SUB} subsystem” ON)
endforeach()

+# Don’t mistake osx for unix
+if (UNIX AND NOT APPLE)

  • set(UNIX_SYS ON)
    +else()
  • set(UNIX_SYS OFF)
    +endif()

option_string(ASSERTIONS “Enable internal sanity checks (auto/disabled/release/enabled/paranoid)” “auto”)
set_option(DEPENDENCY_TRACKING “Use gcc -MMD -MT dependency tracking” ON)
set_option(LIBC “Use the system C library” ON)
@@ -170,24 +177,24 @@
set_option(VIDEO_DUMMY “Use dummy video driver” ON)
set_option(VIDEO_OPENGL “Include OpenGL support” ON)
set_option(VIDEO_OPENGLES “Include OpenGL ES support” ON)
-set_option(PTHREADS “Use POSIX threads for multi-threading” ${UNIX})
+set_option(PTHREADS “Use POSIX threads for multi-threading” ${UNIX_SYS})
dep_option(PTHREADS_SEM “Use pthread semaphores” ON “PTHREADS” OFF)
set_option(SDL_DLOPEN “Use dlopen for shared object loading” ON)
-set_option(OSS “Support the OSS audio API” ${UNIX})
-set_option(ALSA “Support the ALSA audio API” ${UNIX})
+set_option(OSS “Support the OSS audio API” ${UNIX_SYS})
+set_option(ALSA “Support the ALSA audio API” ${UNIX_SYS})
dep_option(ALSA_SHARED “Dynamically load ALSA audio support” ON “ALSA” OFF)
-set_option(ESD “Support the Enlightened Sound Daemon” ${UNIX})
+set_option(ESD “Support the Enlightened Sound Daemon” ${UNIX_SYS})
dep_option(ESD_SHARED “Dynamically load ESD audio support” ON “ESD” OFF)
-set_option(PULSEAUDIO “Use PulseAudio” ${UNIX})
+set_option(PULSEAUDIO “Use PulseAudio” ${UNIX_SYS})
dep_option(PULSEAUDIO_SHARED “Dynamically load PulseAudio support” ON “PULSEAUDIO” OFF)
-set_option(ARTS “Support the Analog Real Time Synthesizer” ${UNIX})
+set_option(ARTS “Support the Analog Real Time Synthesizer” ${UNIX_SYS})
dep_option(ARTS_SHARED “Dynamically load aRts audio support” ON “ARTS” OFF)
-set_option(NAS “Support the NAS audio API” ${UNIX})
-set_option(RPATH “Use an rpath when linking SDL” ${UNIX})
+set_option(NAS “Support the NAS audio API” ${UNIX_SYS})
+set_option(RPATH “Use an rpath when linking SDL” ${UNIX_SYS})
set_option(CLOCK_GETTIME “Use clock_gettime() instead of gettimeofday()” OFF)
-set_option(INPUT_EVENTS “Use Linux 2.4 unified input interface” ${UNIX})
-set_option(INPUT_TSLIB “Use the Touchscreen library for input” ${UNIX})
-set_option(VIDEO_X11 “Use X11 video driver” ${UNIX})
+set_option(INPUT_EVENTS “Use Linux 2.4 unified input interface” ${UNIX_SYS})
+set_option(INPUT_TSLIB “Use the Touchscreen library for input” ${UNIX_SYS})
+set_option(VIDEO_X11 “Use X11 video driver” ${UNIX_SYS})
dep_option(X11_SHARED “Dynamically load X11 support” ON “VIDEO_X11” OFF)
set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
foreach(_SUB ${SDL_X11_OPTIONS})
@@ -523,7 +530,7 @@
endif(VIDEO)

Platform-specific options and settings

-if(UNIX)
+if(UNIX AND NOT APPLE)
if(AUDIO)
if(SYSV5 OR SOLARIS OR HPUX)
set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
@@ -812,6 +819,24 @@
endif(MINGW OR CYGWIN)
endif(HAVE_WINCE)
elseif(APPLE)
+

  • Apple frameworks

  • include_directories(/System/Library/Frameworks)
  • find_library(CARBON_LIBRARY Carbon)
  • find_library(FORCEFEEDBACK ForceFeedback)
  • find_library(COCOA_LIBRARY Cocoa)
  • find_library(OpenGL_LIBRARY OpenGL)
  • find_library(COREAUDIO CoreAudio)
  • find_library(AUDIOUNIT AudioUnit)
  • find_library(AUDIOTOOLBOX AudioToolbox)
  • find_library(IOKIT IOKit)
  • set(EXTRA_LIBS ${CARBON_LIBRARY} ${COCOA_LIBRARY} ${OpenGL_LIBRARY} ${COREAUDIO} ${AUDIOUNIT} ${AUDIOTOOLBOX} ${IOKIT})
  • Cocoa file support

  • file(GLOB EXTRA_SOURCES ${PROJECT_SOURCE_DIR}/src/file/cocoa/*.m)
  • set(SOURCE_FILES ${EXTRA_SOURCES} ${SOURCE_FILES})
  • set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
  • iOS hack needed - http://code.google.com/p/ios-cmake/ ?

    if(VIDEO)
    CheckCOCOA()

Doug <douglas.linder at gmail.com>:

  1. Similarly to lowercase syntax, preferred end*() syntax is no
    expression in the closing block. It just make maintaining files easier
    (if you have if(XXX && YYY) and endif(XXX && YYY) you have to make two
    changes every time you touch the statement; ending with endif() is
    better unless you have nasty un-nested if statements with no
    indentation).

I find the endif(MEH) close blocks quite helpful for developing the scripts
and finding issues with mismatched if()s on refactoring - even though the
maintenance is a bit higher. The readability suffers from that, though. I
think that once most parts become stable enough, those checks can be removed.

  1. As one of the irritating things about cmake UNIX matches for osx,
    so you probably want to put your blocks either as:

if(APPLE)

elseif(UNIX)

endif()

or

if(UNIX AND NOT APPLE)

endif()

I was unaware of that, thanks.

  1. Also seems you missed the file/cocoa .m files, and the frameworks
    to link against.

Patch attached. c

I did not miss them - I just have no knowledge about them :-). Do you mind to
check, if they are integrated correctly? Right now it seems that e.g. Cocoa
is always linked in, even if the user chooses VIDEO_COCOA=OFF or VIDEO=OFF.
Same for the sound libraries, etc.

I merged your patch and will post an updated version of the scripts later on
today.

Cheers
Marcus

Dear all,

another updated version of the CMake-based build system is available, which
adresses the following issues:

  • several minor fixes
  • CFLAGS and LDFLAGS environment flag support
  • reduce cmake FindXXX dependencies to a minimum (FindX11.cmake) to
    allow custom CFLAGS and LDFLAGS
    NOTE: this forces the user to set them to e.g. include /usr/local
    properly. For cross-compiling however it is necessary to have enough
    flexibility, which FindXXX.cmake usually does not give us
  • installation support (including OS-specific SDL_config_XXXX.h files
    for now)
  • sdl2.pc and sdl2-config files are properly created now
  • started with Win32/VS.NET support by incorporating
    SDL_config_windows.h into SDL_config.h
  • changed subsystem knobs to be prefixed with SDL_ (e.g. SDL_TIMERS
    instead of TIMERS) to avoid name clashes (SDL_FILE vs. cmake’s FILE)
  • improved MacOS X support (from Doug, thanks!)

Known issues:

  • configure/autotools internally use several defaults that can vary
    depending on platforms. Their usefulness will be evaluated and take
    into consideration later on
  • dlopen options might behave differently from configure - I could not
    find out the intended logic from the configure script (see the TODO
    in CMakeLists.txt)
  • mprotect check might not work as supposed
    [- different option scenarios were not thoroughly tested yet]

You can find the patch at

http://www.sysfault.org/tmp/cmake_20120821.diff

Cheers
Marcus
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120821/ff5f9371/attachment.pgp

Great stuff!

Re: frameworks always linking in --> Ah, hadn’t considered that. Yeah,
good point. I’ll have a look at it and try to get them only linking if
you build the related component. (Probably as a set of if(HAVE_XXX)
inside the existing if(APPLE) block).

I’m not actually sure if Carbon is even required… I just put it in
there because it was in the automake config.~
Doug.

On Aug 21, 2012 7:12 PM, wrote:

Doug <@Doug1>:

  1. Similarly to lowercase syntax, preferred end*() syntax is no
    expression in the closing block. It just make maintaining files easier
    (if you have if(XXX && YYY) and endif(XXX && YYY) you have to make two
    changes every time you touch the statement; ending with endif() is
    better unless you have nasty un-nested if statements with no
    indentation).

I find the endif(MEH) close blocks quite helpful for developing the scripts
and finding issues with mismatched if()s on refactoring - even though the
maintenance is a bit higher. The readability suffers from that, though. I
think that once most parts become stable enough, those checks can be removed.

  1. As one of the irritating things about cmake UNIX matches for osx,
    so you probably want to put your blocks either as:

if(APPLE)

elseif(UNIX)

endif()

or

if(UNIX AND NOT APPLE)

endif()

I was unaware of that, thanks.

  1. Also seems you missed the file/cocoa .m files, and the frameworks
    to link against.

Patch attached. c

I did not miss them - I just have no knowledge about them :-). Do you mind to
check, if they are integrated correctly? Right now it seems that e.g. Cocoa
is always linked in, even if the user chooses VIDEO_COCOA=OFF or VIDEO=OFF.
Same for the sound libraries, etc.

I merged your patch and will post an updated version of the scripts later on
today.

Cheers
Marcus


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hm, this should do it (patch attached).

There’s a bit of weird stuff in there though; the haptic
implementation depends on the joystick implementation, you can’t have
one without the other.

There’s also no way to link at all without linking against cocoa,
since the file implementation depends on it.

I’m also not quite sure I’ve got the opengl stuff linking right… but
it seems to work for me.~
Doug.

On Wed, Aug 22, 2012 at 9:06 AM, Doug <@Doug1> wrote:

Great stuff!

Re: frameworks always linking in --> Ah, hadn’t considered that. Yeah,
good point. I’ll have a look at it and try to get them only linking if
you build the related component. (Probably as a set of if(HAVE_XXX)
inside the existing if(APPLE) block).

I’m not actually sure if Carbon is even required… I just put it in
there because it was in the automake config.

~
Doug.

On Aug 21, 2012 7:12 PM, wrote:

Doug <@Doug1>:

  1. Similarly to lowercase syntax, preferred end*() syntax is no
    expression in the closing block. It just make maintaining files easier
    (if you have if(XXX && YYY) and endif(XXX && YYY) you have to make two
    changes every time you touch the statement; ending with endif() is
    better unless you have nasty un-nested if statements with no
    indentation).

I find the endif(MEH) close blocks quite helpful for developing the scripts
and finding issues with mismatched if()s on refactoring - even though the
maintenance is a bit higher. The readability suffers from that, though. I
think that once most parts become stable enough, those checks can be removed.

  1. As one of the irritating things about cmake UNIX matches for osx,
    so you probably want to put your blocks either as:

if(APPLE)

elseif(UNIX)

endif()

or

if(UNIX AND NOT APPLE)

endif()

I was unaware of that, thanks.

  1. Also seems you missed the file/cocoa .m files, and the frameworks
    to link against.

Patch attached. c

I did not miss them - I just have no knowledge about them :-). Do you mind to
check, if they are integrated correctly? Right now it seems that e.g. Cocoa
is always linked in, even if the user chooses VIDEO_COCOA=OFF or VIDEO=OFF.
Same for the sound libraries, etc.

I merged your patch and will post an updated version of the scripts later on
today.

Cheers
Marcus


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
-------------- next part --------------
— …/CMakeLists.txt 2012-08-23 22:20:45.000000000 +0800
+++ CMakeLists.txt 2012-08-23 22:21:25.000000000 +0800
@@ -647,6 +647,7 @@
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
set(HAVE_SDL_JOYSTICK TRUE)
endif(LINUX)

  • endif(SDL_JOYSTICK)

    CheckPTHREAD()
    @@ -863,37 +864,92 @@
    elseif(APPLE)

    TODO: rework this for proper MacOS X, iOS and Darwin support

  • Apple frameworks

  • include_directories(/System/Library/Frameworks)
  • find_library(CARBON_LIBRARY Carbon)
  • find_library(FORCEFEEDBACK ForceFeedback)
  • find_library(COCOA_LIBRARY Cocoa)
  • find_library(OpenGL_LIBRARY OpenGL)
  • find_library(COREAUDIO CoreAudio)
  • find_library(AUDIOUNIT AudioUnit)
  • find_library(AUDIOTOOLBOX AudioToolbox)
  • find_library(IOKIT IOKit)
  • list(APPEND EXTRA_LIBS ${CARBON_LIBRARY} ${COCOA_LIBRARY} ${OpenGL_LIBRARY}
  • ${COREAUDIO} ${AUDIOUNIT} ${AUDIOTOOLBOX} ${IOKIT})
  • Cocoa file support

  • Requires the darwin file implementation

    if(SDL_FILE)
    file(GLOB EXTRA_SOURCES ${PROJECT_SOURCE_DIR}/src/file/cocoa/*.m)
    set(SOURCE_FILES ${EXTRA_SOURCES} ${SOURCE_FILES})
    set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
    set(HAVE_SDL_FILE TRUE)
  • endif(SDL_FILE)
  • set(SDL_FRAMEWORK_COCOA 1)

  • else()

  • message(FATAL_ERROR “SDL_FILE must be enabled to build on MacOS X”)

  • endif()

  • if(SDL_AUDIO)

  • set(MACOSX_COREAUDIO 1)

  • file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)

  • set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})

  • set(HAVE_SDL_AUDIO TRUE)

  • set(SDL_FRAMEWORK_COREAUDIO 1)

  • set(SDL_FRAMEWORK_AUDIOUNIT 1)

  • endif()

  • if(SDL_JOYSTICK)

  • set(SDL_JOYSTICK_IOKIT 1)

  • file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)

  • set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})

  • set(HAVE_SDL_JOYSTICK TRUE)

  • set(SDL_FRAMEWORK_IOKIT 1)

  • set(SDL_FRAMEWORK_FF 1)

  • endif()

  • if(SDL_HAPTIC)

  • set(SDL_HAPTIC_IOKIT 1)

  • file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)

  • set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})

  • set(HAVE_SDL_HAPTIC TRUE)

  • set(SDL_FRAMEWORK_IOKIT 1)

  • set(SDL_FRAMEWORK_FF 1)

  • if(NOT SDL_JOYSTICK)

  •  message(FATAL_ERROR "SDL_HAPTIC requires SDL_JOYSTICK to be enabled")
    
  • endif()

  • endif()

  • if(SDL_POWER)

  • set(SDL_POWER_MACOSX 1)

  • file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)

  • set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})

  • set(HAVE_SDL_POWER TRUE)

  • set(SDL_FRAMEWORK_CARBON 1)

  • set(SDL_FRAMEWORK_IOKIT 1)

  • endif()

  • Actually load the frameworks at the end so we don’t duplicate include.

  • if(SDL_FRAMEWORK_COCOA)

  • find_library(COCOA_LIBRARY Cocoa)

  • list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})

  • endif()

  • if(SDL_FRAMEWORK_IOKIT)

  • find_library(IOKIT IOKit)

  • list(APPEND EXTRA_LIBS ${IOKIT})

  • endif()

  • if(SDL_FRAMEWORK_FF)

  • find_library(FORCEFEEDBACK ForceFeedback)

  • list(APPEND EXTRA_LIBS ${FORCEFEEDBACK})

  • endif()

  • if(SDL_FRAMEWORK_CARBON)

  • find_library(CARBON_LIBRARY Carbon)

  • list(APPEND EXTRA_LIBS ${CARBON_LIBRARY})

  • endif()

  • if(SDL_FRAMEWORK_COREAUDIO)

  • find_library(COREAUDIO CoreAudio)

  • list(APPEND EXTRA_LIBS ${COREAUDIO})

  • endif()

  • if(SDL_FRAMEWORK_AUDIOUNIT)

  • find_library(AUDIOUNIT AudioUnit)

  • list(APPEND EXTRA_LIBS ${AUDIOUNIT})

  • endif()

    iOS hack needed - http://code.google.com/p/ios-cmake/ ?

    if(SDL_VIDEO)
    CheckCOCOA()
    if(VIDEO_OPENGL)

  •  # TODO: Use FIND_PACKAGE(OpenGL) instead
     set(SDL_VIDEO_OPENGL 1)
     set(SDL_VIDEO_OPENGL_CGL 1)
     set(SDL_VIDEO_RENDER_OGL 1)
     if(DARWIN)
    
  •    list(APPEND EXTRA_LDFLAGS "-Wl,-framework,OpenGL")
    
  •    find_library(OpenGL_LIBRARY OpenGL)
    
  •    list(APPEND EXTRA_LIBRARIES ${OpenGL_LIBRARY})
     endif(DARWIN)
     set(HAVE_VIDEO_OPENGL TRUE)
    
    endif(VIDEO_OPENGL)
    @@ -922,8 +978,10 @@
    if(NOT HAVE_SDL_JOYSTICK)

    configure.in puts this into a if test enable_XXX = yes - do we need that?

    set(SDL_JOYSTICK_DISABLED 1)
  • file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/dummy/*.c)
  • set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
  • if(NOT APPLE) # on OSX this results in unresolved symbols.
  • file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/dummy/*.c)
  • set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
  • endif()
    endif(NOT HAVE_SDL_JOYSTICK)
    if(NOT HAVE_SDL_HAPTIC)
    set(SDL_HAPTIC_DISABLED 1)

Doug <douglas.linder at gmail.com>:

Hm, this should do it (patch attached).

Thanks! I’ll include it asap.

There’s a bit of weird stuff in there though; the haptic
implementation depends on the joystick implementation, you can’t have
one without the other.

I stumbled across that on Win32, too. It looks like the joystick-specific
parts for haptic are not enclosed in a #if !SDL_JOYSTICK_DISABLED conditional.
Same for SDL_VIDEO and SDL_LOADSO, since all the Win32 IME stuff relies on
LoadObject().

Cheers
Marcus

Dear all,

just another updated version of the CMake-based build system is
available, which adresses the following issues:

  • removed FindX11.cmake dependency for cross-compile environments
  • Win32/VS.NET support operational now
  • fixed some subsystem depdencies for Mac OS X, Win32 and Unix
    platforms by issuing a fatal error, which warns the user about those
  • even more improved MacOS X support with proper 3rd party dependency
    handling (once more Doug, thanks a lot!)

Known issues:

  • dlopen options might behave differently from configure - I could not
    find out the intended logic from the configure script (see the TODO
    in CMakeLists.txt)
    @Ryan, Sam: what’s the intended behaviour in configure.in?

  • the GCC stack boundary preference adopted from configure.in does not
    seem to work on 64-bit platforms (reproducible in both, configure
    and cmake) with gcc version 4.2.1 20070831:

    error: -mpreferred-stack-boundary=2 is not between 4 and 12

    @Ryan, Sam: would it be safe to set it to 4 or is it targeting
    32-bit archs mostly?

  • some minor issues with subsystem dependencies remain, which need to
    be fixed on the source code level and are valid for every build, be
    it configure, VS.NET, cmake or whatever. Patches will go into
    Bugzilla within the next days.

  • Win32 assembler flags are not aware of any configuration knobs yet,
    this needs to be fixed on the source code level. Patches will go into
    Bugzilla within the next days.

You can find the patch at

http://www.sysfault.org/tmp/cmake_20120823.diff

Unix-like platforms, when it comes to building the core
library. According to Doug, most stuff seems to work properly on OS X,
too. Everyone interested in it, please give it a try with your typical
build scenario and let me know, if there are any issues.

The cmake build system coexists in a friendly way with the existing
configure, VisualC or XCode build types. It does not modify any files
that would be modified by them, so you should not run into trouble with
parallel build attempts.

Cheers
Marcus
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120823/14b66c00/attachment.pgp>From my perspective, about 90 percent are done for Win32 and most

Dear all,

another updated version for the CMake-based build system is available,
which adresses the following issues:

  • fixed dlopen() detection on several Linux-based systems.
  • changed LIBC option default for MinGW/MSSYS-based builds

You can find the patch at

http://www.sysfault.org/tmp/cmake_20120827.diff

So far it has been successfully tested on

  • FreeBSD (amd64 & i386)
  • Linux (Arch 64-bit, Debian 32-bit, Ubuntu 64-bit)
  • Windows XP SP3, 32- and 64-bit, VS.NET 2010
  • Windows 7 64-bit, VS.NET 2010, MinGW, Msys

Cheers
Marcus
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120827/e31a56c3/attachment.pgp

It’s just a tiny thing, but I was trying to build the DLL without the
static lib today and it threw an error; those target_link_libraries()
should be inside the if block I think…

index f8b7cfb…982fb41 100644
— a/deps/sdl/SDL/CMakeLists.txt
+++ b/deps/sdl/SDL/CMakeLists.txt
@@ -1171,8 +1171,8 @@ if(SDL_SHARED)
VERSION ${SDL_VERSION}
SOVERSION ${LT_CURRENT})
set(_INSTALL_LIBS “SDL2” ${_INSTALL_LIBS})

  • target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
    endif(SDL_SHARED)
    -target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})

if(SDL_STATIC)
add_library(SDL2-static STATIC ${SOURCE_FILES})
@@ -1180,8 +1180,8 @@ if(SDL_STATIC)

TODO: Win32 platforms keep the same suffix .lib for import and static

libraries - do we need to consider this?

set(_INSTALL_LIBS “SDL2-static” ${_INSTALL_LIBS})

  • target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
    endif(SDL_STATIC)
    -target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})~
    Doug.

On Tue, Aug 28, 2012 at 1:03 AM, Marcus von Appen wrote:

Dear all,

another updated version for the CMake-based build system is available,
which adresses the following issues:

  • fixed dlopen() detection on several Linux-based systems.
  • changed LIBC option default for MinGW/MSSYS-based builds

You can find the patch at

http://www.sysfault.org/tmp/cmake_20120827.diff

So far it has been successfully tested on

  • FreeBSD (amd64 & i386)
  • Linux (Arch 64-bit, Debian 32-bit, Ubuntu 64-bit)
  • Windows XP SP3, 32- and 64-bit, VS.NET 2010
  • Windows 7 64-bit, VS.NET 2010, MinGW, Msys

Cheers
Marcus


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

On, Thu Sep 13, 2012, Doug wrote:

It’s just a tiny thing, but I was trying to build the DLL without the
static lib today and it threw an error; those target_link_libraries()
should be inside the if block I think…

index f8b7cfb…982fb41 100644
— a/deps/sdl/SDL/CMakeLists.txt
+++ b/deps/sdl/SDL/CMakeLists.txt
@@ -1171,8 +1171,8 @@ if(SDL_SHARED)
VERSION ${SDL_VERSION}
SOVERSION ${LT_CURRENT})
set(_INSTALL_LIBS “SDL2” ${_INSTALL_LIBS})

  • target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
    endif(SDL_SHARED)
    -target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})

if(SDL_STATIC)
add_library(SDL2-static STATIC ${SOURCE_FILES})
@@ -1180,8 +1180,8 @@ if(SDL_STATIC)

TODO: Win32 platforms keep the same suffix .lib for import and static

libraries - do we need to consider this?

set(_INSTALL_LIBS “SDL2-static” ${_INSTALL_LIBS})

  • target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
    endif(SDL_STATIC)
    -target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})

Fixed in the most recent version, thanks!

Cheers
Marcus
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120919/a07daf41/attachment.pgp

Dear all,

another updated version for the CMake-based build system is available,
which includes the following changes:

  • removed Windows CE support as of recent SDL2 commits
  • fixed a minor issue with building only the shared OR static library

You can find the patch at

http://www.sysfault.org/tmp/cmake_20120919.diff

Also, there is a bug tracker entry at

http://bugzilla.libsdl.org/show_bug.cgi?id=1597

to which further updates will be posted (instead of this list).

Cheers
Marcus
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120919/2252d847/attachment.pgp

Thanks Marcus!On Wed, Sep 19, 2012 at 1:33 AM, Marcus von Appen wrote:

Dear all,

another updated version for the CMake-based build system is available,
which includes the following changes:

  • removed Windows CE support as of recent SDL2 commits
  • fixed a minor issue with building only the shared OR static library

You can find the patch at

http://www.sysfault.org/tmp/cmake_20120919.diff

Also, there is a bug tracker entry at

http://bugzilla.libsdl.org/show_bug.cgi?id=1597

to which further updates will be posted (instead of this list).

Cheers
Marcus


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org