在CMAKE子目录CMakeLists.txt文件中更改编译器 [英] change compiler in CMAKE sub_directory CMakeLists.txt file

查看:493
本文介绍了在CMAKE子目录CMakeLists.txt文件中更改编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个内部子目录中更改CMAKE_C_COMPILER和CMAKE_CXX_COMPILER,这是一个较大项目的一部分。

I would like to change CMAKE_C_COMPILER and CMAKE_CXX_COMPILER in an inner sub_directory being compiled as part of a bigger project.

从GNU更改为intel编译器。

changing from GNU to intel compiler. however, outside of this directory nothing has to chagne.

有可能吗?

谢谢

推荐答案

而不是使用 add_subdirectory 来考虑使子目录成为一个独立的CMake项目,可以独立于较大的项目进行配置和构建。然后,您可以使用 ExternalProject_Add将子目录作为外部项目添加到较大的项目中命令。

Instead of using add_subdirectory consider making the subdirectory a self-contained CMake project, which can be configured and built independently of the bigger project. You can then add the subdirectory to your bigger project as an external project by using the ExternalProject_Add command.

这篇关于在CMAKE子目录CMakeLists.txt文件中更改编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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