[CMake] does CMake have "usage targets" like Premake?
Lance Luvaul
lance at mso.anu.edu.au
Tue Jan 17 09:36:24 EST 2012
I think cmake's find_package is only a first order approximation to
premake's usages. What usage library targets have that find_package
doesn't is the ability to cleanly inject dependency info (like include
dirs or link libraries) into any target that claims to be dependent on
the library. This is achieved simply by having the target call "uses
<library>"... there is no need for the target to explicitly add anything
to target_link_libraries() or include_directories().
I guess it's a bit like calling include_directories() twice, once in the
CMakeLists.txt for the library and again in the CMakeLists.txt file for
the target using the library, but then you'd need to have the latter
include() the former for it to work (as having target
add_subdirectory(library) wouldn't have the same accumulative effect).
But for accumulating all linker objects together, this wouldn't work
(that is, having target call target_link_libraries() on its binaries
then include()'ing another file defining library which calls
target_link_libraries() for its binaries). Target would have to either
add something via target_link_libraries() or call
add_dependencies(target library).
I guess the crux of it is that target shouldn't have to concern itself
with library's business. It should be library's job to add library's
header paths to include_directories(), or its binaries to
target_link_libraries(). Target should only add its own header paths
and binaries. It's the whole 'separation of concerns' or 'modular
object programming paradigm' argument.
I guess I'd say usages seem to be like a combination of
include_directories, add_dependencies and target_link_libraries, but
done in a more succinct way and put in their proper place. Apart from
the succinctness, can this be done in CMake?
On 16/01/2012 11:54 PM, Yuri Timenkov wrote:
>
> if i understand correctly it's CMake's find_package analog.
>
> On Jan 16, 2012 10:41 AM, "Lance Luvaul" <lance at mso.anu.edu.au
> <mailto:lance at mso.anu.edu.au>> wrote:
>
> See
> http://sourceforge.net/tracker/index.php?func=detail&aid=2794681&group_id=71616&atid=531880
> <http://sourceforge.net/tracker/index.php?func=detail&aid=2794681&group_id=71616&atid=531880>
> for more detail on what constitutes a usage-target. How can I
> achieve the same result in CMake? Thanks.
> --
>
> Powered by www.kitware.com <http://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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120118/9b19b708/attachment.htm>
More information about the CMake
mailing list