[Cmake] Dependency problem

William A. Hoffman bill.hoffman at kitware.com
Tue Mar 4 22:02:35 EST 2003


Well, cmake can either build things in sub directories first, or in the 
current directory.
We picked current directory first to support sub directories that contain 
tests that use
libraries from the parent directory.    If a library does not exist, and 
cmake is being run
the first time, cmake has rules that will jump into the library directory 
can build it the first
time.   However, once the library exists, cmake does not jump into the 
directory and try
a build before using the library.

In short, you will have to move your executable into a sub-directory.

-Bill


At 09:39 PM 3/4/2003 +0000, Filipe Sousa wrote:
>Hi,
>
>I have the following directory struture in my project:
>
>myapp/
>  + banner/
>      banner.h
>      banner.cpp
>      CMakeLists.txt
>  main.cpp
>  CMakeLists.txt
>
>banner CMakeLists.txt:
>ADD_LIBRARY(banner banner.cpp)
>
>main CMakeLists.txt:
>PROJECT(myapp)
>SUBDIRS(banner)
>
>LINK_DIRECTORIES(banner)
>ADD_EXECUTABLE(myapp main.cpp)
>TARGET_LINK_LIBRARIES(myapp banner)
>
>When I compile the project for the first time I get the following output:
>[fsousa at neptuno]$ make
>Building dependencies. cmake.depends...
>Building object file main.o...
>Building dependencies. cmake.depends...
>Building object file banner.o...
>Building static library libbanner.a...
>Building executable myapp...
>/home/fsousa/tmp/myapp/banner: building default_target
>
>If I change the banner.h file and compile again I get the next output:
>[fsousa at neptuno]$ make
>Building dependencies dependlocal...
>Building object file main.o...
>Building executable myapp...
>/home/fsousa/myapp/test/banner: building default_target
>Building dependencies dependlocal...
>Building object file banner.o...
>Building static library libbanner.a...
>
>As you can see first build the executable before the libbanner.a, but the
>right order should be first create the libbanner.a and build the executable
>next.
>
>Is this a bug or I'm missing something?
>
>Thanks.
>--
>Filipe Sousa
>
>
>_______________________________________________
>Cmake mailing list
>Cmake at public.kitware.com
>http://public.kitware.com/mailman/listinfo/cmake






More information about the CMake mailing list