通过CMake控制Xcode工程编译选项

Xcode工程属性列表

每一个Xcode工程属性都有一个对应的属性ID,在苹果官网帮助文档可以查到:

https://help.apple.com/xcode/mac/current/#/itcaec37c2a6

下面是关于strip的配置属性

Strip Debug Symbols During Copy (COPY_PHASE_STRIP)

Specifies whether binary files that are copied during the build, such as in a Copy Bundle Resources or Copy Files build phase, should be stripped of debugging symbols. It does not cause the linked product of a target to be stripped—use Strip Linked Product (STRIP_INSTALLED_PRODUCT) for that.
CoreML Model Class Generation Language (COREML_CODEGEN_LANGUAGE)

The Source-code language to use for generated CoreML model class. By default "Automatic" will analyze your project to determine the correct language. Adjust this setting to explicitly select "Swift" or "Objective-C", or select "None" to disable model class generation.
CoreML Generated Model Inherits NSObject (COREML_CODEGEN_SWIFT_GLOBAL_MODULE)

通过CMake配置Xcode属性

只需要在每个Xcode属性ID前面加上 CMAKE_XCODE_ATTRIBUTE_ 即可。

比如要编译的release库包含调试信息,则需要将工程配置中的strip设置改为No,则在生成XCode工程的命令行中进行如下配置:

cmake -DCMAKE_XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT=NO -DCMAKE_XCODE_ATTRIBUTE_COPY_PHASE_STRIP=NO -DCMAKE_BUILD_TYPE=Release -G Xcode ../

你可能感兴趣的:(通过CMake控制Xcode工程编译选项)