[CMake] Automatic Building of dependencies
William A. Hoffman
billlist at nycap.rr.com
Thu May 4 11:28:32 EDT 2006
At 09:49 AM 5/4/2006, Thomas.Voss at rub.de wrote:
>Hi,
>
>I've just started using cmake for building my projects and encountered the following
>problem:
>
>Assume the following dir structure:
>
>Toplevel
> |
> ----Application 1
> |
> ----cmake
> |
> ----CMakeLists.txt
> |
> ----Library 1
> |
> ----cmake
> |
> ----CMakeLists.txt
> |
> ----Library 2
> |
> ----cmake
> |
> ----CMakeLists.txt
>
>The libraries depend on qt and include header-files that need to be processed by moc.
>
>How Do I tell cmake in the CMakeLists.txt of "Application 1" that it should build the
>libraries according to the CMakeLists.txt found in the library-specific cmake subdirs?
>
>ADD_SUBDIRECTORY() doesn't work as the moc_* files aren't generated.
Something like this should work:
ADD_SUBDIRECTORY(Library1)
ADD_SUBDIRECTORY(Library2)
ADD_SUBDIRECTORY(Application1)
The CMakeLists.txt file in Application1 should be something like this:
ADD_EXECUTABLE(Application1 ....)
# tell the application to link to the libraries
# this will cause the libraries to be built before the application
# and the moc files should be generated as by-product of that build
TARGET_LINK_LIBRARIES(Application1 Library1 Library2)
-Bill
More information about the CMake
mailing list