From 7bc7197f6ad64ec47a64b1633f157a09da0767e1 Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Fri, 14 Feb 2014 18:58:36 +0000 Subject: [PATCH] Use Cmake to generate app-bundle on Mac - build the .plist using CMake features - update the nightly Mac packaging script for the new layout --- CMakeModules/FlightGearBundleInfo.plist.in | 36 +++++++++++++++++++ package/mac/build-mac-nightly-dmg.rb | 40 +++------------------- package/mac/nightly.plist.in | 29 ---------------- src/Main/CMakeLists.txt | 36 +++++++++++++++++-- 4 files changed, 74 insertions(+), 67 deletions(-) create mode 100644 CMakeModules/FlightGearBundleInfo.plist.in delete mode 100644 package/mac/nightly.plist.in diff --git a/CMakeModules/FlightGearBundleInfo.plist.in b/CMakeModules/FlightGearBundleInfo.plist.in new file mode 100644 index 000000000..b45a34e3e --- /dev/null +++ b/CMakeModules/FlightGearBundleInfo.plist.in @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string> + <key>CFBundleGetInfoString</key> + <string>${MACOSX_BUNDLE_INFO_STRING}</string> + <key>CFBundleIconFile</key> + <string>${MACOSX_BUNDLE_ICON_FILE}</string> + <key>CFBundleIdentifier</key> + <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleLongVersionString</key> + <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string> + <key>CFBundleName</key> + <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string> + + <key>LSMinimumSystemVersion</key> + <string>10.6.0</string> + + <key>NSHumanReadableCopyright</key> + <string>${MACOSX_BUNDLE_COPYRIGHT}</string> +</dict> +</plist> diff --git a/package/mac/build-mac-nightly-dmg.rb b/package/mac/build-mac-nightly-dmg.rb index 575c837fd..8ea313d59 100755 --- a/package/mac/build-mac-nightly-dmg.rb +++ b/package/mac/build-mac-nightly-dmg.rb @@ -20,10 +20,6 @@ puts "Code signing identity is #{$codeSignIdentity}" puts "osgVersion=#{osgVersion}, so-number=#{$osgSoVersion}" -$svnLibs = ['svn_client', 'svn_wc', 'svn_delta', 'svn_diff', 'svn_ra', - 'svn_ra_local', 'svn_repos', 'svn_fs', 'svn_fs_fs', 'svn_fs_util', - 'svn_ra_svn', 'svn_subr', 'svn_ra_neon'] - def fix_install_names(object) #puts "fixing install names for #{object}" @@ -46,6 +42,11 @@ puts "Erasing previous image dir" `rm -rf #{dmgDir}` bundle=dmgDir + "/FlightGear.app" + +puts "Moving & renaming app bundle" +`mkdir -p #{dmgDir}` +`mv #{$prefixDir}/fgfs.app #{bundle}` + contents=bundle + "/Contents" macosDir=contents + "/MacOS" $frameworksDir=contents +"/Frameworks" @@ -53,25 +54,6 @@ resourcesDir=contents+"/Resources" osgPluginsDir=contents+"/PlugIns/osgPlugins-#{osgVersion}" volName="\"FlightGear Nightly Build\"" -def fix_svn_install_names(object) - $svnLibs.each do |l| - fileName = "lib#{l}-1.0.dylib" - newName = "@executable_path/../Frameworks/#{fileName}" - `install_name_tool -change #{fileName} #{newName} #{object}` - end -end - -def copy_svn_libs() - puts "Copying Subversion client libraries" - $svnLibs.each do |l| - libFile = "lib#{l}-1.0.dylib" - path = "#{$frameworksDir}/#{libFile}" - `cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}` - fix_svn_install_names(path) - # `install_name_tool -id #{libFile} #{path}` - end -end - def code_sign(path) puts "Signing #{path}" `codesign -s "#{$codeSignIdentity}" #{path}` @@ -82,7 +64,6 @@ fgVersion = File.read("#{srcDir}/version").strip dmgPath = Dir.pwd + "/fg_mac_nightly_#{fgVersion}.dmg" puts "Creating directory structure" -`mkdir -p #{macosDir}` `mkdir -p #{$frameworksDir}` `mkdir -p #{resourcesDir}` `mkdir -p #{osgPluginsDir}` @@ -97,7 +78,6 @@ bins.each do |b| outPath = "#{macosDir}/#{b}" `cp #{$prefixDir}/bin/#{b} #{outPath}` fix_install_names(outPath) - fix_svn_install_names(outPath) end puts "copying libraries" @@ -117,16 +97,6 @@ $osgPlugins.each do |p| fix_install_names("#{osgPluginsDir}/#{pluginFile}") end -copy_svn_libs() - -# Info.plist -template = File.read("#{srcDir}/package/mac/nightly.plist.in") -output = ERB.new(template).result(binding) - -File.open("#{contents}/Info.plist", 'w') { |f| - f.write(output) -} - `cp #{srcDir}/package/mac/nightly-readme.rtf #{dmgDir}/ReadMe.rtf` `cp #{srcDir}/package/mac/FlightGear.icns #{resourcesDir}/FlightGear.icns` `cp #{srcDir}/COPYING #{dmgDir}` diff --git a/package/mac/nightly.plist.in b/package/mac/nightly.plist.in deleted file mode 100644 index 8ad6f1207..000000000 --- a/package/mac/nightly.plist.in +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> -<dict> - <key>CFBundleIconFile</key> - <string>FlightGear.icns</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleGetInfoString</key> - <string>FlightGear nightly build</string> - <key>CFBundleSignature</key> - <string>????</string> - <key>CFBundleExecutable</key> - <string>FlightGear</string> - <key>CFBundleIdentifier</key> - <string>org.flightgear.FlightGear</string> - <key>CFBundleVersion</key> - <string><%= fgVersion %></string> - <key>CFBundleShortVersionString</key> - <string>unstable nightly build</string> - <key>LSMinimumSystemVersion</key> - <string>10.6.0</string> - <key>NSMainNibFile</key> - <string>MainMenu</string> - <key>NSPrincipalClass</key> - <string>NSApplication</string> -</dict> -</plist> - diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 5512db22d..e6475ea7f 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -70,7 +70,34 @@ source_group("Main\\Sources" FILES ${SOURCES}) # important we pass WIN32 here so the console is optional. Other # platforms ignore this option. If a console is needed we allocate # it manually via AllocConsole() -add_executable(fgfs WIN32 ${SOURCES} ${FG_SOURCES} ${FG_HEADERS} ${HEADERS}) +# similarly pass MACOSX_BUNDLE so we generate a .app on Mac +add_executable(fgfs WIN32 MACOSX_BUNDLE + ${SOURCES} ${FG_SOURCES} ${FG_HEADERS} ${HEADERS}) + +#----------------------------------------------------------------------------- +# MacOSX bundle packagaing + +if(APPLE) + execute_process(COMMAND date +%Y + OUTPUT_VARIABLE CURRENT_YEAR + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + # in our local CMakeModules dir + set_target_properties(fgfs PROPERTIES + MACOSX_BUNDLE_INFO_PLIST FlightGearBundleInfo.plist.in + MACOSX_BUNDLE_GUI_IDENTIFIER "org.flightgear.FlightGear" + MACOSX_BUNDLE_SHORT_VERSION_STRING ${FLIGHTGEAR_VERSION} + MACOSX_BUNDLE_LONG_VERSION_STRING "FlightGear ${FLIGHTGEAR_VERSION} Nightly" + MACOSX_BUNDLE_BUNDLE_VERSION ${FLIGHTGEAR_VERSION} + MACOSX_BUNDLE_COPYRIGHT "FlightGear ${FLIGHTGEAR_VERSION} © 1997-${CURRENT_YEAR}, The FlightGear Project. Licensed under the GNU Public License version 2." + MACOSX_BUNDLE_INFO_STRING "Nightly build of FlightGear ${FLIGHTGEAR_VERSION} for testing and development" + MACOSX_BUNDLE_BUNDLE_NAME "FlightGear" + MACOSX_BUNDLE_ICON_FILE "FlightGear.icns" + ) +endif() + +#----------------------------------------------------------------------------- get_property(FG_LIBS GLOBAL PROPERTY FG_LIBS) #message(STATUS "fg libs ${FG_LIBS}") @@ -110,7 +137,6 @@ target_link_libraries(fgfs ${OPENSCENEGRAPH_LIBRARIES} ${OPENGL_LIBRARIES} ${PLIB_LIBRARIES} - ${JPEG_LIBRARY} ${HLA_LIBRARIES} ${EVENT_INPUT_LIBRARIES} ${SIMGEAR_CORE_LIBRARY_DEPENDENCIES} @@ -118,7 +144,11 @@ target_link_libraries(fgfs ${PLATFORM_LIBS} ) -install(TARGETS fgfs RUNTIME DESTINATION bin) +if (APPLE) + install(TARGETS fgfs BUNDLE DESTINATION .) +else() + install(TARGETS fgfs RUNTIME DESTINATION bin) +endif() if(ENABLE_METAR) add_executable(metar metar_main.cxx)