Stéphane
Stéphane

Reputation: 20360

Getting CMake on Windows to find the vc120 Boost libraries

CMake is looking for a different boost files than I have installed, and I don't know how to fix it. I'm on 64-bit Windows 7, VisualStudio Community 2015, and using the latest 64-bit build of Boost boost_1_58_0-msvc-12.0-64.exe.

The relevant part of my CMake file is this:

SET          ( Boost_DEBUG                ON  )
SET          ( Boost_DETAILED_FAILURE_MSG ON  )
SET          ( Boost_USE_STATIC_LIBS      ON  )
SET          ( Boost_USE_MULTITHREADED    ON  )
SET          ( Boost_USE_STATIC_RUNTIME   OFF )
FIND_PACKAGE ( Boost COMPONENTS regex date_time REQUIRED )

With debug and detailed messages enabled, I can see CMake is looking in the right place, but is looking for "vc140" instead of "vc120":

location of version.hpp: C:/boost_1_58_0/boost/version.hpp
version.hpp reveals boost 1.58.0
guessed _boost_COMPILER = -vc140
_boost_MULTITHREADED = -mt
_boost_RELEASE_ABI_TAG = -
_boost_DEBUG_ABI_TAG = -gd
_boost_LIBRARY_SEARCH_DIRS = C:\boost_1_58_0\lib64-msvc-12.0;C:\boost_1_58_0/lib;C:\boost_1_58_0/stage/lib;C:/boost_1_58_0/lib;C:/boost_1_58_0/../lib;C:/boost_1_58_0/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
Searching for REGEX_LIBRARY_RELEASE:
libboost_regex-vc140-mt-1_58;
libboost_regex-vc140-mt;
libboost_regex-mt-1_58;
libboost_regex-mt;
libboost_regex

The files I have are named with "120":

>dir /b c:\boost_1_58_0\lib64-msvc-12.0\libboost_regex-*
libboost_regex-vc120-mt-1_58.lib
libboost_regex-vc120-mt-gd-1_58.lib
libboost_regex-vc120-mt-s-1_58.lib
libboost_regex-vc120-mt-sgd-1_58.lib
libboost_regex-vc120-s-1_58.lib
libboost_regex-vc120-sgd-1_58.lib

I'm assuming "120" refers to the version of VisualStudio? How do I get CMake to find the vc120 files?

Upvotes: 2

Views: 1035

Answers (1)

Stéphane
Stéphane

Reputation: 20360

Little known variable called Boost_COMPILER is the solution. So in my case, to force CMake to look for vc120 instead of the default vc140, I have to run cmake like this:

>cmake -DCMAKE_BUILD_TYPE=Release -DBoost_COMPILER=-vc120 -DBOOST_ROOT=C:\boost_1_58_0 -DBOOST_LIBRARYDIR=C:\boost_1_58_0\lib64-msvc-12.0 -G "Visual Studio 14" ..

Upvotes: 3

Related Questions