[CMake] cmake 2.6.0, breakages

Andreas Pakulat apaku at gmx.de
Sat May 17 12:45:46 EDT 2008


On 17.05.08 18:06:11, Dmitry Marakasov wrote:
> --- CMakeLists.txt begins here ---
> # project name
> PROJECT(Memonix)
> 
> # 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.

> # 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)
> 
> ADD_DEFINITIONS(${SDL_CFLAGS})
> ADD_EXECUTABLE(Memonix ${memonix_SRCS})
> TARGET_LINK_LIBRARIES(Memonix ${SDL_LIBS} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${OPENGL_gl_LIBRARY} ${GLU_LIBRARY})
> ---
> 
> Seems cleaner but that's more lines as well.

Its not a workaround, its the correct thing to do.

> 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.

Andreas

-- 
Tuesday is the Wednesday of the rest of your life.


More information about the CMake mailing list