How do I specify that CMake should use a different link_directories
value depending on whether the target is 32-bit is 64-bit? For example, 32-bit binaries need to link with 32-bit Boost, 32-bit binaries need to link with 64-bit Boost.
views:
29answers:
2
+1
A:
You do something along these lines
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( BOOST_LIBRARY "/boost/win64/lib" )
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( BOOST_LIBRARY "/boost/win32/lib" )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( CMAKE_EXE_LINKER_FLAGS ${BOOST_LIBRARY} )
As specified by Martin, this shouldn't be needed for boost, but it is a good to know method anyway.
tibur
2010-10-29 21:39:35
+2
A:
For Boost specifically, you should use
FIND_LIBRARY(Boost 1.44 COMPONENTS ...)
Then the CMake variable Boost_LIBRARY_DIRS will contain the correct library path, which has to be set using LINK_DIRECTORIES, e.g.
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
The more general case is correctly described in user434507's answer.
Martin
2010-10-27 08:12:53