Currently, since boost 1.70.0, imported CMake targets for boost libraries inspect the BUILD_SHARED_LIBS variable and complain if its boost setting does not match the project's setting (and e.g. suggest to add an additional CMake variable Boost_USE_STATIC_LIBS=OFF in case BUILD_SHARED_LIBS is not ON).
While the idea is nice and makes sense in some cases when building libraries, checks for BUILD_SHARED_LIBS only makes sense for CMake projects build libraries. They do not make sense for other projects that, for example, only build executables via ADD_EXECUTABLE().
Hence, CMake projects for executables currently always need to be configured with an additional non-project-related variable Boost_USE_STATIC_LIBS such that FIND_PACKAGE(Boost) does not fail.
Actually, I think it would be cleaner to skip the check on BUILD_SHARED_LIBS completely and leave it to the developer to ensure that he configures boost and derived projects consistently.
Currently, since boost 1.70.0, imported CMake targets for boost libraries inspect the BUILD_SHARED_LIBS variable and complain if its boost setting does not match the project's setting (and e.g. suggest to add an additional CMake variable Boost_USE_STATIC_LIBS=OFF in case BUILD_SHARED_LIBS is not ON).
While the idea is nice and makes sense in some cases when building libraries, checks for BUILD_SHARED_LIBS only makes sense for CMake projects build libraries. They do not make sense for other projects that, for example, only build executables via ADD_EXECUTABLE().
Hence, CMake projects for executables currently always need to be configured with an additional non-project-related variable Boost_USE_STATIC_LIBS such that FIND_PACKAGE(Boost) does not fail.
Actually, I think it would be cleaner to skip the check on BUILD_SHARED_LIBS completely and leave it to the developer to ensure that he configures boost and derived projects consistently.