[CMake] cmake 2.6.0, breakages

Dmitry Marakasov amdmi3 at amdmi3.ru
Sun May 18 18:06:51 EDT 2008


* Andreas Pakulat (apaku at gmx.de) wrote:

> > # depends
> > set(SDL_CONFIG "sdl-config" CACHE STRING "Path to sdl-config script")
> Thats broken by design, what if sdl-config is not in my PATH?

> > FIND_PACKAGE(SDL REQUIRED)
> > FIND_PACKAGE(SDL_image REQUIRED)
> > FIND_PACKAGE(SDL_mixer REQUIRED)
> And why do the above modules not set proper variables, which would allow
> you to completely get rid of sdl-config calls. If they don't they should
> be fixed.
I didn't bother finding out actually, that was quick and dirty
CMakeLists.txt. My point was that cmake's SDL module doesn't use
sdl-config at all, but the latter provides more than just include
directory and library to link.

Compare CMake's SDL variables:
SDL_INCLUDE_DIRS=/usr/local/include/SDL
SDL_LIBRARY=/usr/local/lib/libSDLmain.a;/usr/local/lib/libSDL.so;-lpthread

to 
sdl-config --libs:
-L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL -pthread
sdl-config --cflags:
-I/usr/local/include/SDL -I/usr/local/include -D_GNU_SOURCE=1 -D_REENTRANT

So I thought it would be safer to use sdl-config and let user specify
path to in if it's not in $PATH.

> > # targets
> > ADD_DEFINITIONS(`${SDL_CONFIG} --cflags`)
> I think that this works with cmake 2.4 is a bug in cmake and not
> intentional.

> > EXEC_PROGRAM(${SDL_CONFIG} ARGS "--cflags" OUTPUT_VARIABLE SDL_CFLAGS)
> > EXEC_PROGRAM(${SDL_CONFIG} ARGS "--libs" OUTPUT_VARIABLE SDL_LIBS)
> Its not a workaround, its the correct thing to do.
Got it, thanks.

> > CMakeFiles/Memonix.dir/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.o
> > gets into project object files (seems like it's because
> > CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp gets into GLOB_RECURSE.
> > That's obviously undesired.
> Right, then don't use GLOB_RECURSE when you use srcdir == builddir. In
> fact, don't use srcdir == builddir unless you have good reasons. Apart
> from that you could as well just list all the files in the project in a
> variable, instead of using GLOB.
Agreed. But I still see it as a bug that cmake uses srcdir ==
builddir AND includes it's own files into glob when doing GLOB.

Btw, I didn't find a way to change builddir in documentation. I've done
that once in my own project (and got some problems with Qt, since
generated includes went to build/ and were not included from other
source files), but now I cannot recall it.

So how do I make all cmake-generated and output files go to build/ if
project directory layout is like this:

CMakeLists.txt
src/
build/

-- 
Dmitry A. Marakasov    | jabber: amdmi3 at jabber.ru
amdmi3 at amdmi3.ru       | http://www.amdmi3.ru


More information about the CMake mailing list