boostorg / hana

Your standard library for metaprogramming
http://boostorg.github.io/hana
Boost Software License 1.0
1.66k stars 217 forks source link

Add a Boost-friendly subproject case to CMakeLists #490

Closed pdimov closed 2 years ago

ldionne commented 3 years ago

Thanks for the PR! I'd like to understand what would be required to make the main CMake file compatible with the rest of Boost instead - I think it would be easier to maintain in the future, and I'd like Hana to be a good citizen of Boost as much as possible.

pdimov commented 3 years ago

The current CMakeLists only seems suited for root project use, so getting from here to there is not a small diff. Clean subprojects are easier to make Boost-compatible, although there are still many things that will be "wrong".

The project name must be boost_libname by convention; the version when inside the Boost superproject must be set to BOOST_SUPERPROJECT_VERSION (e.g. "1.77.0".) There must be a clean target boost_libname with an alias Boost::libname that other libraries (Boost and not) can link to. target_include_directories must be include to enable the superproject automatic install feature; or if not, the library can supply its own installation, but the package name must be boost_libname, the package version must match the Boost version, and the config file must declare the Boost::libname target and issue the required find_dependency calls that match target_link_libraries. (The destinations should also be "correct", i.e. those given by GNUInstallDirs to which CMake 3.14 defaults.)

As few options as possible must be declared, preferably none unless they really control how the library is built; as few lines of status output must be produced, preferably none. (For 140+ libraries, if each decides to add four options and print seven lines of output, the result is not hard to imagine.) Adding any compile flags is also not a good practice; these should be left to the master project. And of course find_package(Boost) is just asking for trouble. :-)

I'm working on a document to spell all this out, but it's not done yet.

ldionne commented 2 years ago

Thanks for the explanation and sorry for sitting on this. Let's land this, and in the future, I can work on updating the main CMakeLists.txt to be Boost-compatible if I have time. Otherwise, I don't want to stall your effort on that.

pdimov commented 2 years ago

Thanks for merging that; please let me know when it's in master, so that I can remove hana from BOOST_INCOMPATIBLE_LIBRARIES.

pdimov commented 2 years ago

Would you please merge this to master before 1.78.0?

ldionne commented 2 years ago

Done, sorry it took so long, I'm somewhat overloaded with libc++.