[cmake-developers] Modern cross-platform buildsystem design requirements

Daniel Pfeifer daniel at pfeifer-mail.de
Wed Sep 10 04:19:19 EDT 2014


Hi Steve,

2014-09-10 0:32 GMT+02:00 Stephen Kelly <steveire at gmail.com>:
>
>
> I wonder what a cmake-based buildsystem would look like for a collection of
> executables/targets which should be built for multiple ...
>

I would generalize even more and finish the sentence with "options at once".
This includes Debug/Release, Shared/Static, PlatformA/PlatformB, etc.


With usage-requirements we now can propagate properties from dependees to
dependents. What about the other direction? Imagine this:

 add_library(foo STATIC foo.cpp)
 add_library(bar SHARED bar.cpp)
 target_link_libraries(bar foo)
 add_executable(myexe main.cpp)
 target_link_libraries(myexe foo)

A static library foo is used both in a shared library and in an executable.
Depending on the platform it should be build twice: once with PIC, once
without.


Another example: We sometimes run code generators as custom buildsteps.

 add_library(foo foo.cpp)
 add_executable(codegen codegen.cpp)
 # set_target_properties(codegen PROPERTIES BUILD_FOR_HOST 1)
 target_link_libraries(codegen foo)
 add_custom_command(OUTPUT source.cpp COMMAND codegen)
 add_executable(myexe source.cpp)
 target_link_libraries(myexe foo)

When crosscompiling, we need the codegenerator for the host platform (This
would need some target property).
But more interestingly, the library foo should be built for both the host
and the target(s).


Thank you for starting that discussion!

-- Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20140910/083d8b05/attachment-0002.html>


More information about the cmake-developers mailing list