Boost compiled libraries have the same names for x86 and x64. My project uses Boost and I want it to automatically link correct Boost libraries when compiling with CMake for x64 or x86 target
My CMakeFiles.txt uses simple code
find_package(Boost REQUIRED
COMPONENTS
coroutine context thread filesystem program_options system
)
My Boost is built with (MSVC2015)
b2 address-model=32 --build-type=minimal stage --stagedir stage
b2 address-model=64 --build-type=minimal stage --stagedir stage64
I have also tried "install" target and putting boost builds into separate folders
I am building my project with (Windows)
md build32
cd build32
cmake .. -G"Visual Studio 14 2015"
cmake --build .
cd ..
and
md build
cb build
cmake .. -G"Visual Studio 14 2015 Win64"
cmake --build .
cd ..
x86 target is build successfull because its libraries (boost) are laying in "stage" folder that is well-known to CMake's FindBoost module
But x64 target cant be built because FindBoost uses x86 libraries of Boost for building process and does not try to use libraries from "stage64" with this error:
D:\lib\boost_1_61_0\stage\lib\libboost_coroutine-vc140-mt-gd-1_61.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
My goal is to exlude any additional params at "Cmake" calling to build my project and I want it to automatically find correct boost libs for x86 or x64 depending on which -G param of CMAKE I am using
How can I change my CMakeFiles.txt to make it automatically find correct boost libraries?
Boost version - 1.61, MSVC 2015, CMAKE - 3.6.2 (latest and has knowledge about boost 1.61), Windows 7 x64
BOOST_ROOT
to approprite directory (D:\lib\boost_1_61_0\stage64
) when build project for x86_64. – TsyvarevBOOST_ROOT/lib32-msvc-14.0/
and the x64 ones inBOOST_ROOT/lib64-msvc-14.0/
and check again? – llonesmizstage32
instead of juststage
. The problem seems to be thatBOOST_ROOT/stage/lib
seems to be unconditionally added to the list of directories where CMake looks for libraries. – llonesmiz