2

我在 mac os 上创建了一个 firebreath 插件,它必须弹出一个窗口来获取用户输入(只有一个文本字段和两个按钮)。

这是我当前用于测试的 projectDef.cmake。

file (GLOB XIB RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
Mac/bundle_template/input.xib
)

# Make sure we can find the 'ibtool' program. If we can NOT find it we
# skip generation of this project
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
    message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files.      It should have been installed with the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
endif()

# make the compiled nib file to desktop for testing
set (NIBFILE /Users/develop/Desktop/input.nib)

add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD 
    COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text  --compile ${NIBFILE} ${XIB}
    COMMENT "Compiling input.xib")

set (SOURCES
    ${SOURCES}
    ${PLATFORM}
    ${XIB}
)

add_custom_command 块对 cmake 没有影响,当我的插件目标构建成功时没有编译 nib 文件,但是 ibtool 在终端的命令行中工作。

4

2 回答 2

1

看起来您需要做的是将 .xib 文件编译为 .nib 文件。这里有一个如何做到这一点的例子:

http://www.cmake.org/Wiki/CMake:OSX_InterfaceBuilderFiles

基本上你会做类似的事情:

# Make sure we can find the 'ibtool' program. If we can NOT find it we
# skip generation of this project
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
    message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
endif()

set (NIBFILE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/input.nib)

add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD 
    COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text 
            --compile ${NIBFILE} ${XIB}
    COMMENT "Compiling input.xib")

set (SOURCES
    ${SOURCES}
    ${PLATFORM}
    ${XIB}
    ${NIBFILE}
)

set_source_files_properties(${NIBFILE}
    PROPERTIES
        MACOSX_PACKAGE_LOCATION "Resources/English.lproj"
        GENERATED 1
)

您需要设置 NIB 文件的位置,但请记住,您还需要将其设置为 GENERATED,因为第一次运行准备脚本时它不会存在。

于 2012-03-15T03:10:28.690 回答
0

问题解决了。请参阅此链接。这种方法有效。我的最终解决方案如下:

//projectDef.cmake

set(XIB "Mac/bundle_template/input.xib")

add_mac_plugin(${PROJECT_NAME} ${PLIST} ${STRINGS} ${LOCALIZED} SOURCES ${XIB})

//Mac.cmake in "add_mac_plugin" macro

if (${ARGC} GREATER 5)
add_library( ${PROJECT_NAME} MODULE
    ${SOURCES} 
    ${ARGN}
    )
else()
add_library( ${PROJECT_NAME} MODULE
    ${SOURCES} 
    )
endif()

if (${ARGC} GREATER 5)
set_target_properties(${PROJECT_NAME} PROPERTIES
    BUNDLE 1
    BUNDLE_EXTENSION plugin
    XCODE_ATTRIBUTE_WRAPPER_EXTENSION plugin  #sets the extension to .plugin
    XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle
    XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist
    MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist
    RESOURCE ${ARGN}
    LINK_FLAGS "-Wl,- exported_symbols_list,${FB_ESC_ROOT_DIR}/gen_templates/ExportList_plugin.txt")
else()
set_target_properties(${PROJECT_NAME} PROPERTIES
    BUNDLE 1
    BUNDLE_EXTENSION plugin
    XCODE_ATTRIBUTE_WRAPPER_EXTENSION plugin  #sets the extension to .plugin
    XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle
    XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist
    MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist
    LINK_FLAGS "-Wl,-exported_symbols_list,${FB_ESC_ROOT_DIR}/gen_templates/ExportList_plugin.txt")
endif()

我的修改好像不是很漂亮,我对cmake不是很了解。你好出租车司机,你能更新宏来支持像xib这样的外部资源吗?顺便说一句,非常感谢,伙计。

于 2012-03-16T03:11:54.423 回答