Thunderforge
Thunderforge

Reputation: 20585

How can I set NSHighResolutionCapable in Info.plist via CMake?

I am currently using CMake to build a Mac app. I can set a number of Info.plist files with commands like this:

SET(MACOSX_BUNDLE_LONG_VERSION_STRING ${MYAPP_VERSION})

I would like to set NSHighResolutionCapable in my Info.plist file. Unfortunately, there isn't a property like MACOSX_BUNDLE_HIGH_RESOLUTION_CAPABLE. How can I set this Info.plist value programmatically with CMake?

Upvotes: 1

Views: 2547

Answers (2)

bear24rw
bear24rw

Reputation: 4627

Another solution is to run a post build command to modify the plist:

  add_custom_command(
      TARGET foobar
      POST_BUILD
      COMMAND plutil -replace NSHighResolutionCapable -bool true foobar.app/Contents/Info.plist
      )

Upvotes: 2

frang
frang

Reputation: 97

You can`t. You only can edit from CMake a few set of Info.plist properties. Show here. But you can provide your own Info.plist template for use in your OSX Bundles in CMake. Here´s the code I use:

function(osxBundle bundleName subDirList dependList)

    processTarget("${bundleName}" APPLE_BUNDLE "${subDirList}" "${dependList}")

    # Info.plist configure
    # Proyect provides its own Info.plist?
    if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
        set_target_properties(${bundleName} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
    # Use default template
    else()
        set_target_properties(${bundleName} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SCRIPTS_PATH}/Info.plist)
    endif()

    # Overwrite some properties (not used yet)
    # MACOSX_BUNDLE_BUNDLE_NAME
    # MACOSX_BUNDLE_BUNDLE_VERSION
    # MACOSX_BUNDLE_COPYRIGHT
    # MACOSX_BUNDLE_GUI_IDENTIFIER
    # set_target_properties(${bundleName} PROPERTIES MACOSX_BUNDLE_ICON_FILE logo.icns)
    # MACOSX_BUNDLE_INFO_STRING
    # MACOSX_BUNDLE_LONG_VERSION_STRING
    # MACOSX_BUNDLE_SHORT_VERSION_STRING

    target_link_libraries(${bundleName} ${COCOA_LIB})

endfunction()

Upvotes: 3

Related Questions