How do I specify that CMake should use a different link_directories value depending on whether the target is 32-bit or 64-bit? For example, 32-bit binaries need
Based on rominf I turned up following solution (for Windows). I install boost libraries into: C:\Boost_32 and C:\Boost_64
In CMakeLists.txt
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
set(BOOST_ROOT C:/Boost_${BITS})
find_package(Boost 1.64.0 COMPONENTS ... )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
LINK_DIRECTORIES(${Boost_LIBRARY_DIR})
Explanation:
CMAKE_SIZEOF_VOID_P is equal to 4 on 32bit platform, and 8 on 64bit platform.8*${CMAKE_SIZEOF_VOID_P} will evaluate to 32 or 64,
respectively.C:/Boost_${BITS} turns into C:/Boost_32 or C:/Boost_64 automagicallyAdvantages: