如何参数化Eclipse生成的make文件 [英] How can I parameterize an Eclipse generated make file

查看:182
本文介绍了如何参数化Eclipse生成的make文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Eclipse CDT项目,该项目配置为生成make文件.

I have an Eclipse CDT project that is configured to generate make files.

此刻我正在Windows上进行开发,并且我的构建服务器正在运行Linux.

I am developing on windows at the moment, and my build server is running Linux.

make文件可以在本地计算机上很好地构建,但是我有两个预先构建的外部依赖项:boost和ZeroMQ.两者都有一个include目录,一个lib目录和一个相关的dll/so.

The make files build well on my local machine, but I have two pre-built external dependencies: boost and ZeroMQ. Both of these have an include directory, a lib directory and an associated dll/so.

如何配置项目,以使生成的make文件可以具有在make时解析(而不是烘焙到make文件中)的不同BOOST_HOME或ZMQ_HOME变量.

How can I configure the project such that the generated make files can have different BOOST_HOME or ZMQ_HOME variables that are resolved at make time (as opposed to being baked into the make file).

推荐答案

CDT生成的makefile包含以下几行:

Makefiles generated by CDT include the following lines:

-include ../makefile.init
 ...
-include ../makefile.defs
 ...
-include ../makefile.targets

也就是说,您可以添加例如makefile.defs在项目根目录中以控制构建.

That is, you can add e.g. makefile.defs in the project root to control the build.

JeffV 我添加了一个makefile.init:

JeffV I added a makefile.init:

 BOOST_HOME = C:\code\boost_1_48_0
 ZMQ_HOME = C:\code\zmq\zeromq-2.1.11

在项目设置"Build Variables"配置中,我还添加了以下条目:

In the project settings "Build Variables" config I also added these entries:

BOOST_HOME = $(BOOST_HOME)
ZMQ_HOME = $(ZMQ_HOME)

这会导致eclipse用make文件中的$(BOOST_HOME)变量替换我的lib中引用的$ {BOOST_HOME}并包含路径.

Which causes eclipse to replace ${BOOST_HOME} where it is references in my lib and include paths, with the $(BOOST_HOME) variable in the make file.

这使我可以在每个构建平台上拥有特定于平台的makefile.init版本.

This allows me to have a platform specific version of the makefile.init on each build platform.

这篇关于如何参数化Eclipse生成的make文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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