[CMake] How to differ?

Eric Noulard eric.noulard at gmail.com
Fri Oct 29 10:14:11 EDT 2010


2010/10/29 Thomas Lehmann <t.lehmann at rtsgroup.net>
> Hi,
>
> I’m new to the cmake tool trying to find out how to apply
> this best to our system. Here’s a problem I would like
> to know how to do best:
>
>
>
> Assume following setup:
>
> -          /projects/libs/one
> -          /projects/libs/two
> -          /projects/apps/first
> -          /projects/apps/two
>
> Both application are using both libraries.
>
> Being in /tmp/obj ….

What does this mean "being in /tmp/obj" ?

> I have  some options to prepare a build:
>
> -          cmake /projects   (this means: intending to build all)
> -          cmake /projects/libs (this means: intending to  build all libraries only)
> -          cmake /projects/apps (this means: intending to build all applications)
> -          cmake /projects/apps/first (this means: intending to build app “first” only)
> Now the question(s):
>
> -          Using “build all” is fine. I’m using “link_directories” for both applications.
> But using the last two examples I fail with “cannot find –lone” (and two).
> How can I fix this?
>
> -          I know I could use “include_subdirectory” but then I fail with first and third
> example. I will get a message like “another target with same name already exists”.
> Both question are relating to same.

I think I don't get it.
What do you want to do?

1) Write a single CMake-enabled project with which you may build all
    or part of the project

2) Write several separate CMake-enabled project which are inter-dependant?

I would personnally try 1) unless you have good reason not to do so.
The projects/CMakeLists.txt would be the main project
consisting in some
add_subdirectory(libs/XXXX)
add_subdirectory(apps//YYYY)
then for each lib there will be some
projects/libs/XXXX/CMakeLists.txt consisting in
add_library(XXXX <list of source>) command
and for each app there will be some
projects/apps/YYYY/CMakeLists.txt which contains
add_executable(YYYY <list of source>)
target_link_library(YYYY XXXX)
include_directories(${CMAKE_SOURCE_DIR}/libs/XXXX)

from this structure you should be able to build part or all of the target
just by calling the appropriate one. CMake should take care of building
the dependencies using the "target_link_library" links.

However I may have misunderstood what you want?

Could you tell us what you want and may be send us some CMakeLists.txt
you already tried?


--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list