[CMake] acyclic subdirectory builds
Amitha Perera
amitha-cmake at thepereras.org
Fri Apr 4 09:55:12 EDT 2008
Bätge wrote:
> ADD_DEPENDENCIES( exea liba )
> ADD_DEPENDENCIES( exeb liba )
That should be TARGET_LINK_LIBRARIES.
Egon: as Stephan says, you want to avoid this include() stuff. That is
only useful some complicated situations. What you want is probably
something like this: (I added a libb for fun.)
/liba/CMakeLists.txt:
...
add_library( liba ... )
...
/libb/CMakeLists.txt
...
add_library( libb ... )
...
/exea/CMakeLists.txt
...
add_executable( exea )
target_link_libraries( exea liba libb )
...
/exeb/CMakeLists.txt
...
add_executable( exeb )
target_link_libraries( exeb liba libb )
...
/CMakeLists.txt
PROJECT( proj )
add_subdirectory( liba )
add_subdirectory( exea )
add_subdirectory( exeb )
(You may be able to to the last step from a proj subdirectory, as you
had in your original email, but I can't remember right now if that is a
2.4.x feature or a 2.6.x feature.)
If you move to CMake 2.6, you can even create self-standing sub-project
solutions. (I think CMake 2.4 doesn't quite do that, but I could be wrong.)
Amitha.
More information about the CMake
mailing list