Find modules are only for third-party libraries. Boost should only provide config packages, and then update cmake’s FindBoost to use boost’s cmake config packages.
> A CMake-based
> application
> could point to it and, instead of using the system Boost libraries, Boost
> targets would be built from source as part of the user build.
> * The built Boost **binaries** would also provide a compatible, drop-in
> replacement for the 'FindBoost' module distributed with CMake. The
> behavior
> is similar to the previous bullet, except the built binaries would be used
> instead of the source code.
> * The style of the 'CMakeLists.txt' files would follow current best
> practice.
> We'd resist the temptation to write macros which replace the core CMake
> functions. There would be repetition in the files, to be sure, but I
> think we
> should avoid attempting to innovate CMake. I've seen this fail on many
> occasions and would like to keep our goal focused, at this point, on
> migrating Boost to CMake. In the future we could revisit this.
Although, somewhat outdated, and incorrect in places, this repo has an example of building boost with proper cmake support:
https://github.com/boost-cmake/boost-cmake
However, I find this brittle and error-prone. Here’s an example of cmake for Boost.Fusion:
https://github.com/boost-cmake/boost-cmake/blob/master/listsfiles/libs/fusion/CMakeLists.txt
This doesn’t even handle fusion's dependencies, and it is a little incorrect.
I have been working on cmake modules to handle this, but I am in the process of refactoring it, here:
https://github.com/boost-cmake/bcm
One way the Boost.Fusion could be written is like this using the modules to generate the cmake package config:
bcm_setup_version(VERSION ${BOOST_VERSION})
find_package(boost_config)
find_package(boost_core)
find_package(boost_function_types)
find_package(boost_functional)
find_package(boost_mpl)
find_package(boost_preprocessor)
find_package(boost_static_assert)
find_package(boost_tuple)
find_package(boost_type_traits)
find_package(boost_typeof)
find_package(boost_utility)
add_library(boost_fusion INTERFACE)
add_library(boost::fusion ALIAS boost_fusion)
set_property(TARGET boost_fusion PROPERTY EXPORT_NAME fusion)
target_link_libraries(boost_fusion INTERFACE
boost::config
boost::core
boost::function_types
boost::functional
boost::mpl
boost::preprocessor
boost::static_assert
boost::tuple
boost::type_traits
boost::typeof
boost::utility
)
bcm_install_targets(TARGETS boost_fusion INCLUDE include)
bcm_auto_export(TARGETS boost_fusion
DEPENDS
PACKAGE boost_config
PACKAGE boost_core
PACKAGE boost_function_types
PACKAGE boost_functional
PACKAGE boost_mpl
PACKAGE boost_preprocessor
PACKAGE boost_static_assert
PACKAGE boost_tuple
PACKAGE boost_type_traits
PACKAGE boost_typeof
PACKAGE boost_utility
)
However, with dependencies this is not maintainable. But perhaps a `bcm_boost_depends` can handle this, like this:
bcm_setup_version(VERSION ${BOOST_VERSION})
add_library(boost_fusion INTERFACE)
add_library(boost::fusion ALIAS boost_fusion)
set_property(TARGET boost_fusion PROPERTY EXPORT_NAME fusion)
bcm_boost_depends(boost_fusion INTERFACE
boost_config
boost_core
boost_function_types
boost_functional
boost_mpl
boost_preprocessor
boost_static_assert
boost_tuple
boost_type_traits
boost_typeof
boost_utility
)
bcm_install_targets(TARGETS boost_fusion INCLUDE include)
bcm_auto_export(TARGETS boost_fusion)
This is the direction I would like to take the modules, and I think this is much more maintainable. Code repetition is not good, and just boost has innovated C++, I see no reason it couldn’t help innovate cmake. Especially, since these modules do no stray from what standard cmake does.
> * There would be a list of CMake guidelines that we'd use.
> * Boost libraries should be buildable in isolation and use
> 'find_package(Boost...)' to discover their Boost dependencies.
I am just wondering how this would work. In general, this would require all the libraries to be built together. I don’t think libraries individually can provide components.
> * We would work with CMake towards eventually taking over maintenance of the
> FindBoost module distributed with CMake.
Each library should provide its own package of the form `find_package(boost_*)`, and the we can update the cmake to search for those components first and then fallback on the guessing games.
>
> I see this progressing with several milestones.
>
> 1. Release of a CMake-buildable Boost and the CMake conventions. In this
> stage
> each Boost library can be built in isolation or with the entire
> distribution
Sans circular dependencies. As libraries which have circular dependencies will always have to be built with the entire distribution, but hopefully having modularing building might push authors to fix the cycles.
> and all the 'FindBoost' functionality mentioned above would be
> incorporated.
Wouldn’t we need to update `FindBoost` in cmake so this would work?
I'd rather not tie cmakification of Boost to innovating CMake, at least not
at the outset. I think you have some good ideas in your bcm library, but
I'd like to see wider industry adoption before switching Boost to them. I
don't like the risk involved.
> > * There would be a list of CMake guidelines that we'd use.
> > * Boost libraries should be buildable in isolation and use
> > 'find_package(Boost...)' to discover their Boost dependencies.
>
> I am just wondering how this would work. In general, this would require
> all the libraries to be built together. I don’t think libraries
> individually can provide components.
>
It doesn't require all the libraries to be built together and, yes,
libraries can provide components. See this talk:
https://www.youtube.com/watch?v=3eH4hMKl7XE
>
> > * We would work with CMake towards eventually taking over maintenance of
> the
> > FindBoost module distributed with CMake.
>
> Each library should provide its own package of the form
> `find_package(boost_*)`, and the we can update the cmake to search for
> those components first and then fallback on the guessing games.
>
Hrm. Maybe.
>
> >
> > I see this progressing with several milestones.
> >
> > 1. Release of a CMake-buildable Boost and the CMake conventions. In this
> > stage
> > each Boost library can be built in isolation or with the entire
> > distribution
>
> Sans circular dependencies. As libraries which have circular dependencies
> will always have to be built with the entire distribution, but hopefully
> having modularing building might push authors to fix the cycles.
>
Yeah, sans circular dependencies.
>
> > and all the 'FindBoost' functionality mentioned above would be
> > incorporated.
>
> Wouldn’t we need to update `FindBoost` in cmake so this would work?
>
No, I don't think so.
Sorry, that was worded poorly. Rather a library can not add additional components to a previously installed library(not without some strange hackery).
>
> On Jun 16, 2017, at 11:51 PM, David Sankel <cam...@gmail.com> wrote:
>
>
>
> On Sat, Jun 17, 2017 at 12:27 AM, P F <pfu...@yahoo.com> wrote:
>
>>
>> > On Jun 16, 2017, at 6:44 PM, David Sankel via Boost <
>> bo...@lists.boost.org> wrote:
>>
>>
>
>> > * There would be a list of CMake guidelines that we'd use.
>> > * Boost libraries should be buildable in isolation and use
>> > 'find_package(Boost...)' to discover their Boost dependencies.
>>
>> I am just wondering how this would work. In general, this would require
>> all the libraries to be built together. I don’t think libraries
>> individually can provide components.
>>
>
> It doesn't require all the libraries to be built together and, yes,
> libraries can provide components. See this talk: https://www.youtube.com/
> watch?v=3eH4hMKl7XE
>
>
>
> Sorry, that was worded poorly. Rather a library can not add additional
> components to a previously installed library(not without some strange
> hackery).
>
Ah, I see what you mean now. I didn't mean to imply we should support that
use case.
None of the find modules do this, nor do libraries that provide config cmake. In fact, the video shows a lot of non-standard ways of using cmake, which is what you are proposing we avoid, and I agree with.
> This is, indeed, the only way to write packages that can be built with already-installed binaries or together with the source code of their dependencies.
But you never write packages, rather you ignore the packages, like this:
set(as_subproject Foo)
macro(find_package)
if(NOT "${ARG0}" IN_LIST as_subproject)
_find_package(${ARGV})
endif()
endmacro()
add_subdirectory(Foo)
add_subdirectory(App)
This makes `find_package(Foo)` do nothing as `Foo::Foo` is part of the project. This way projects can be written to support both modular and superproject build without changing the build scripts, and without needing to use `if(NOT TARGET)` hacks.
> It is a very important property to have in a build system for large-scale development.
It is very important for boost to be able to support `add_subdirectory` builds. However, hijacking `find_package` to call `add_subdirectory` is the wrong approach and goes against cmake’s workflow. The approach I outlined is what is presented in Daniel Pfeifer’s Effective Cmake talk(although I was aware of this before Daniel’s talk).
I'm mostly in agreement with Paul here.
You may however also be in agreement too David. Here are some cmake use
cases:
1. I want a library from a Boost release, so find_package(boost 1.60
MODULE COMPONENTS asio REQUIRED), link to boost::asio
2. I am making a new Boost library or I am using Boost trunk source
tree. So add_subdirectory(boost/libs/asio EXCLUDE_FROM_ALL), link to
boost::asio
3. There is a third use case pre-C++11 Boost libraries can't do which is
to mix some release Boost libraries from find_package with some brought
in by add_subdirectory() from a source tree. You may wish to rule out
supporting that, but equally, a correct cmake implementation should
implement that just fine.
I do agree David that cmake innovation is to be avoided right now. I
have a superb cmake innovation at the library formerly known as
boost-lite and now called quickcpplib because it lets you write state of
the art C++ libraries super-quick by eliminating needing to think about
build or test or tooling or documentation or CI scripting, just supply
the config file and go, the cmake inspects its environment and automates
everything thereafter. It's really amazing. But it also is very
experimental, and insufficiently tested. And it has several serious bugs
I haven't got to fixing yet.
So don't innovate cmake. Just use 100% standard cmake 3.5, and make sure
it is a *good neighbour* to other cmake and is not *anti-social* like
most cmake currently written today. Design the cmake to be usable as
build and discovery drivers by other cmake. This is the key improvement
in cmake 3 - being nice to **any** other cmake.
I'd recommend a minimum of cmake 3.5. You can create header only library
targets and >= 3.5 those work right without bugs. You can create static
and dynamic library targets for those libraries which implement those. I
would personally suggest a Python script which parses Jamfile.v2 and
spits out a CMakeLists.txt. You'd get 80% of Boost.Build easily enough
using just this.
You just then need to feed everything to the cmake package tooling,
again all 100% cmake 3. And you should be done, no cmake innovation needed.
As Edward pointed out, not everything Boost.Build can do will work in
cmake without cmake innovation. But worry about that after, for end
users of Boost they almost certainly have no need nor want for any of
the stuff beyond already described. Indeed one argument could be "don't
move Boost to cmake, *package* Boost releases with auto-generated cmake
build support". That would make for happy end users.
Niall
--
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
We will need to update cmake so that it finds boost config packages. Or the user can say `find_package(boost_asio)`.
>
> 2. I am making a new Boost library or I am using Boost trunk source
> tree. So add_subdirectory(boost/libs/asio EXCLUDE_FROM_ALL), link to
> boost::asio
No, the `add_subdirectory` is for a superproject. A library will just call `find_package`(which the superproject will override) to get the targets.
>
> 3. There is a third use case pre-C++11 Boost libraries can't do which is
> to mix some release Boost libraries from find_package with some brought
> in by add_subdirectory() from a source tree. You may wish to rule out
> supporting that, but equally, a correct cmake implementation should
> implement that just fine.
There is no reason why that can’t be supported. You only setup `find_package` to ignore the packages that are part of the build and then call `find_package` as you normally would for libraries that aren’t being built.
>
>
> I do agree David that cmake innovation is to be avoided right now. I
> have a superb cmake innovation at the library formerly known as
> boost-lite and now called quickcpplib because it lets you write state of
> the art C++ libraries super-quick by eliminating needing to think about
> build or test or tooling or documentation or CI scripting, just supply
> the config file and go, the cmake inspects its environment and automates
> everything thereafter. It's really amazing. But it also is very
> experimental, and insufficiently tested. And it has several serious bugs
> I haven't got to fixing yet.
>
> So don't innovate cmake. Just use 100% standard cmake 3.5, and make sure
> it is a *good neighbour* to other cmake and is not *anti-social* like
> most cmake currently written today. Design the cmake to be usable as
> build and discovery drivers by other cmake. This is the key improvement
> in cmake 3 - being nice to **any** other cmake.
>
> I'd recommend a minimum of cmake 3.5.
I agree we should use cmake 3.5 as a baseline, as that is what comes with ubuntu 16.04.
> You can create header only library
> targets and >= 3.5 those work right without bugs. You can create static
> and dynamic library targets for those libraries which implement those.
We need to generate the cmake config package. And that includes the dependencies. Libraries like Hana can “cheat” and export the targets directly to the cmake config package because it has no dependencies. However, for a library like Boost.Fusion the dependencies will need to be listed a third time in the cmake config.
> I
> would personally suggest a Python script which parses Jamfile.v2 and
> spits out a CMakeLists.txt. You'd get 80% of Boost.Build easily enough
> using just this.
We can generate the code with python, which will help with libraries that have lots of dependencies. Although some libraries like Boost.Config is not so simple.
>
> You just then need to feed everything to the cmake package tooling,
> again all 100% cmake 3. And you should be done, no cmake innovation needed
The BCM modules aren’t trying to work or redefine the cmake workflow, rather it is tool to help reduce the boilerplate needed to provide cmake support in libraries like boost. Otherwise we will have authors create their own set of functions to make the build scripts more maintainable, and then we will lose consistency among boost libraries.
>
> As Edward pointed out, not everything Boost.Build can do will work in
> cmake without cmake innovation. But worry about that after, for end
> users of Boost they almost certainly have no need nor want for any of
> the stuff beyond already described. Indeed one argument could be "don't
> move Boost to cmake, *package* Boost releases with auto-generated cmake
> build support". That would make for happy end users.
It would be nice to not just support cmake, but pkgconfig as well. There are many times I need to use boost in non-cmake projects, so having pkgconfig would be helpful as well.
Sorry, I skipped over that part. The bcm_ macros are another boost library that would be installed and found with `find_package`. I was just trying to transform the code I linked to, but ideally, it would written like this:
find_package(BCM)
find_package(boost_config) # Use main boost version version
bcm_setup_version(VERSION ${BOOST_CONFIG_VERSION})
add_library(boost_fusion INTERFACE)
add_library(boost::fusion ALIAS boost_fusion)
set_property(TARGET boost_fusion PROPERTY EXPORT_NAME fusion)
bcm_boost_depends(boost_fusion INTERFACE
boost_config
boost_core
boost_function_types
boost_functional
boost_mpl
boost_preprocessor
boost_static_assert
boost_tuple
boost_type_traits
boost_typeof
boost_utility
)
bcm_install_targets(TARGETS boost_fusion INCLUDE include)
bcm_auto_export(TARGETS boost_fusion)
>
CMake's syntax is verbose, which makes it much more friendly to pickup. Bjam’s syntax is too terse with too many weird quirks that most authors just copy and paste code.
>
> I do think CMake is broken in it's core, because it doesn't build but create a description (i.e. makefile or similar). And in order to change that I have to clear the cache and reconstruct it. Boost.build on the other hand works like a charm if I have a proper build description and write `b2 toolset=gcc toolset=msvc` - it will build both and test on both without any conflicts.
You would just create two separate build trees for each configuration. I don’t see how that makes CMake broken.
> I think we should definitely keep boost.build around, if only to have it's concepts (as in meta-targets) in a working build-system. I also don't think CMake will be around forever, it's a deficient solution.
A lot of autotools projects are moving to cmake. I don’t see them moving the Boost.Build. Boost.Build doesn’t have the support that cmake does.
> As ist boost.build, but boost.build gets the job done for boost. I don't see the point of moving from one deficient tool to a worse one, just because everybody seems to be using it.
I don’t think it does get the job done. Some boost libraries do more extensive testing in cmake than in the Boost.Build because it doesn’t get the job done. Some libraries have auto-generated tests and files because Boost.Build doesn’t get the job done. Even more so, downstream projects have to reverse engineer the dependencies because Boost.Build doesn’t get the job done.
On 06/17/2017 07:57 AM, P F via Boost wrote:
>
> I don’t think it does get the job done. Some boost libraries do more extensive testing in cmake than in the Boost.Build because it doesn’t get the job done.
Are you talking about things like this:
https://github.com/boostorg/hana/blob/master/cmake/TestHeaders.cmake
Boost.Build implementation:
https://github.com/boostorg/units/blob/develop/test_headers/Jamfile.v2
In Christ,
Steven Watanabe
You mean dependency. Like boost is for end user programs.
A significant minority of end users will not wish to use find_package()
and will strongly prefer to use add_subdirectory(). For example, anyone
on Windows will find add_subdirectory() vastly easier going. Anyone who
currently integrates Boost into their own build and test config will use
add_subdirectory(). Anyone who builds Boost with custom config will use
add_subdirectory().
Well written cmake 3 has no problem allowing that. It's now a build
driver, any external cmake can load it in and ask it for as much or as
little build config as necessary. It's why cmake 3 is so radically
better than cmake 2. Stephen did an amazing job in restructuring cmake
to be reusable by other cmake. CMakeLists.txt is just a library now, to
be consumed by other cmake scripts. If you keep CMakeLists.txt
completely free of custom function and macro baggage, your
CMakeLists.txt becomes extremely reusable and modular for all other cmake.
>> You can create header only library targets and >= 3.5 those work
>> right without bugs. You can create static and dynamic library
>> targets for those libraries which implement those.
>
> We need to generate the cmake config package. And that includes the
> dependencies. Libraries like Hana can “cheat” and export the targets
> directly to the cmake config package because it has no dependencies.
> However, for a library like Boost.Fusion the dependencies will need
> to be listed a third time in the cmake config.
You don't need to generate the cmake config package. cmake generates the
cmake config package using its knowledge of how to build the code. I
don't know where you're getting all this complexity from.
A correct implementation doesn't need anybody to "cheat". It should be
100% modern cmake. If anybody needs to cheat, you've done it wrong.
>> I would personally suggest a Python script which parses Jamfile.v2
>> and spits out a CMakeLists.txt. You'd get 80% of Boost.Build easily
>> enough using just this.
>
> We can generate the code with python, which will help with libraries
> that have lots of dependencies. Although some libraries like
> Boost.Config is not so simple.
I don't know what you're talking about. cmake tracks dependencies just
fine and can export dependencies into things which consume targets.
>> You just then need to feed everything to the cmake package
>> tooling, again all 100% cmake 3. And you should be done, no cmake
>> innovation needed
>
> The BCM modules aren’t trying to work or redefine the cmake workflow,
> rather it is tool to help reduce the boilerplate needed to provide
> cmake support in libraries like boost. Otherwise we will have authors
> create their own set of functions to make the build scripts more
> maintainable, and then we will lose consistency among boost
> libraries.
If there is a single custom function in what is implemented, then it's
being done wrong. cmake 3.5 and later comes with substantial runtime
facilities obviating the need for macros and custom functions for most
end users. Just use what comes built into cmake.
I appreciate all the work you've done with the BCM cmake modules. I
respectfully insist that all that is superfluous in a minimum viable
cmake 3.5 implementation. I appreciate what you are saying about the
boilerplate issue, but if you require cmake 3.5 minimum, I do not
believe any significant boilerplate issue should occur.
(Where the difference between mine and your approach stems from is that
cmake is scriptable i.e. you can write programs in cmake which run over
a source tree and do housekeeping using "cmake -P" (sometimes "ctest -S"
is easier/better). These scripts can talk with git and pregenerate
boilerplate that in cmake v2 days would be hidden inside macros. They
can also install themselves into githooks so they regenerate boilerplate
when you do git checkout and so on.
A classic boilerplate to generate is lists of source files to save
CMakeLists.txt having to specify it. Another classic cmake script is for
Appveyor and Travis run per commit as cmake is portable and actually
pretty powerful as a programming language.)
So tl;dr; I strongly recommend placing all cmake complexity into
runnable scripts which generate .cmake files to be include()d to avoid
boilerplate, and keep the CMakeLists.txt etc completely free of any
custom macros or functions. This greatly reduces the learning curve for
library developers, keeps the cmake clean for end users to import into
their cmake, and of course keeps build and configure times very quick.
Niall
--
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Yes cmake supports `add_subdirectory` without needing to changing the project scripts. Only the superproject overrides the `find_package`. That is, I write `MyLib` which depends on Foo, like this using `find_package`(ignoring installation for now):
find_package(Foo 2.0 REQUIRED)
add_library(MyLib)
target_link_libraries(MyLib Foo::Foo)
Then if the user would like to build `MyLib` and `Foo` all in the same superprojects they can override `find_package`:
set(as_subproject Foo MyLib)
macro(find_package)
if(NOT "${ARG0}" IN_LIST as_subproject)
_find_package(${ARGV})
endif()
endmacro()
add_subdirectory(Foo)
add_subdirectory(MyLib)
add_subdirectory(App)
In addition you can mix external dependencies and `add_subdirectory`. That is, if Foo depends on zlib, then that could be found with `find_package` instead of being built within the same project.
However, a library should *not* avoid calling `find_package` or rely on strange custom logic(like `if(NOT TARGET)`) in order support `add_subdirectory. Each library should be able to be built independently and then we(or the user) overrides `find_package` to support the superproject builds.
>
>>> You can create header only library targets and >= 3.5 those work
>>> right without bugs. You can create static and dynamic library
>>> targets for those libraries which implement those.
>>
>> We need to generate the cmake config package. And that includes the
>> dependencies. Libraries like Hana can “cheat” and export the targets
>> directly to the cmake config package because it has no dependencies.
>> However, for a library like Boost.Fusion the dependencies will need
>> to be listed a third time in the cmake config.
>
> You don't need to generate the cmake config package. cmake generates the
> cmake config package using its knowledge of how to build the code. I
> don't know where you're getting all this complexity from.
>
> A correct implementation doesn't need anybody to "cheat". It should be
> 100% modern cmake. If anybody needs to cheat, you've done it wrong.
Cmake generates the export targets, however, if a dependency comes from another imported target, cmake will not create those imported targets. Instead they need to be defined with a call to `find_package`. However, in a config cmake package you will use `find_dependency` instead(which is almost the same except it it forwards the correct parameters for EXACT, QUIET and REQUIRED which were passed to the original `find_package` call). So if `MyLib` depends on `Foo`, then the cmake pakcage config would be written like this:
include(CMakeFindDependencyMacro)
find_dependency(Foo 2.0)
include("${CMAKE_CURRENT_LIST_DIR}/MyLibTargets.cmake”)
The `find_dependency` is necessary because `MyLib` depends on `Foo::Foo` which would be left undefined without a call to `find_package`(or `find_dependency` in this case). This allows the dependencies and packages to be relocatable, which is important.
However, in the case of a library like Hana, that has no dependencies, there is no need to call `find_dependency. Essentially, it would look like this:
include("${CMAKE_CURRENT_LIST_DIR}/HanaTargets.cmake”)
So instead of having cmake write the targets to a separate file, instead the targets can be written directly to the `HanaConfig.cmake`. This is what I meant by “cheat”. What Hana does is entirely correct and appropriate.
>
>>> I would personally suggest a Python script which parses Jamfile.v2
>>> and spits out a CMakeLists.txt. You'd get 80% of Boost.Build easily
>>> enough using just this.
>>
>> We can generate the code with python, which will help with libraries
>> that have lots of dependencies. Although some libraries like
>> Boost.Config is not so simple.
>
> I don't know what you're talking about. cmake tracks dependencies just
> fine and can export dependencies into things which consume targets.
For every `find_package` used in cmake(that is not a build-dependency) there needs to be a corresponding `find_dependency` call in the cmake package config file.
Also, Boost.Config tests are generated from *.ipp files, which is different than other boost libraries, and it adds a little more complexity.
>
>>> You just then need to feed everything to the cmake package
>>> tooling, again all 100% cmake 3. And you should be done, no cmake
>>> innovation needed
>>
>> The BCM modules aren’t trying to work or redefine the cmake workflow,
>> rather it is tool to help reduce the boilerplate needed to provide
>> cmake support in libraries like boost. Otherwise we will have authors
>> create their own set of functions to make the build scripts more
>> maintainable, and then we will lose consistency among boost
>> libraries.
>
> If there is a single custom function in what is implemented, then it's
> being done wrong. cmake 3.5 and later comes with substantial runtime
> facilities obviating the need for macros and custom functions for most
> end users. Just use what comes built into cmake.
>
> I appreciate all the work you've done with the BCM cmake modules. I
> respectfully insist that all that is superfluous in a minimum viable
> cmake 3.5 implementation. I appreciate what you are saying about the
> boilerplate issue, but if you require cmake 3.5 minimum, I do not
> believe any significant boilerplate issue should occur.
I disagree, there is still quite a bit of boilerplate. Also, the modules support additional things like pkgconfig.
>
> (Where the difference between mine and your approach stems from is that
> cmake is scriptable i.e. you can write programs in cmake which run over
> a source tree and do housekeeping using "cmake -P" (sometimes "ctest -S"
> is easier/better). These scripts can talk with git and pregenerate
> boilerplate that in cmake v2 days would be hidden inside macros. They
> can also install themselves into githooks so they regenerate boilerplate
> when you do git checkout and so on.
I think code generation on each commit is the wrong way to do this.
>
> A classic boilerplate to generate is lists of source files to save
> CMakeLists.txt having to specify it.
That is not something BCM tries to do. Authors can decide how they want to manage that. Instead BCM tries to handle the boilerplate between synchronizing the dependencies in the build, cmake package config, linking, and pkgconfig. It can also help ensure that libraries correctly alias the target to easily support superproject builds.
I agree which is why I am writing cmake modules to help make this more straightforward.
>
> * only needs to run tests
> * users need only point to the header library.
A header-only library needs to do more than this. It needs to install the headers as well as the usage requirements(through exporting the target)
>
> Actually, this example makes bjam look much easier than CMake which I believe conflicts with the original premise which motivated the proposal.
I don’t think its a fair comparison to bjam as its not doing the same thing. The bjam files in boost for header-only libraries do not individually install headers or usage requirements.
I think it is at minimum relevant, and mostly fair. The argument for using
an external non-Boost build system, regardless of which one is the current
flavor, is that it is externally supported. And hence no one at Boost needs
to write a bunch of code to make use of it for the Boost use case. But if
there needs to be a significant amount of code in Boost for the build
system the justifications for switching loose considerable appeal. It
doesn't matter where the code is. If it's in individual libraries or
collected in a common Boost module, it's still effort to maintain
comparable to the effort of maintaining b2.
--
-- Rene Rivera
-- Grafik - Don't Assume Anything
-- Robot Dreams - http://robot-dreams.net
-- rrivera/acm.org (msn) - grafikrobot/aim,yahoo,skype,efnet,gmail
_______________________________________________
There is many use cases for switching to cmake. One use case is modular building and to have boost export its usage requirements in the form of pkgconfig or cmake find packages. This can also be done using bjam files as well, but there is work that needs to be done to support this. Of course, the fact that Louis has done the work is not fair to compare with non-existent work. Furthermore, the argument is made that by switching to cmake, boost can take advantage of this larger community support to fulfill this work, instead of letting a decade go by on such unfulfilled requests in bjam.
Hmmm - I never felt the need for this. I just copy a library to my
system and add the directory to the list of directories to be searched.
What could possible be easier than that.
>> Actually, this example makes bjam look much easier than CMake which I believe conflicts with the original premise which motivated the proposal.
>
> I don’t think its a fair comparison to bjam as its not doing the same thing. The bjam files in boost for header-only libraries do not individually install headers or usage requirements.
Hmmm - Now I don't know what the proposal is. I thought it was to
replace bjam. I don't know what else it needs to do. I see CMake as an
alternative way of building and testing libraries. I don't see this
impacting users in any way. I thought I knew what is being proposed but
now I don't think I do. Perhaps this proposal should be something more
specific than "Moving Boost to CMake".
Robert Ramey
>
> On Jun 17, 2017, at 11:14 PM, Rene Rivera <grafi...@gmail.com> wrote:
>
> On Sat, Jun 17, 2017 at 10:55 PM, P F via Boost <bo...@lists.boost.org>
> wrote:
>
>>
>> > On Jun 17, 2017, at 3:10 PM, Robert Ramey via Boost <
>> bo...@lists.boost.org> wrote:
>> >
>> > Actually, this example makes bjam look much easier than CMake which I
>> believe conflicts with the original premise which motivated the proposal.
>>
>> I don’t think its a fair comparison to bjam as its not doing the same
>> thing. The bjam files in boost for header-only libraries do not
>> individually install headers or usage requirements.
>>
>
> I think it is at minimum relevant, and mostly fair. The argument for using
> an external non-Boost build system, regardless of which one is the current
> flavor, is that it is externally supported. And hence no one at Boost needs
> to write a bunch of code to make use of it for the Boost use case. But if
> there needs to be a significant amount of code in Boost for the build
> system the justifications for switching loose considerable appeal. It
> doesn't matter where the code is. If it's in individual libraries or
> collected in a common Boost module, it's still effort to maintain
> comparable to the effort of maintaining b2.
>
>
> There is many use cases for switching to cmake. One use case is modular
> building
>
Concretely define what "modular building" is.
> and to have boost export its usage requirements in the form of pkgconfig
> or cmake find packages.
>
Concretely define what it means to support those.
> This can also be done using bjam files as well, but there is work that
> needs to be done to support this.
>
True.. But the assumption seems to be that it would easier to do all of the
above with cmake. Which I dispute.
> Of course, the fact that Louis has done the work is not fair to compare
> with non-existent work.
>
Perhaps it's not fair to compare work that hasn't been defined sufficiently
to implement for any build system.
> Furthermore, the argument is made that by switching to cmake, boost can
> take advantage of this larger community support to fulfill this work,
> instead of letting a decade go by on such unfulfilled requests in bjam.
>
It is unfair to blame the build system for requests that are substantially
structural issues with Boost. Issues that would malign any build system
that Boost might use.
--
-- Rene Rivera
-- Grafik - Don't Assume Anything
-- Robot Dreams - http://robot-dreams.net
-- rrivera/acm.org (msn) - grafikrobot/aim,yahoo,skype,efnet,gmail
_______________________________________________
Much easier to say `cmake --build . --target install` or `install lib` from a package manager then manually figuring out what files need to be copied. Furthermore, this prevents installing the usage requirements, which it is much easier to say `g++ $(pkg-config boost_asio --cflags --libs)` or `target_link_libraries(myLib boost::asio)` then trying to figure out all the compiler and linker flags needed to use asio. A header-only should still provide its usage requirements, because:
* It may require linking in other libraries. Although a library is header-only it may depend on non-header-only libraries. This is the case for Boost.Asio, which needs to link in other libraries.
* A library may change usage requirements in the future. A library could change from header-only to being built, or it could bring in a new dependency that requires linking in a new library. This would affect all downstream libraries, but if the build scripts are using the usage requirements this will require zero changes to the build scripts.
>
>>> Actually, this example makes bjam look much easier than CMake which I believe conflicts with the original premise which motivated the proposal.
>> I don’t think its a fair comparison to bjam as its not doing the same thing. The bjam files in boost for header-only libraries do not individually install headers or usage requirements.
>
> Hmmm - Now I don't know what the proposal is. I thought it was to replace bjam. I don't know what else it needs to do. I see CMake as an alternative way of building and testing libraries. I don't see this impacting users in any way. I thought I knew what is being proposed but now I don't think I do. Perhaps this proposal should be something more specific than "Moving Boost to CMake”.
I believe the proposal was to move to cmake using cmake’s best practices for building, testing, and supporting `find_package`.
git clone https://github.com/boostorg/build
cd build
./bootstrap.sh
b2 install
cd ..
git clone https://github.com/boostorg/hana
cd hana
b2 install
or with cmake:
git clone https://github.com/boost-cmake/bcm
cd bcm
mkdir build
cd build
cmake ..
cmake --build . --target install
cd ../..
git clone https://github.com/boostorg/hana
cd hana
mkdir build
cd build
cmake ..
cmake --build . --target install
>
>
>> and to have boost export its usage requirements in the form of pkgconfig
>> or cmake find packages.
>>
>
> Concretely define what it means to support those.
These files would be generated during installation. I am not sure what more detail you are asking?
>
>
>> This can also be done using bjam files as well, but there is work that
>> needs to be done to support this.
>>
>
> True.. But the assumption seems to be that it would easier to do all of the
> above with cmake. Which I dispute.
That is not my assumption, either.
>
>
>> Of course, the fact that Louis has done the work is not fair to compare
>> with non-existent work.
>>
>
> Perhaps it's not fair to compare work that hasn't been defined sufficiently
> to implement for any build system.
>
>
>> Furthermore, the argument is made that by switching to cmake, boost can
>> take advantage of this larger community support to fulfill this work,
>> instead of letting a decade go by on such unfulfilled requests in bjam.
>>
>
> It is unfair to blame the build system for requests that are substantially
> structural issues with Boost. Issues that would malign any build system
> that Boost might use.
Yes, the build is not directly at fault, but if boost moved to cmake, there is a much larger community of people who are familiar with cmake and boost that could help work on these structural changes.
>> Hmmm - Now I don't know what the proposal is. I thought it was to replace bjam. I don't know what else it needs to do. I see CMake as an alternative way of building and testing libraries. I don't see this impacting users in any way. I thought I knew what is being proposed but now I don't think I do. Perhaps this proposal should be something more specific than "Moving Boost to CMake”.
>
> I believe the proposal was to move to cmake using cmake’s best practices for building, testing, and supporting `find_package`.
LOL - so it seems that neither one of knows what the proposal actually
is. I think it's time for the promoters of this proposal to step back
and agree on some more specific/concrete proposal that can be discussed
in a productive way - probably on a new thread. Probably with a titile
like one of the following:
a) proposal - Add support for CMake for building boosts and running tests
b) proposal - Add support for CMake to make Boost more user friendly by ...
c) proposal - add your own here ...
And this proposal should start with a succinct goal or motivation
Then describe the actions proposed to support the above. It's helpful
it describes who would undertake which actions - library maintainers,
some Developer, Some other player like the developers of CMake itself, etc.
Some sort of plan/description of how this would would proceed - All at
once - some proposals might not make sense unless applied to all
libraries as a requirement. Others might work as an option for each
library.
Sorry I can't be more specific - but of course I'm not the one making
such a proposal.
Robert Ramey
On 18.06.2017 11:20, Robert Ramey via Boost wrote:
> On 6/18/17 7:30 AM, P F via Boost wrote:
>
>>> Hmmm - Now I don't know what the proposal is. I thought it was to
>>> replace bjam. I don't know what else it needs to do. I see CMake as
>>> an alternative way of building and testing libraries. I don't see
>>> this impacting users in any way. I thought I knew what is being
>>> proposed but now I don't think I do. Perhaps this proposal should
>>> be something more specific than "Moving Boost to CMake”.
>>
>> I believe the proposal was to move to cmake using cmake’s best
>> practices for building, testing, and supporting `find_package`.
>
> LOL - so it seems that neither one of knows what the proposal actually
> is. I think it's time for the promoters of this proposal to step back
> and agree on some more specific/concrete proposal that can be
> discussed in a productive way - probably on a new thread. Probably
> with a titile like one of the following:
>
> a) proposal - Add support for CMake for building boosts and running tests
> b) proposal - Add support for CMake to make Boost more user friendly
> by ...
> c) proposal - add your own here ...
Thanks for trying hard to make this discussion efficient and
constructive. I have followed your suggestion and written my own little
"proposal". It may be lacking in some specifics, though I refrained from
putting too much into it precisely to avoid the discussion once again
being derailed by technical details. Those can all be sorted out easily
once the consensus is there.
It's really sad to see how much effort gets wasted on this list over the
years as ambitious people propose one idea or another, but eventually
get dragged down by the community's inability to "get their act
together" and move in almost any direction, leaving us with the status quo.
Let's keep trying... !
Best,
Stefan
>
> And this proposal should start with a succinct goal or motivation
>
> Then describe the actions proposed to support the above. It's helpful
> it describes who would undertake which actions - library maintainers,
> some Developer, Some other player like the developers of CMake itself,
> etc.
>
> Some sort of plan/description of how this would would proceed - All at
> once - some proposals might not make sense unless applied to all
> libraries as a requirement. Others might work as an option for each
> library.
>
> Sorry I can't be more specific - but of course I'm not the one making
> such a proposal.
>
> Robert Ramey
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
--
...ich hab' noch einen Koffer in Berlin...
I am not sure why it would feel alien, the getting started guide has those same steps:
http://www.boost.org/doc/libs/1_64_0/more/getting_started/unix-variants.html#easy-build-and-install
> Where would the headers go?
I don’t know what Boost.Build defaults to, but you can control where boost gets installed with the `--prefix` flag.
> What will happen to the already existing system Boost installation?
I believe the install rule copies the files, so they would just be replaced.
> What if I want to uninstall?
You would delete the directory, unless boost build supports a `b2 uninstall` that is created from the install rule.
There is no reason to doubt that user would find this helpful, otherwise users wouldn’t ask for such features. And it may seem like it doesn’t matter at this point for `safe_numerics`, except if you or one the libraries you depend on decide to use a compiled component this will effect both you and your users.
> But I don't see how it concerns boost library development. Boost library development is concerned with building libraries and running tests.
And also distribution. Nobody is going to use your library without distribution.
>
> So it sounds like you're interested in making Boost a more satisfying experience for users of Boost Libraries. A worthy consideration which I believe many of use would support. I would support a working FindBoost for example as I use CMake to build ide. Sounds like you have something in mind like FindBoostSerialization, FindBoostHana, etc.
No, something like boost_serialization-config.cmake or boost_hana-config.cmake. Find modules are for third-party libraries that don’t support cmake consumers.
> Which might also be interesting - but it has nothing to do with library development.
It does, because each library knows its usage requirements and when they will change, thus each library should provide that to the users.
> FindBoost can be made to work without boost developers doing anything differently. Why not make a separate project FindBoostxxx and include all anything you want there. The you don't have convince anyone to do anything, all you have to do is do it.
This does work currently because cmake developers have reversed-engineered the usage requirements, so I can write something like this in cmake:
find_package(Boost)
target_link_libraries(myLib boost::asio)
However, when I upgrade boost, I need to upgrade cmake as well. There really shouldn’t be a coupling between cmake and boost, like that. Instead each library can provide the cmake configuration, and we can update cmake’s FindBoost module to look for these configuration files, or the user can just call them directly with `find_package(boost_asio)`.
>> So it sounds like you're interested in making Boost a more satisfying experience for users of Boost Libraries. A worthy consideration which I believe many of use would support. I would support a working FindBoost for example as I use CMake to build ide. Sounds like you have something in mind like FindBoostSerialization, FindBoostHana, etc.
>
> No, something like boost_serialization-config.cmake or boost_hana-config.cmake. Find modules are for third-party libraries that don’t support cmake consumers.
>
>> Which might also be interesting - but it has nothing to do with library development.
>
> It does, because each library knows its usage requirements and when they will change, thus each library should provide that to the users.
>
>> FindBoost can be made to work without boost developers doing anything differently. Why not make a separate project FindBoostxxx and include all anything you want there. The you don't have convince anyone to do anything, all you have to do is do it.
>
> This does work currently because cmake developers have reversed-engineered the usage requirements, so I can write something like this in cmake:
>
> find_package(Boost)
> target_link_libraries(myLib boost::asio)
>
> However, when I upgrade boost, I need to upgrade cmake as well. There really shouldn’t be a coupling between cmake and boost, like that. Instead each library can provide the cmake configuration, and we can update cmake’s FindBoost module to look for these configuration files, or the user can just call them directly with `find_package(boost_asio)`.
So ... you want to add a file boost_serialization-config.cmake to
boost-root/libs/serialiation Right? That's all? I think we've already
acceded to the request that library authors are permitted to add CMake
and other support files to thier directories. So we're done here?
With all due respect, getting a concrete proposal from you is like
pulling teeth. I know you're well meaning, but I need more help here.
Robert Ramey
I think Daniel Pfeifer “Effective CMake” talk gives a good overview how this can be done in cmake. Of course, doing this outside of cmake would be a little more work, but probably could be built-in to boost build(which can handle the heavy lifting).
>
> However, when I upgrade boost, I need to upgrade cmake as well. There
> really shouldn’t be a coupling between cmake and boost, like that. Instead
> each library can provide the cmake configuration, and we can update cmake’s
> FindBoost module to look for these configuration files, or the user can
> just call them directly with `find_package(boost_asio)`.
>
First.. Needing to upgrade cmake to deal with newer releases of Boost is,
IMO, a design and implementation defect of cmake.
Second.. Why not use something like Conan that doesn't care about what
build system your dependencies use and will adjust to the build system you
are using for your product?
--
-- Rene Rivera
-- Grafik - Don't Assume Anything
-- Robot Dreams - http://robot-dreams.net
-- rrivera/acm.org (msn) - grafikrobot/aim,yahoo,skype,efnet,gmail
How to do this properly is fully documented in cmake (And provided free of
efort with polly) in bjam it's a total black art.
I am always left with the nagging feeling that something is wrong, because
despite following the instructions on stack overflow, there is no actual
documentation to convince me that all the voodoo in the jam files has
received the correct number of sacrificial virgins.
This is a sorry state of affairs for the worlds most popular c++ library.
It should be easy, no, automatic to include boost. After all, c++ without
boost is like [insert idiom about useless things here].
R
On Mon, 19 Jun 2017 at 01:05, Rene Rivera via Boost <bo...@lists.boost.org>
wrote:
> On Sun, Jun 18, 2017 at 4:09 PM, P F via Boost <bo...@lists.boost.org>
How is it a defect of cmake? How can cmake know the usage requirements for boost libraries when boost doesn’t make that available?
>
> Second.. Why not use something like Conan that doesn't care about what build system your dependencies use and will adjust to the build system you are using for your product?
Conan requires adding special function or macros to the cmake that don’t work with standalone cmake. This also makes it not work with other package managers that may want to build the library. We could write conditionals around the conan functions, but then it feels like we are supporting two buildsystems. Hopefully, in the future, conan will fix this so that there is no need for modifications to the cmake file.
Also, cget can work with other build systems as well by providing a cmake file that can translate the cmake toolchain to the other build system. It already provides this support for boost, so you can build boost with:
cget install -X boost https://downloads.sourceforge.net/project/boost/boost/1.64.0/boost_1_64_0.tar.bz2
If we support modular builds like I showed(where I can clone a library and then call `b2 install`), then cget could install libraries modularly:
cget install -X boost boostorg/predef
However, since predef is header-only, you can currently install it like this:
cget install -X header boostorg/predef
Of course, none of this supports the usage requirements. If there is a way to retrieve this information during a build of boost, I can update cget’s boost script to convert this to cmake packages or pkgconfig.
Best,
Vicente