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)
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 Boost. 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: