[CMake] SDL_LIBRARY_TEMP

E. Wing ewmailing at gmail.com
Tue Sep 12 18:22:36 EDT 2006


> Date: Mon, 11 Sep 2006 15:27:36 -0700
> From: "Brandon J. Van Every" <bvanevery at gmail.com>

> At 06:27 PM 9/11/2006, Brandon J. Van Every wrote:
> >I'm making a casual effort to build the G3D library, which has CMake
> support under development.  It contains:
> >INCLUDE (FindSDL)
> >FIND_PACKAGE(SDL REQUIRED)
> >
> >I have SDL binaries for VS7.1 on my system in E:\devel\vs71\SDL-1.2.11.
> >CMakeSetup complained that it was missing some SDL variables, so I manually
> provided SDL_INCLUDE_DIR and SDLMAIN_LIBRARY.  Things seem to build ok after
> this, although the build breaks somewhere else for G3D reasons, so I'm not
> 100% sure of success here.
> >
> >Anyways, CMake is also looking for SDL_LIBRARY_TEMP.  This is not
> documented.  Googling, it appears to be specific to the CMake FindSDL
> module, and is not any kind of general SDL parameter.  It shows up in
> CMakeSetup as SDL_LIBRARY_TEMP-NOTFOUND.  Leaving it alone doesn't seem to
> cause a problem, but to the user it looks like an error.  If FindSDL is
> creating this variable, shouldn't it initialize it or something?
> >Make it not look suspect.
>
> Yep, that is a bug, most likely from a FIND_* call putting it in the cache.
> You can create a bug entry.
>
> -Bill
>

So I wrote most of the code in that module so I guess I should chime
in. What I was trying to do with the SDL_LIBRARY_TEMP was that some
platforms need to specify more than others on the link line. OS X is
-framework SDL -framework Cocoa, Visual Studio was -lSDL -lSDLmain,
mingw was -lmingw -lSDL -lSDLmain, FreeBSD was -lSDL11 -pthreads -lm,
and so forth.

Since the names and types of the libraries were all variable, I wanted
to unify the build system under CMake so people using the module
wouldn't have to know about all these details. The intention was that
a user only need to use SDL_LIBRARY and SDL_INCLUDE_DIR in their
scripts.

I invented SDL_LIBRARY_TEMP as a private hidden variable that I could
manipulate as needed. The problem I encountered with using SDL_LIBRARY
was that once it was seet by FIND_LIBRARY, any changes I made to it
were never reflected in the ccmake GUI. Even though I changed the
string, it only showed the original set value. This annoys me very
much. So the work-around was to manipulate private variables, and in
one shot, set SDL_LIBRARY at the very end so its value in the GUI
reflected the correct value.

This all used to work for me, but I haven't tried it in Windows
recently with the newest versions of CMake and SDL. But if there is a
cleaner way to pull this all off that doesn't break CMake, I would
like to know about it.

-Eric


More information about the CMake mailing list