使用 CMake 编译 32 位与 64 位项目 [英] Compiling 32-bit vs 64-bit project using CMake

查看:92
本文介绍了使用 CMake 编译 32 位与 64 位项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何指定 CMake 应根据目标是 32 位还是 64 位使用不同的 link_directories 值?例如,32 位二进制文​​件需要与 32 位 Boost 链接,64 位二进制文​​件需要与 64 位 Boost 链接.

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.

推荐答案

你按照这些思路做一些事情

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} )

这篇关于使用 CMake 编译 32 位与 64 位项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆