[CMake] Component-based FindSDL.cmake

Pablo Odorico pablo.odorico at gmail.com
Sat Oct 7 00:29:34 EDT 2006


This is my first approach to the component-based SDL package.

It includes my previous modification of FindSDL*.cmake files and some new code 
to manage components.

# Locates the SDL library treating auxiliary libraries as components:
# 
# SDL_image: IMAGE
# SDL_mixer: MIXER
# SDL_sound: SOUND
# SDL_net:   NET
# SDL_ttf:   TTF
# 
# This module defines:
# 
# SDL_FOUND
# SDL_LIBRARY
# SDL_INCLUDE_DIR
# 
# SDL_{COMPONENT}_FOUND
# SDL_{COMPONENT}_LIBRARY
# SDL_{COMPONENT}_INCLUDE_DIR
# 
# as required by: 
http://www.cmake.org/cgi-bin/viewcvs.cgi/Modules/readme.txt?root=CMake&view=markup
(and all uppercase names)

FindSDL.cmake: (as always feel free to use/modify/ignore it)
http://download.bblug.usla.org.ar/FindSDL.cmake

Example CMakeLists.txt:
http://download.bblug.usla.org.ar/CMakeLists.txt

The output of the example in my system:
-- WARNING: WRONGCOMPONENT is not a component of package SDL
>> SDL
   SDL_FOUND: YES
   SDL_LIBRARY: /usr/lib64/libSDLmain.a;/usr/lib64/libSDL.so;-lpthread
   SDL_INCLUDE_DIR: /usr/include/SDL

>> IMAGE
   SDL_IMAGE_FOUND: YES
   SDL_IMAGE_LIBRARY: /usr/lib64/libSDL_image.so
   SDL_IMAGE_INCLUDE_DIR: /usr/include/SDL

>> MIXER
   SDL_MIXER_FOUND: YES
   SDL_MIXER_LIBRARY: /usr/lib64/libSDL_mixer.so
   SDL_MIXER_INCLUDE_DIR: /usr/include/SDL

>> NET
   SDL_NET_FOUND: YES
   SDL_NET_LIBRARY: /usr/lib64/libSDL_net.so
   SDL_NET_INCLUDE_DIR: /usr/include/SDL

>> SOUND
   SDL_SOUND_FOUND: YES
   SDL_SOUND_LIBRARY: /usr/lib64/libSDL_sound.so
   SDL_SOUND_INCLUDE_DIR: /usr/include/SDL

>> TTF
   SDL_TTF_FOUND: YES
   SDL_TTF_LIBRARY: /usr/lib64/libSDL_ttf.so
   SDL_TTF_INCLUDE_DIR: /usr/include/SDL
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pablo/Proj/cmake

Some questions now:
  - Can't QUIET be used with components?
  - _all_ components have to be REQUIRED?
This FindSDL.cmake supports SDL_FIND_REQUIRED_{COMPONENT} and 
SDL_FIND_QUIETLY_{COMPONENT}

-pablo

-- 
Pablo Odorico
http://pablo.etype.com.ar/


More information about the CMake mailing list