<div dir="ltr"><div>Hello!</div><div><br></div><div>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.</div><div><br></div><div>I configure the project using <span style="font-family:monospace,monospace">cmake-gui</span>. I select the <span style="font-family:monospace,monospace">Visual Studio 15 2017</span> generator and set optional toolset option to <span style="font-family:monospace,monospace">LLVM-vs2014</span>. I have LLVM 6.0 x64 installed.<br></div><div><br></div><div>CMakeLists.txt:</div><div><span style="font-family:monospace,monospace"># Boost settings<br>if (WIN32)<br>  # According to documentation:<br>  #<br>  # On Visual Studio and Borland compilers Boost headers request automatically<br>  # linking to corresponding libraries. This requires matching libraries to be<br>  # linked explicitly or available in the link library search path. In this case<br>  # setting Boost_USE_STATIC_LIBS to OFF may not achieve dynamic linking. Boost<br>  # automatic linking typically requests static libraries with a few exceptions<br>  # (such as Boost.Python).<br>  #<br>  # That's why for static libraries it is required to explicitly enable static<br>  # libraries usage.<br>  set (Boost_USE_STATIC_LIBS ON)<br>endif (WIN32)</span></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">find_package (Boost 1.38.0 REQUIRED<br>  COMPONENTS<br>  exception)</span><br></div><div><br></div><div><br></div><div>Error message:</div><div><br></div><div>

<p style="margin:0px;white-space:pre-wrap"><span style="font-family:monospace,monospace"><span style="color:rgb(255,0,0)">CMake Error at C:/Program Files/CMake/share/cmake-3.11/Modules/FindBoost.cmake:2044 (message):<br>  Unable to find the requested Boost libraries.<br><br>  Boost version: 1.67.0<br><br>  Boost include path: W:/boost/1.67.0<br><br>  Could not find the following static Boost libraries:<br><br>          boost_exception<br><br>  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the<br>  directory containing Boost libraries or BOOST_ROOT to the location of<br>  Boost.<br>Call Stack (most recent call first):<br>  ...</span></span></p></div><div><br></div><div>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 <span style="font-family:monospace,monospace">_Boost_GUESS_COMPILER_PREFIX</span> (line 451) checks Intel, MSVC, Borland and MinGW compilers (and general UNIX case). The thing is that <span style="font-family:monospace,monospace">CMAKE_CXX_COMPILER_ID</span> for the <span style="font-family:monospace,monospace">LLVM-v140</span> toolset is <span style="font-family:monospace,monospace">Clang</span>. As a result, an empty Boost compiler prefix is returned by the function.</div><div><br></div><div>I managed to workaround the issue by adding the following check before the other checks performed by the <span style="font-family:monospace,monospace">_Boost_GUESS_COMPILER_PREFIX</span> function:</div><div><br></div><div><span style="font-family:monospace,monospace">if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")<br>  if("${CMAKE_VS_PLATFORM_TOOLSET}" STREQUAL "LLVM-vs2010")<br>    set(_boost_COMPILER "-vc100")<br>  elseif("${CMAKE_VS_PLATFORM_TOOLSET}" STREQUAL "LLVM-vs2012")<br>    set(_boost_COMPILER "-vc110")<br>  elseif("${CMAKE_VS_PLATFORM_TOOLSET}" STREQUAL "LLVM-vs2013")<br>    set(_boost_COMPILER "-vc120")<br>  elseif("${CMAKE_VS_PLATFORM_TOOLSET}" STREQUAL "LLVM-vs2014")<br>    set(_boost_COMPILER "-vc141;-vc140")<br>  endif()<br>else</span></div><div><span style="font-family:monospace,monospace"></span><br></div><div>I am not sure that this is the right solution in general, but it has resolved the issue that I had.</div><div><br></div><div>What is the correct solution for the problem.<br></div><div><br></div><div><div class="gmail_signature"><div dir="ltr">Best regards,</div><div>Innokentiy Alaytsev<br></div></div></div>
</div>