Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling 32-bit vs 64-bit project using CMake

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 to link with 32-bit Boost, 64-bit binaries need to link with 64-bit Boost.

like image 341
Gili Avatar asked Oct 27 '10 02:10

Gili


People also ask

Is CMake 32 bit?

CMake is software designed to automate compilation on various systems. We'll need both the make tool and a C or C++ compiler to build a project. As a result, we have a 32-bit executable program linked to a 32-bit C library.

What is CMake good for?

CMake handles the difficult aspects of building software such as cross-platform builds, system introspection, and user customized builds, in a simple manner that allows users to easily tailor builds for complex hardware and software systems.


1 Answers

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} ) 
like image 59
Eugene Smith Avatar answered Oct 14 '22 10:10

Eugene Smith