gpt4 book ai didi

Is it possible to pass #define flags to vcpkg packages for compiling?(可以将#DEFINE标志传递给vcpkg包进行编译吗?)

转载 作者:bug小助手 更新时间:2023-10-25 13:38:32 25 4
gpt4 key购买 nike



Is there a way to pass build #define flags to vcpkg packages? I'm using Manifest mode.

有没有办法将build #define标志传递给vcpkg包?我用的是清单模式。


Specifically, I want to set the _GLFW_WNDCLASSNAME define when building the glfw3 package via vcpkg.

具体地说,我希望在通过vcpkg构建glfw3包时设置_GLFW_WNDCLASSNAME定义。


This is the portfile for glfw3. I don't know the details of portfiles, but I don't see that #define being used in there.

这是glfw3的端口文件。我不知道端口文件的细节,但我看不出其中使用了#定义。


更多回答
优秀答案推荐

In the Cmake configuration in options you set the compiler flags. Add:

在Cmake配置的选项中设置编译器标志。添加:


 -D_GLFW_WNDCLASSNAME=something

-D in GCC:

-GCC中的D:



-D name


Predefine name as a macro, with definition 1.


-D name=definition


The contents of definition are tokenized and processed as if they appeared during translation phase three in a ‘#define’ directive. In
particular, the definition is truncated by embedded newline
characters.


If you are invoking the preprocessor from a shell or shell-like program you may need to use the shell’s quoting syntax to protect
characters such as spaces that have a meaning in the shell syntax.


If you wish to define a function-like macro on the command line, write its argument list with surrounding parentheses before the equals
sign (if any). Parentheses are meaningful to most shells, so you
should quote the option. With sh and csh, -D'name(args…)=definition'
works.


-D and -U options are processed in the order they are given on the command line. All -imacros file and -include file options are
processed after all -D and -U options.



更多回答

The vcpkg tool downloads and builds the packages automatically, based on the definition of a vcpkg.json file. I'm not building those packages manually. My question is how to tell the vcpkg tool to compile those packages with the given #define value.

Vcpkg工具根据vcpkg.json文件的定义自动下载和构建包。我不会手动构建这些包。我的问题是如何告诉vcpkg工具使用给定的#Define值编译这些包。

@Dess in portfile. You have cmake opinions there.

端口文件中的@Dess。你可以在那里发表意见。

Oh, you're saying to change the portfile code in the vcpkg repo locally download. I'll give that a try. But, ideally, I'm looking for a way to pass compiler flags to the package without having to mess with the vcpkg repo files.

哦,您是说要更改本地下载的vcpkg repo中的端口文件代码。我会试一试。但是,理想情况下,我正在寻找一种方法来将编译器标志传递给包,而不必扰乱vcpkg repo文件。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com