[CMake] installing resources in mac app on cmake 2.6

David Cole david.cole at kitware.com
Mon Apr 7 13:55:15 EDT 2008


This is a snippet from the CMake source tree, in the file
CMake/Tests/BundleTest/CMakeLists.txt :

<snippet>
SET_SOURCE_FILES_PROPERTIES(
  "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
  PROPERTIES
  MACOSX_PACKAGE_LOCATION Resources
  )

SET_SOURCE_FILES_PROPERTIES(
  SomeRandomFile.txt
  "${CMake_SOURCE_DIR}/ChangeLog.txt"
  PROPERTIES
  MACOSX_PACKAGE_LOCATION MacOS
  )

SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar")

# Test building a bundle linking to a shared library.
ADD_LIBRARY(BundleTestLib SHARED BundleLib.cxx)
ADD_EXECUTABLE(BundleTest
  MACOSX_BUNDLE
  BundleTest.cxx
  SomeRandomFile.txt
  "${CMake_SOURCE_DIR}/ChangeLog.txt"
  "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
  )
</snippet>


It should be as simple as adding the resource files as sources to your
executable that has the MACOSX_BUNDLE flag on and then:

SET_SOURCE_FILES_PROPERTIES(
  "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
  PROPERTIES
  MACOSX_PACKAGE_LOCATION Resources
  )

When you have the MACOSX_PACKAGE_LOCATION set and the file is added as a
source, it should be copied into the .app bundle during a "make" (or a build
with Xcode).


HTH,
David


On Mon, Apr 7, 2008 at 12:16 PM, Mattias Holm <mattias.holm at contra.nu>
wrote:

> Hi,
>
> I asked about this before, but i think it was lost in all the other talk
> of cmake 2.6 at that moment.
>
> How do I ensure that resources added to the resource list of an
> application is installed in the MacOS X application bundle?
>
> Will it be done during the normal build (i.e. without typing make
> install), and will it in that case avoid copying files if they have not
> changed (some resource files can be quite heavy).
>
> I tried adding the resource files to the the application, but they were
> not installed in the app bundle on a plain "make".
>
> Do I need to do something with the install command as well?
>
>
> / Mattias
>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080407/a5a79a57/attachment.htm>


More information about the CMake mailing list