2

我曾经有这样的定义:

#define MY_CLSID {0xc9955517, 0x6ca4, 0x439f, {0x86, 0xb7, 0xdd, 0xc5, 0xb6, 0x45, 0xe7, 0x6c}}

现在我想通过cmake做到这一点,但到目前为止我失败了。有谁知道该怎么做?

PS:那是我的尝试:

add_definitions(/D MY_CLSID={0x87f8774f,0xb485,0x47e2,{0xa7,0x55,0xa4,0xa,0x8a,0x5e,0x88,0x6c}})
4

2 回答 2

1

Of course, arrowdodger's answer is correct and if you have only a few of those defines, I would recommend it as well. In case of lots of (more complex) defines, the use of configure_file can be a good alternative:

// In Your_CLSID.h.in
#cmakedefine {0xc9955517, 0x6ca4, 0x439f, {0x86, 0xb7, 0xdd, 0xc5, 0xb6, 0x45, 0xe7, 0x6c}}
// end of Your_CLSID.h.in

and generate a "Your_CLSID.h" with

configure_file( ${CMAKE_SOURCE_DIR}/Your_CLSID_Config.h.in ${CMAKE_BINARY_DIR}/common/Your_CLSID.h )

Of course, you will have to add your binary dir to the include-directories:

include_directories( ${CMAKE_BINARY_DIR}/common )

See also my similar answers to the following questions:

于 2012-10-08T18:48:02.743 回答
1

用引号为我工作:

add_definitions(
  /D MY_CLSID="{0x87f8774f,0xb485,0x47e2,{0xa7,0x55,0xa4,0xa,0x8a,0x5e,0x88,0x6c}}"
)
于 2012-10-08T16:08:24.753 回答