|
Boost : |
Subject: Re: [boost] CMake Modularization
From: Peter Dimov (lists_at_[hidden])
Date: 2016-09-27 19:18:41
Philip Woods wrote:
> I created an example project
> https://github.com/Elzair/cmake-boost-filesystem-test to demonstrate my
> ideas. I added CMake build support to the minimum number of modules needed
> to support this demo: https://github.com/Elzair/assert
> https://github.com/Elzair/config https://github.com/Elzair/core
> https://github.com/Elzair/filesystem/tree/master and
> https://github.com/Elzair/system
I know next to nothing about CMake, but this doesn't seem quite the right
way.
This:
set(BOOST_FILESYSTEM_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include"
CACHE STRING "Location of boost.filesystem headers")
should perhaps just be
target_include_directories(boost_filesystem PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include)
The manual dependency checking at the top:
if(NOT BOOST_CONFIG_INCLUDE_DIRS)
message(FATAL_ERROR "Cannot find boost.config!")
endif(NOT BOOST_CONFIG_INCLUDE_DIRS)
should probably be replaced by
target_link_libraries(boost_config)
boost_config, being a header-only library, should be
add_library(boost_config INTERFACE)
The various BOOST_*_INCLUDE_DIRS and BOOST_*_LIBRARIES won't be needed;
CMake will figure it out automatically. And the order of add_subdirectory
will no longer matter.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk