create a multi project with kdevelop and cmake

Milian Wolff mail at milianw.de
Tue Jan 17 18:41:57 GMT 2012


On Tuesday 17 January 2012 18:03:29 pasparis at noos.fr wrote:
> Hello
> 
> I am trying to create a multiproject containing several projects libraries
> with KDEvelop4 and CMake.I don't know the exact rules to follow in order to
> set up a multi project library with KDEvelop and CMake: the problem is the
> following
> 
> I would like to have all the project at the same level in a directory.
> the root directory is pKD0 and in pKD0 I create with KDevelop projA (library
> A),projB (library B) etc.. and projMain (executable using the set of
> libraries)

Personally I don't see how this relates to KDevelop. I'd say your problem is 
purely in configuring CMake for this setup. In KDevleop you can just open the 
pKD0 folder as a single directory and it should work as-is. If you do it 
correctly (see below) you should also be able to open any of the subfolders as 
a separate project in KDevelop instead.

> their CMakeList files are
> projA:
> project(proja)
> add_library(proja STATIC cTest.cpp)

If this is a library that should be used outside of the pKD0 folder, you'll 
have to write a FindProjA.cmake and use find_package(ProjA) where it's 
supposed to be used. See also: 
http://www.cmake.org/Wiki/CMake/Tutorials/Packaging

If otoh you are actually talking about a single project (pKD0) that just 
happens to consist of a bunch of libraries and executables, you can make your 
life easier by creating a CMakeLists.txt in the *top* folder and including the 
directories there. I've done this in MassifVisualizer e.g., see for example: 
https://projects.kde.org/projects/extragear/sdk/massif-
visualizer/repository/revisions/master/entry/CMakeLists.txt
also take a look at the other CMakeLists.txt in the subfolders.

> projMain:
> cmake_minimum_required(VERSION 2.8)
> project(projMain)
> add_subdirectory(projA)
> include_directories (${PROJA_SOURCE_DIR}/projA)
> add_executable(projMain main.cpp)
> target_link_libraries(projMain proja)
> 
> I got a message that "projA is not an existing library" and when I put
> add_subdirectory(/pascal/pKD0/projA) I get "no rule to make target"

the subdirectoy projA is not inside projMain folder, so this will of course 
not work. Rather, use find_package or the above way I used in massif-
visualizer.

> this works when projA is under ProjMain directory, but when I add a new
> project under the ProjMain KDEvelop put it both outside and under the
> projmain
> 
> I don't know hown to organise the multiproject directories with KDevelop and
> CMake, thank you in advance if someone could clarrify this point pascal

Again, nothing to do with KDevelop. Look at existing projects that use CMake 
and emulate them. KDevelop itself btw. is also a good example for that, as 
KDevplatform is also "just" a bunch of libraries which get linked into the 
plugins and KDevelop executable.

Bye
-- 
Milian Wolff
mail at milianw.de
http://milianw.de




More information about the KDevelop mailing list