On 14.07.09 12:08:43, Martin Santa María wrote:
>
> Hello everyone,
>
> I have a design problem. I have a new project consisting on different
> packages. Each package should be built as a library but it could depend on
> libraries generated by other packages. Also there is an executable built from
> some of these libraries:
>
> root/
> CMakeLists.txt -> generates executable with some package libraries
> package1/
> CMakeLists.txt -> generates package1.lib
> package2/
> CMakeLists.txt -> generates package2.lib that depends on package1 library
> and its header files. so it must include root/package1/
>
>
> My problem begins with INCLUDE_DIRECTORIES and LINK_DIRECTORIES.
Don't use link_directories, instead use target_link_libraries and name
the needed targets in there. So for package2/CMakeLists.txt you'd have:
add_library( package2 SHARED <sources> )
target_link_libraries(package2 package1)
For include dirs of package2/CMakeLists.txt you can just do:
include_directories( "${CMAKE_SOURCE_DIRECTORY}/package1" )
> archive this, I think I need to use ADD_SUBDIRECTORY so each sub
Right.
> The problem is that the root CMakeLists.txt should known the list of
> generated libraries and source files so it could make the global
> executable.
Again, you can simply use the target names:
target_link_libraries(rootexec package1 package2 package4 package7)
If the number of libs depends on certain options you can simply build up
a list of actually built targets:
set( LIBS ${package2} )
if(OPTION_FOO)
set( LIBS ${LIBS} package1)
else(OPTION FOO)
set( LIBS ${LIBS} package3)
endif(OPTION_FOO)
Andreas
--
You will triumph over your enemy.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake