[Kde-games-devel] Question about CMakeLists.txt design

Andreas Beckermann b_mann at gmx.de
Tue Apr 18 16:52:58 CEST 2006


On Tuesday 18 April 2006 16:27, Dmitry Suzdalev wrote:
> Hello kde-game-devels! :)

Hi

> Today I tried to run kpat (trunk version) and quickly figured out that it
> misses installed carddecks from 'libkdegames/carddecks'.

And while trying to convert boson to cmake, I figured out why (see below) :-)

> So they need to be added to corresponding CMakeLists.txt.
> Old Makefile.am (which located in libkdegames/carddecks) just looped
> through all carddecks's subdirectories and installed all png's it
> found there.
>
> The question is:
> Should I write CMakeLists.txt which behaves like that
> Makefile.am (loops) and which resides in libkdegames/carddecks, 

Well, this may be not so easy, as cmake lacks a "install whole directory" 
target. I believe that's the reason why the carddecks are not yet ported to 
cmake.

> or should I 
> prefer more 'modular' approach and write CMakeLists.txt in _each_
> deck's subdirectory (so the libkdegames/carddecks/CmakeLists.txt
> contains only add_subdirectory statements)?

I would go for this one, yes. For boson something like this worked pretty 
well:
in libkdegames/carddecks/CMakeLists.txt:
set(base_dir ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(default)
...

in libkdegames/carddecks/<subdirectrory>/CMakeLists.txt:
file(RELATIVE_PATH current_dir ${base_dir} ${CMAKE_CURRENT_SOURCE_DIR}
set(install_dir <install_prefix>/${current_dir}
install_files(${install_dir} .*\\.png)

where <install_prefix> is probably something 
like /opt/kde/share/apps/carddecks (maybe something like 
${KDE_DATA_INSTALL_DIR}/carddecks)

That CMakeLists.txt file in <subdirectory> can now be copied without 
modification to every other carddeck directory.

Well, I'd probably do something like that :-)

> Hope, I made my question clear, sorry for not very perfect English ;).
>
> And, btw, is
> include_directories(${KDE_BLA_BLA_BLA} ${CMAKE_BLA_BLA}...)
> needed in png-install-only CMakeLists.txt?
> I've already seen a couple of such CMakeLists.txt (and keeped this
> statement in those written by myself as I didn't know whether it's really
> needed ;) )

include_directories() adds directories to the list of paths where headers are 
searched. I.e. it adds a "-I<include_directory>" to the compiler lines.
You don't need this at all, if you don't compile anything in that 
CMakeLists.txt file.

> Cheers,
> Dmitry.

CU
Andi


More information about the kde-games-devel mailing list