[Cmake] Mac OS X .app bundle making script - double-clickable mac application

Andy Cedilnik andy.cedilnik at kitware.com
Thu Jun 10 12:48:53 EDT 2004


Hi Eric,

As I said, this feature has not been tested a lot yet. I think you will
have to create a post install rule on the target to get everything
working. That said, new install framework allows you to do this pretty
easily. You can actually use FILE(GLOB to get the list of files.

You should create let say install_macosx_bundle.cmake.on file which says
something like:

FILE(GLOB_RECURSE MACOSX_FILES_FOR_INSTALL
"@EXECUTABLE_OUTPUT_PATH@/myapp.app")
MESSAGE(STATUS "Installing MacOSX bundle.")
FILE(INSTALL
  DESTINATION "@CMAKE_INSTALL_PREFIX@/Application"
  TYPE FILE
  FILES ${MACOSXFILES_FOR_INSTALL}) 

Unfortunately that will not set permissions right. I guess you would
have to add special FILE(INSTALL for the executable.

I guess you could do:

FILE(GLOB_RECURSE MACOSX_FILES_FOR_INSTALL
"@EXECUTABLE_OUTPUT_PATH@/myapp.app")
MESSAGE(STATUS "Installing MacOSX bundle.")
SET(files)
SET(execs)
FOREACH(file ${MACOSX_FILES_FOR_INSTALL})
  IF("${file}" MATCHES "MacOS/myapp$")
    SET(execs ${execs} ${file})
  ELSE("${file}" MATCHES "MacOS/myapp$")
    SET(files ${files} ${file})
  ENDIF("${file}" MATCHES "MacOS/myapp$")
ENDFOREACH(file)
FILE(INSTALL
  DESTINATION "@CMAKE_INSTALL_PREFIX@/Application"
  TYPE FILE
  FILES ${files}) 
FILE(INSTALL
  DESTINATION "@CMAKE_INSTALL_PREFIX@/Application"
  TYPE EXECUTABLE
  FILES ${execs}) 

After that, you do

ADD_EXECUTABLE(myapp MACOSX_BUNDLE ...)

you say:
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/install_macosx_bundle.cmake.in
  ${CMAKE_CURRENT_SOURCE_DIR}/install_macosx_bundle.cmake)

and

SET_TARGET_PROPERTIES(myapp PROPERTIES
  POST_INSTALL_SCRIPT
"${CMAKE_CURRENT_BINARY_DIR}/install_macosx_bundle.cmake")

This should do the trick.

Also, make sure not to do INSTALL_TARGET(... myapp) because it will not
work. I created a bug report for this and will hopefully fix it at some
point.

			Andy


On Thu, 2004-06-10 at 12:22, Eric Wing wrote:
> Out of curiosity, will the Install target rules work
> with the .app bundles now in 2.0? I remember in 1.8.3,
> I couldn't figure out how to bundles except by listing
> every subfile inside the bundle (directory) structure.
> It would be nice if if CMake would just treat the
> whole bundle as a single package.




More information about the Cmake mailing list