FindBoost with MSVC and LLVM Toolset

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

FindBoost with MSVC and LLVM Toolset

Innokentiy Alaytsev

I got a problem while trying to use CMake 3.11.3 to configure a project that uses Boost.Exception library and LLVM-vs2014 toolset with MSVS 2017 v15.7.4.

I configure the project using cmake-gui. I select the Visual Studio 15 2017 generator and set optional toolset option to LLVM-vs2014. I have LLVM 6.0 x64 installed.

# Boost settings
if (WIN32)
  # According to documentation:
  # On Visual Studio and Borland compilers Boost headers request automatically
  # linking to corresponding libraries. This requires matching libraries to be
  # linked explicitly or available in the link library search path. In this case
  # setting Boost_USE_STATIC_LIBS to OFF may not achieve dynamic linking. Boost
  # automatic linking typically requests static libraries with a few exceptions
  # (such as Boost.Python).
  # That's why for static libraries it is required to explicitly enable static
  # libraries usage.
  set (Boost_USE_STATIC_LIBS ON)
endif (WIN32)

find_package (Boost 1.38.0 REQUIRED

Error message:

CMake Error at C:/Program Files/CMake/share/cmake-3.11/Modules/FindBoost.cmake:2044 (message):
Unable to find the requested Boost libraries.

Boost version: 1.67.0

Boost include path: W:/boost/1.67.0

Could not find the following static Boost libraries:


No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Call Stack (most recent call first):

I performed a little investigation. It seems that FindBoost module the is distributed with CMake does not support using an alternative toolset with MSVS generator. The function _Boost_GUESS_COMPILER_PREFIX (line 451) checks Intel, MSVC, Borland and MinGW compilers (and general UNIX case). The thing is that CMAKE_CXX_COMPILER_ID for the LLVM-v140 toolset is Clang. As a result, an empty Boost compiler prefix is returned by the function.

I managed to workaround the issue by adding the following check before the other checks performed by the _Boost_GUESS_COMPILER_PREFIX function:

    set(_boost_COMPILER "-vc100")
    set(_boost_COMPILER "-vc110")
    set(_boost_COMPILER "-vc120")
    set(_boost_COMPILER "-vc141;-vc140")

I am not sure that this is the right solution in general, but it has resolved the issue that I had.

What is the correct solution for the problem.

Best regards,
Innokentiy Alaytsev


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: