Boost logo

Boost :

Subject: Re: [boost] [cmake] Minimum viable cmakeification for Boost
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2017-06-21 12:53:34


On 06/21/2017 02:11 PM, Peter Dimov via Boost wrote:
> Thomas Heller wrote:
>> FWIW, this is totally doable within CMake. Consider this:
>>
>> # I guess this if statement has to persist, if someone knows a way
>> # around it, please fix. Could be placed in another Setup.cmake or so to
>> # seperate the build logic from this logic.
>> if (PUMPKIN_WITH_ZLIB)
>> # This sets ZLIB_FOUND to TRUE if found and exports and gives you the
>> # ZLIB::ZLIB target.
>> find_package(ZLIB)
>> else()
>> # Workaround to have the target available even when zlib was not
>> # requested...
>> add_library(ZLIB::ZLIB INTERFACE IMPORTED)
>> endif()
>>
>> # Sets up the zlib dependent target...
>> add_library(pumpkin_zlib
>> EXCLUDE_FROM_ALL ${PUMPKIN_ZLIB_SOURCES})
>> target_compile_definitions(pumpkin_zlib PUMPKIN_HAVE_ZLIB)
>> target_link_libraries(pumpkin_zlib ZLIB::ZLIB)
>>
>> # setup the main target.
>> add_library(pumpkin ${PUMPKIN_SOURCES})
>> target_link_libraries(pumpkin
>> PRIVATE $<$<BOOL:${PUMPKIN_WITH_ZLIB}>:pumpkin_zlib>)
>
> What I had in mind was more like this:
>
> add_library(pumpkin ${PUMPKIN_SOURCES})
>
> add_library(pumpkin_zlib ${PUMPKIN_ZLIB_SOURCES})
> target_link_libraries(pumpkin_zlib pumpkin)
> target_link_libraries(pumpkin_zlib ZLIB::ZLIB)
>
> with the find_package logic residing in the rootmost CMakeLists, where
> the project links or does not link to pumpkin_zlib, as appropriate.

What would be the rootmost CMakeLists.txt? The one in boostorg in our
case? The one that our users would write?
I am still having difficulties to see the benefits of having it all in
the rootmost file (since I really have problems grasping what is
actually means).

For reference, I just had a quick glance at the iostreams (which has a
dependency on zlib) Jamfile.v2. Two observations from my side:
  1) It looks very imperative
  2) The zlib dependency is not handled at the Jamroot but in the
     component directly.
That is, it looks very similar to what I proposed earlier.

What do I miss?

>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk