CMake:Bundles And Frameworks

From KitwarePublic
Jump to navigationJump to search

Issue

(In all examples, the applications are named appl1, appl2, ..., libraries are named libr1, libr2, ..., header files are named appl1_header1, appl2_header2, libr1_header1, ..., and there are auxilary files associated with application and library appl1_aux1, appl2_aux2, libr1_aux1, .... and some resource files associated with application and library appl1_res1, appl2_res2, libr1_res1, .... All versions are ver1, ver2, ...)

On Mac there are several different cases of combinations of bundles, frameworks, and unix tools.

The problem is that CMAKE_INSTALL_PREFIX is not enough. Also, when creating bundles and frameworks, auxilary files should be in the proper subdirectory structure.

Cases

Unix tools only

  • No issues (just like any other unix)

Bundle only

  • Everything in a same directory:
/Applications/
             appl1.app/
                      Contents/
                              Info.plist
                              MacOS/
                                   appl1 -> appl1-1
                                   appl1-1
                                   appl1_aux1
                                   appl1_aux2
                              Resources/
                                   appl1_res1
                                   appl1_res2
  • Suggested api:
ADD_EXECUTABLE(
  appl1
  MACOSX_BUNDLE
  appl1_src1.cxx
  appl1_src2.cxx
  ...
  BUNDLE_CONTENT
  apple1_aux1
  apple1_aux2
  apple1_res1
  apple1_res2
  )

SET_SOURCE_FILES_PROPERTIES(
  apple1_aux1
  apple1_aux2
  PROPERTIES
  BUNDLE_LOCATION MacOSX
  )
SET_SOURCE_FILES_PROPERTIES(
  apple1_res1
  apple1_res2
  PROPERTIES
  BUNDLE_LOCATION Resources
  )

Framework only

  • Everything in a same directory:
/Library/
        Frameworks/
                  libr1.framework/
                                 libr1     -> Versions/Current/libr1
                                 Resources -> Versions/Current/Resources
                                 Libraries -> Versions/Current/Libraries
                                 Headers   -> Versions/Current/Headers
                                 Versions/
                                         Current -> ver2
                                         ver2/
                                             libr1
                                             Resources/
                                                      Info.plist
                                                      version.plist
                                             Libraries/
                                                      libr2.dylib
                                                      libr3.dylib
                                             Headers/
                                                    libr1_header1.h
                                                    libr1_header2.h
                                                    libr1_header3.h

Bundle + Framework

  • Bundle stuff in one directory, framework stuff in another one
/Applications/
             appl1.app/
                      Contents/
                              Info.plist
                              MacOS/
                                   appl1 -> appl1-ver1
                                   appl1-ver2
                                   appl1_aux1
                                   appl1_aux2
                              Resources/
                                   appl1_res1
                                   appl1_res2
/Library/
        Frameworks/
                  libr1.framework/
                                 libr1     -> Versions/Current/libr1
                                 Resources -> Versions/Current/Resources
                                 Libraries -> Versions/Current/Libraries
                                 Headers   -> Versions/Current/Headers
                                 Versions/
                                         Current -> ver2
                                         ver2/
                                             libr1
                                             Resources/
                                                      Info.plist
                                                      version.plist
                                             Libraries/
                                                      libr2.dylib
                                                      libr3.dylib
                                             Headers/
                                                    libr1_header1.h
                                                    libr1_header2.h
                                                    libr1_header3.h
  • Suggested api:
ADD_EXECUTABLE(
  appl1
  MACOSX_BUNDLE
  appl1_src1.cxx
  appl1_src2.cxx
  ...
  BUNDLE_CONTENT
  apple1_aux1
  apple1_aux2
  apple1_res1
  apple1_res2
  )

SET_SOURCE_FILES_PROPERTIES(
  apple1_aux1
  apple1_aux2
  PROPERTIES
  BUNDLE_LOCATION MacOSX
  )
SET_SOURCE_FILES_PROPERTIES(
  apple1_res1
  apple1_res2
  PROPERTIES
  BUNDLE_LOCATION Resources
  )

Bundle + Unix tools

  • Bundle stuff in one directory, unix tools in typical unix location
/Applications/
             appl1.app/
                      Contents/
                              Info.plist
                              MacOS/
                                   appl1 -> appl1-ver1
                                   appl1-ver2
                                   appl1_aux1
                                   appl1_aux2
                              Resources/
                                   appl1_res1
                                   appl1_res2

/usr/
    bin/
       appl2
    share/
       appl2-version/
                    appl2_aux1
                    appl2_aux2

Framework + Unix tools

  • Framework stuff in one directory, unix tools in typical unix location
/Library/
        Frameworks/
                  libr1.framework/
                                 libr1     -> Versions/Current/libr1
                                 Resources -> Versions/Current/Resources
                                 Libraries -> Versions/Current/Libraries
                                 Headers   -> Versions/Current/Headers
                                 Commands  -> Versions/Current/Commands
                                 Versions/
                                         Current -> ver2
                                         ver2/
                                             libr1
                                             Resources/
                                                      Info.plist
                                                      version.plist
                                             Libraries/
                                                      libr2.dylib
                                                      libr3.dylib
                                             Headers/
                                                    libr1_header1.h
                                                    libr1_header2.h
                                                    libr1_header3.h
                                             Commands/
                                                     appl2
                                             bin/
                                                appl3
/usr/
    bin/
       appl1
       appl2 -> /Library/Frameworks/libr1.framework/Commands/appl2
       appl3 -> /Library/Frameworks/libr1.framework/Version/ver1/bin/appl3
    share/
       appl1-version/
                    appl1_aux1
                    appl1_aux2

Bundle + Framework + Unix tools

  • Framework stuff in one directory, unix tools in typical unix location
/Applications/
             appl1.app/
                      Contents/
                              Info.plist
                              MacOS/
                                   appl1 -> appl1-ver1
                                   appl1-ver2
                                   appl1_aux1
                                   appl1_aux2
                              Resources/
                                   appl1_res1
                                   appl1_res2
/Library/
        Frameworks/
                  libr1.framework/
                                 libr1     -> Versions/Current/libr1
                                 Resources -> Versions/Current/Resources
                                 Libraries -> Versions/Current/Libraries
                                 Headers   -> Versions/Current/Headers
                                 Commands  -> Versions/Current/Commands
                                 Versions/
                                         Current -> ver2
                                         ver2/
                                             libr1
                                             Resources/
                                                      Info.plist
                                                      version.plist
                                             Libraries/
                                                      libr2.dylib
                                                      libr3.dylib
                                             Headers/
                                                    libr1_header1.h
                                                    libr1_header2.h
                                                    libr1_header3.h
                                             Commands/
                                                     appl2
                                             bin/
                                                appl3
/usr/
    bin/
       appl1
       appl2 -> /Library/Frameworks/libr1.framework/Commands/appl2
       appl3 -> /Library/Frameworks/libr1.framework/Version/ver1/bin/appl3
    share/
         appl1-version/
                      appl1_aux1
                      appl1_aux2