如何为CMAKE外部项目指定编译器? [英] How to specify the compiler for CMAKE external project?

查看:96
本文介绍了如何为CMAKE外部项目指定编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在ExternalProject_Add中包含一个外部项目。我想做的就是

I am including an external project with ExternalProject_Add. What I want is to be able to do

cmake -DCMAKE_CXX_COMPILER=<some compiler> <assume correct path>

用于顶层项目,以便我选择的编译器传播到外部包含的项目。我希望可以在ExternalProject_Add命令中添加一些内容:

for the top-level project so that my chosen compiler propagates to the externally included projects. I expect something that I can put in the ExternalProject_Add command:

ExternalProject_Add (

  some_external_project

  PREFIX ...            # Assume this works.
  GIT_REPOSITORY ...    # Assume this works too.

  # What should I write here to tell it to use the ${CMAKE_CXX_COMPILER}
  # of the top-level project ?
)


推荐答案

以下内容在顶级项目中为我工作:

The following worked for me in the top-level project:

ExternalProject_Add (

  some_external_project

  PREFIX ...          # Assume this works.
  GIT_REPOSITORY ...  # Assume this works too.

  # This did the trick for me.
  CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
)

这篇关于如何为CMAKE外部项目指定编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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