Is it possible to pass #define flags to vcpkg packages for compiling?

460 Views Asked by At

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

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

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.

1

There are 1 best solutions below

4
0___________ On

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

 -D_GLFW_WNDCLASSNAME=something

-D in GCC:

-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.