[CMake] FindSDL

Brad King brad.king at kitware.com
Wed Aug 17 18:11:01 EDT 2005


Asmodehn Shade wrote:
> - Once I have done my "FIND_PACKAGE( SDL REQUIRED )" What should I do
> to add the include and the link directories and libraries ? something,
> or everything should be ready ?

That will just set some CMake variables you can use to add the
include/link options.  Read Modules/FindSDL.cmake to see the set of
variables provided.

> And btw where should I post the bug I can find on a module ?

Any CMake module or other bug can be reported here:

http://www.cmake.org/Bug

> - On windows, there is no actual test for that library. So nothing is
> found, but still the VS project files are created... without the
> dependency. ( I am using last release )

The "REQUIRED" option to the FIND_PACKAGE command is just a hint to the
FindSDL.cmake module.  The command will set SDL_FIND_REQUIRED to "1"
before loading the module.  It is up to the module's implementation to
produce an error if it cannot find SDL.  This is because FIND_PACKAGE
has no idea how to tell whether an arbitrary find module has succeeded.
  Unfortunately not all modules have been updated to support this
REQUIRED feature since it was added.

> Now what I want is : if the library is not found, then try_download it
> and try_build it. Yeah it looks like a dumb package system on windows
> :-) I just want that in the case where there is no other package
> system. if there is, the build mechanism for the package system should
> prevent somehow the "try_download and try_build" from cmake to happen.
> The check for "required" should be done after the try_build...

We have considered trying to implement such a packaging scheme ("CPack")
but there has been no time to do it.  You'll have to hack your own
solution to get try_download to work.

> Let's say that I want to build it like any other dependency with
> cmake. How can I do that ?
> 
> I was thinking about making my own FindSDL.cmake that :
> - call the default one (how ?)

INCLUDE(${CMAKE_ROOT}/Modules/FindSDL.cmake)

> - then check if it has been found or not.

IF(SDL_FOUND)
  ...
ELSE(SDL_FOUND)
  ...
ENDIF(SDL_FOUND)

> - if found, set the usefull variable and return (which variables?)

See current module.

> - If it is not found then I download the source (how ?)

Good luck with this one.  CMake does build a copy of the curl library
which you might be able to use to download things.  This would require a
modified CMake though.

> - copy my CMakelists.txt for SDL to the folder where the source is.
> - build it simply as a dependency.

You should be able to create a subdirectory in your source tree that
references all the SDL sources remotely:

# ... somehow set SDL_SOURCE_DIR ...
ADD_LIBRARY(mysdl ${SDL_SOURCE_DIR}/src1.c ...)

-Brad



More information about the CMake mailing list