From 5457b8254cb43e002fe90b7c81ae65134ec12b24 Mon Sep 17 00:00:00 2001 From: Richard Bateman Date: Wed, 6 Oct 2010 20:43:04 -0600 Subject: Add support for CFBundle targets on the Mac (#11295) This commit enables building, for example, plugin bundles to be loaded by web browsers. --- Source/cmExportFileGenerator.cxx | 6 +++ Source/cmExportInstallFileGenerator.cxx | 14 +++++++ Source/cmGlobalXCodeGenerator.cxx | 55 ++++++++++++++++++++++++---- Source/cmMakefileLibraryTargetGenerator.cxx | 49 +++++++++++++++++++++++++ Source/cmMakefileLibraryTargetGenerator.h | 1 + Source/cmSourceFile.cxx | 6 ++- Source/cmTarget.cxx | 24 ++++++++++++ Source/cmTarget.h | 3 ++ Tests/CFBundleTest/CMakeLists.txt | 53 +++++++++++++++++++++++++++ Tests/CFBundleTest/ExportList_plugin.txt | 3 ++ Tests/CFBundleTest/Info.plist.in | 54 +++++++++++++++++++++++++++ Tests/CFBundleTest/InfoPlist.strings.in | 4 ++ Tests/CFBundleTest/Localized.r | 18 +++++++++ Tests/CFBundleTest/Localized.rsrc | Bin 0 -> 496 bytes Tests/CFBundleTest/PluginConfig.cmake | 21 +++++++++++ Tests/CFBundleTest/README.txt | 16 ++++++++ Tests/CFBundleTest/VerifyResult.cmake | 32 ++++++++++++++++ Tests/CFBundleTest/np_macmain.cpp | 49 +++++++++++++++++++++++++ Tests/CMakeLists.txt | 15 ++++++++ 19 files changed, 415 insertions(+), 8 deletions(-) create mode 100644 Tests/CFBundleTest/CMakeLists.txt create mode 100644 Tests/CFBundleTest/ExportList_plugin.txt create mode 100644 Tests/CFBundleTest/Info.plist.in create mode 100644 Tests/CFBundleTest/InfoPlist.strings.in create mode 100644 Tests/CFBundleTest/Localized.r create mode 100644 Tests/CFBundleTest/Localized.rsrc create mode 100644 Tests/CFBundleTest/PluginConfig.cmake create mode 100644 Tests/CFBundleTest/README.txt create mode 100644 Tests/CFBundleTest/VerifyResult.cmake create mode 100644 Tests/CFBundleTest/np_macmain.cpp diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e2a6035..9e5c91e 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -325,6 +325,12 @@ cmExportFileGenerator os << "SET_PROPERTY(TARGET " << targetName << " PROPERTY MACOSX_BUNDLE 1)\n"; } + + if (target->IsCFBundleOnApple()) + { + os << "SET_PROPERTY(TARGET " << targetName + << " PROPERTY BUNDLE 1)\n"; + } os << "\n"; } diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 717571c..23ff5fb 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -263,6 +263,20 @@ cmExportInstallFileGenerator value += ".framework/"; value += itgen->GetInstallFilename(target, config); } + else if(target->IsCFBundleOnApple()) + { + const char *ext = target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + ext = "bundle"; + } + + value += itgen->GetInstallFilename(target, config); + value += "."; + value += ext; + value += "/"; + value += itgen->GetInstallFilename(target, config); + } else if(target->IsAppBundleOnApple()) { value += itgen->GetInstallFilename(target, config); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 59ca38f..f58a15f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -570,6 +570,12 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, } } + if(cmtarget.IsCFBundleOnApple()) + { + cmtarget.SetProperty("PREFIX", ""); + cmtarget.SetProperty("SUFFIX", ""); + } + // Add the fileRef to the top level Resources group/folder if it is not // already there. // @@ -804,6 +810,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // some build phases only apply to bundles and/or frameworks bool isFrameworkTarget = cmtarget.IsFrameworkOnApple(); bool isBundleTarget = cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"); + bool isCFBundleTarget = cmtarget.IsCFBundleOnApple(); cmXCodeObject* buildFiles = 0; @@ -849,7 +856,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // create resource build phase - only for framework or bundle targets cmXCodeObject* resourceBuildPhase = 0; - if (!resourceFiles.empty() && (isFrameworkTarget || isBundleTarget)) + if (!resourceFiles.empty() && + (isFrameworkTarget || isBundleTarget || isCFBundleTarget)) { resourceBuildPhase = this->CreateObject(cmXCodeObject::PBXResourcesBuildPhase); @@ -870,7 +878,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // create vector of "non-resource content file" build phases - only for // framework or bundle targets std::vector contentBuildPhases; - if (isFrameworkTarget || isBundleTarget) + if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) { typedef std::map > mapOfVectorOfSourceFiles; @@ -1594,7 +1602,33 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("BUNDLE")); - if(this->XcodeVersion >= 22) + if (target.GetPropertyAsBool("BUNDLE")) + { + // It turns out that a BUNDLE is basically the same + // in many ways as an application bundle, as far as + // link flags go + std::string createFlags = + this->LookupFlags("CMAKE_SHARED_MODULE_CREATE_", lang, "_FLAGS", + "-bundle"); + if(!createFlags.empty()) + { + extraLinkOptions += " "; + extraLinkOptions += createFlags; + } + std::string plist = this->ComputeInfoPListLocation(target); + // Xcode will create the final version of Info.plist at build time, + // so let it replace the cfbundle name. This avoids creating + // a per-configuration Info.plist file. The cfbundle plist + // is very similar to the application bundle plist + this->CurrentLocalGenerator + ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", + plist.c_str()); + std::string path = + this->ConvertToRelativeForXCode(plist.c_str()); + buildSettings->AddAttribute("INFOPLIST_FILE", + this->CreateString(path.c_str())); + } + else if(this->XcodeVersion >= 22) { buildSettings->AddAttribute("MACH_O_TYPE", this->CreateString("mh_bundle")); @@ -1633,7 +1667,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string plist = this->ComputeInfoPListLocation(target); // Xcode will create the final version of Info.plist at build time, - // so let it replace the framework name. This avoids creating + // so let it replace the framework name. This avoids creating // a per-configuration Info.plist file. this->CurrentLocalGenerator ->GenerateFrameworkInfoPList(&target, "$(EXECUTABLE_NAME)", @@ -2032,7 +2066,10 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) case cmTarget::STATIC_LIBRARY: return "archive.ar"; case cmTarget::MODULE_LIBRARY: - return ((this->XcodeVersion >= 22)? + if (cmtarget.IsCFBundleOnApple()) + return "wrapper.plug-in"; + else + return ((this->XcodeVersion >= 22)? "compiled.mach-o.executable" : "compiled.mach-o.dylib"); case cmTarget::SHARED_LIBRARY: return (cmtarget.GetPropertyAsBool("FRAMEWORK")? @@ -2052,8 +2089,12 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(cmTarget& cmtarget) case cmTarget::STATIC_LIBRARY: return "com.apple.product-type.library.static"; case cmTarget::MODULE_LIBRARY: - return ((this->XcodeVersion >= 22)? "com.apple.product-type.tool" : - "com.apple.product-type.library.dynamic"); + if (cmtarget.IsCFBundleOnApple()) + return "com.apple.product-type.bundle"; + else + return ((this->XcodeVersion >= 22)? + "com.apple.product-type.tool" : + "com.apple.product-type.library.dynamic"); case cmTarget::SHARED_LIBRARY: return (cmtarget.GetPropertyAsBool("FRAMEWORK")? "com.apple.product-type.framework" : diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 049a338..1e9a670 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -26,6 +26,12 @@ cmMakefileLibraryTargetGenerator ::cmMakefileLibraryTargetGenerator(cmTarget* target): cmMakefileTargetGenerator(target) { + if(this->Target->IsCFBundleOnApple()) + { + target->SetProperty("PREFIX", ""); + target->SetProperty("SUFFIX", ""); + } + this->CustomCommandDriver = OnDepends; this->Target->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, @@ -41,6 +47,20 @@ cmMakefileLibraryTargetGenerator this->MacContentDirectory += this->FrameworkVersion; this->MacContentDirectory += "/"; } + else if(this->Target->IsCFBundleOnApple()) + { + this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName); + this->MacContentDirectory += "/"; + this->MacContentDirectory += this->TargetNameOut; + this->MacContentDirectory += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + ext = "bundle"; + } + this->MacContentDirectory += ext; + this->MacContentDirectory += "/Contents/"; + } } //---------------------------------------------------------------------------- @@ -301,6 +321,27 @@ cmMakefileLibraryTargetGenerator } //---------------------------------------------------------------------------- +void +cmMakefileLibraryTargetGenerator::CreateCFBundle(std::string& targetName, + std::string& outpath) +{ + // Compute bundle directory names. + outpath = this->MacContentDirectory; + outpath += "MacOS"; + cmSystemTools::MakeDirectory(outpath.c_str()); + this->Makefile->AddCMakeOutputFile(outpath.c_str()); + outpath += "/"; + + // Configure the Info.plist file. Note that it needs the executable name + // to be set. + std::string plist = this->MacContentDirectory + "Info.plist"; + this->LocalGenerator->GenerateAppleInfoPList(this->Target, + targetName.c_str(), + plist.c_str()); + this->Makefile->AddCMakeOutputFile(plist.c_str()); +} + +//---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteLibraryRules (const char* linkRuleVar, const char* extraFlags, bool relink) { @@ -354,6 +395,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules outpath = this->MacContentDirectory; this->CreateFramework(targetName); } + else if(this->Target->IsCFBundleOnApple()) + { + outpath = this->Target->GetDirectory(this->ConfigName); + outpath += "/"; + this->CreateCFBundle(targetName, outpath); + } else if(relink) { outpath = this->Makefile->GetStartOutputDirectory(); @@ -417,6 +464,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules buildEcho += " shared library "; break; case cmTarget::MODULE_LIBRARY: + if (this->Target->IsCFBundleOnApple()) + buildEcho += " CFBundle"; buildEcho += " shared module "; break; default: diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 2f085ad..f3c47db 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -33,6 +33,7 @@ protected: // MacOSX Framework support methods void WriteFrameworkRules(bool relink); void CreateFramework(std::string const& targetName); + void CreateCFBundle(std::string& targetName, std::string& outpath); // Store the computd framework version for OS X Frameworks. std::string FrameworkVersion; diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 26328cf..1c0c957 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -484,17 +484,21 @@ void cmSourceFile::DefineProperties(cmake *cm) cm->DefineProperty ("MACOSX_PACKAGE_LOCATION", cmProperty::SOURCE_FILE, - "Place a source file inside a Mac OS X bundle or framework.", + "Place a source file inside a Mac OS X bundle, CFBundle, or framework.", "Executable targets with the MACOSX_BUNDLE property set are built " "as Mac OS X application bundles on Apple platforms. " "Shared library targets with the FRAMEWORK property set are built " "as Mac OS X frameworks on Apple platforms. " + "Module library targets with the BUNDLE property set are built " + "as Mac OS X CFBundle bundles on Apple platforms. " "Source files listed in the target with this property set will " "be copied to a directory inside the bundle or framework content " "folder specified by the property value. " "For bundles the content folder is \".app/Contents\". " "For frameworks the content folder is " "\".framework/Versions/\". " + "For cfbundles the content folder is " + "\".bundle/Contents\" (unless the extension is changed). " "See the PUBLIC_HEADER, PRIVATE_HEADER, and RESOURCE target " "properties for specifying files meant for Headers, PrivateHeaders, " "or Resources directories."); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9a698c0..6e33b71 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -194,6 +194,22 @@ void cmTarget::DefineProperties(cmake *cm) "the target is built."); cm->DefineProperty + ("BUNDLE", cmProperty::TARGET, + "This target is a CFBundle on the Mac.", + "If a module library target has this property set to true it will " + "be built as a CFBundle when built on the mac. It will have the " + "directory structure required for a CFBundle and will be suitable " + "to be used for creating Browser Plugins or other application " + "resources."); + + cm->DefineProperty + ("BUNDLE_EXTENSION", cmProperty::TARGET, + "The file extension used to name a BUNDLE target on the Mac.", + "The default value is \"bundle\" - you can also use \"plugin\" or " + "whatever file extension is required by the host app for your " + "bundle."); + + cm->DefineProperty ("FRAMEWORK", cmProperty::TARGET, "This target is a framework on the Mac.", "If a shared library target has this property set to true it will " @@ -1204,6 +1220,14 @@ bool cmTarget::IsAppBundleOnApple() } //---------------------------------------------------------------------------- +bool cmTarget::IsCFBundleOnApple() +{ + return (this->GetType() == cmTarget::MODULE_LIBRARY && + this->Makefile->IsOn("APPLE") && + this->GetPropertyAsBool("BUNDLE")); +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f2b7d61..b0e20ba 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -430,6 +430,9 @@ public: Apple. */ bool IsFrameworkOnApple(); + /** Return whether this target is a CFBundle (plugin) on Apple. */ + bool IsCFBundleOnApple(); + /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple(); diff --git a/Tests/CFBundleTest/CMakeLists.txt b/Tests/CFBundleTest/CMakeLists.txt new file mode 100644 index 0000000..347578b --- /dev/null +++ b/Tests/CFBundleTest/CMakeLists.txt @@ -0,0 +1,53 @@ +#this is adapted from FireBreath (http://www.firebreath.org) + +cmake_minimum_required(VERSION 2.8) + +project(CFBundleTest) + +include(PluginConfig.cmake) + +message ("Creating Mac Browser Plugin project ${PROJECT_NAME}") +set(SOURCES + np_macmain.cpp + Localized.r + ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings + ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc +) + +add_library( ${PROJECT_NAME} MODULE + ${SOURCES} + ) + +set (RCFILES ${CMAKE_CURRENT_SOURCE_DIR}/Localized.r) + +configure_file(Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) +configure_file(InfoPlist.strings.in ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings) + +# Compile the resource file +find_program(RC_COMPILER Rez NO_DEFAULT_PATHS) + +execute_process(COMMAND + ${RC_COMPILER} ${RCFILES} -useDF -o ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + ) + +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + PROPERTIES GENERATED 1 + ) +# note that for some reason, the makefile and xcode generators use a different +# property to indicate where the Info.plist file is :-/ For that reason, we +# specify it twice so it will work both places +set_target_properties(CFBundleTest PROPERTIES + BUNDLE 1 + BUNDLE_EXTENSION plugin + XCODE_ATTRIBUTE_WRAPPER_EXTENSION plugin #sets the extension to .plugin + XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle + XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + LINK_FLAGS "-Wl,-exported_symbols_list,\"${CMAKE_CURRENT_SOURCE_DIR}/ExportList_plugin.txt\"") + +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings + ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/English.lproj") diff --git a/Tests/CFBundleTest/ExportList_plugin.txt b/Tests/CFBundleTest/ExportList_plugin.txt new file mode 100644 index 0000000..31d6f64 --- /dev/null +++ b/Tests/CFBundleTest/ExportList_plugin.txt @@ -0,0 +1,3 @@ +_NP_GetEntryPoints +_NP_Initialize +_NP_Shutdown diff --git a/Tests/CFBundleTest/Info.plist.in b/Tests/CFBundleTest/Info.plist.in new file mode 100644 index 0000000..638002f --- /dev/null +++ b/Tests/CFBundleTest/Info.plist.in @@ -0,0 +1,54 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${PLUGIN_NAME} + CFBundleGetInfoString + ${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION}, ${FBSTRING_LegalCopyright} + CFBundleIdentifier + com.${ACTIVEX_PROGID} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BRPL + CFBundleShortVersionString + ${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION} + CFBundleSignature + ???? + CFBundleVersion + ${FBSTRING_PLUGIN_VERSION} + CFPlugInDynamicRegisterFunction + + CFPlugInDynamicRegistration + NO + CFPlugInFactories + + 00000000-0000-0000-0000-000000000000 + MyFactoryFunction + + CFPlugInTypes + + 00000000-0000-0000-0000-000000000000 + + 00000000-0000-0000-0000-000000000000 + + + CFPlugInUnloadFunction + + WebPluginName + ${FBSTRING_ProductName} + WebPluginDescription + ${FBSTRING_FileDescription} + WebPluginMIMETypes + + ${FBSTRING_MIMEType} + + WebPluginTypeDescription + ${FBSTRING_FileDescription} + + + + diff --git a/Tests/CFBundleTest/InfoPlist.strings.in b/Tests/CFBundleTest/InfoPlist.strings.in new file mode 100644 index 0000000..790ead0 --- /dev/null +++ b/Tests/CFBundleTest/InfoPlist.strings.in @@ -0,0 +1,4 @@ +/* Localized versions of Info.plist keys */ + +CFBundleName = "${PLUGIN_NAME}.plugin"; +NSHumanReadableCopyright = "${FBSTRING_LegalCopyright}"; diff --git a/Tests/CFBundleTest/Localized.r b/Tests/CFBundleTest/Localized.r new file mode 100644 index 0000000..e988e26 --- /dev/null +++ b/Tests/CFBundleTest/Localized.r @@ -0,0 +1,18 @@ +#include + +resource 'STR#' (126) +{ { + "${FBSTRING_LegalCopyright}", + "${FBSTRING_ProductName}" +} }; + +resource 'STR#' (127) +{ { + "${FBSTRING_FileDescription}" +} }; + +resource 'STR#' (128) +{ { + "${FBSTRING_MIMEType}", + "${FBSTRING_FileExtents}" +} }; diff --git a/Tests/CFBundleTest/Localized.rsrc b/Tests/CFBundleTest/Localized.rsrc new file mode 100644 index 0000000..cbf3523 Binary files /dev/null and b/Tests/CFBundleTest/Localized.rsrc differ diff --git a/Tests/CFBundleTest/PluginConfig.cmake b/Tests/CFBundleTest/PluginConfig.cmake new file mode 100644 index 0000000..763ddcc --- /dev/null +++ b/Tests/CFBundleTest/PluginConfig.cmake @@ -0,0 +1,21 @@ +#/**********************************************************\ +# Auto-Generated Plugin Configuration file +# for CFTestPlugin +#\**********************************************************/ + +set(PLUGIN_NAME "CFTestPlugin") +set(PLUGIN_PREFIX "CFTP") +set(COMPANY_NAME "FBDevTeam") + +set(MOZILLA_PLUGINID "@firebreath.googlecode.com/CFTestPlugin") + +# strings +set(FBSTRING_CompanyName "Firebreath Dev Team") +set(FBSTRING_FileDescription "CFBundle Test Plugin - Plugin for testing cmake patch to improve FireBreath project generation") +set(FBSTRING_PLUGIN_VERSION "1.0.0") +set(FBSTRING_LegalCopyright "Copyright 2010 Firebreath Dev Team") +set(FBSTRING_PluginFileName "np${PLUGIN_NAME}.dll") +set(FBSTRING_ProductName "CFTestPlugin") +set(FBSTRING_FileExtents "") +set(FBSTRING_PluginName "CFTestPlugin") +set(FBSTRING_MIMEType "application/x-fbtestplugin") diff --git a/Tests/CFBundleTest/README.txt b/Tests/CFBundleTest/README.txt new file mode 100644 index 0000000..248651b --- /dev/null +++ b/Tests/CFBundleTest/README.txt @@ -0,0 +1,16 @@ + +CFBundle test project. The generated .plugin/ bundle from either makefiles or XCode should look like this: + +./Contents +./Contents/Info.plist +./Contents/MacOS +./Contents/MacOS/CFBundleTest +./Contents/Resources +./Contents/Resources/English.lproj +./Contents/Resources/English.lproj/InfoPlist.strings +./Contents/Resources/English.lproj/Localized.rsrc + +file Contents/MacOS/CFBundleTest should return something like: +Contents/MacOS/CFBundleTest: Mach-O 64-bit bundle x86_64 + +It is okay if it is a 32 bit binary; if it is not Mach-O, or is spelled differently, it is not okay. diff --git a/Tests/CFBundleTest/VerifyResult.cmake b/Tests/CFBundleTest/VerifyResult.cmake new file mode 100644 index 0000000..e622900 --- /dev/null +++ b/Tests/CFBundleTest/VerifyResult.cmake @@ -0,0 +1,32 @@ +if(NOT DEFINED CTEST_CONFIGURATION_TYPE) + message(FATAL_ERROR "expected variable CTEST_CONFIGURATION_TYPE not defined") +endif() + +if(NOT DEFINED dir) + message(FATAL_ERROR "expected variable dir not defined") +endif() + +if(NOT DEFINED gen) + message(FATAL_ERROR "expected variable gen not defined") +endif() + +message(STATUS "CTEST_CONFIGURATION_TYPE='${CTEST_CONFIGURATION_TYPE}'") +message(STATUS "dir='${dir}'") +message(STATUS "gen='${gen}'") + +if(gen MATCHES "Make" OR + "${CTEST_CONFIGURATION_TYPE}" STREQUAL "" OR + "${CTEST_CONFIGURATION_TYPE}" STREQUAL "." OR + "${CTEST_CONFIGURATION_TYPE}" STREQUAL "NoConfig") + set(expected_filename "${dir}/CFBundleTest.plugin/Contents/MacOS/CFBundleTest") +else() + set(expected_filename "${dir}/${CTEST_CONFIGURATION_TYPE}/CFBundleTest.plugin/Contents/MacOS/CFBundleTest") +endif() + +if(NOT EXISTS "${expected_filename}") + message(FATAL_ERROR "test fails: expected output file does not exist [${expected_filename}]") +endif() + +file(COPY "${expected_filename}" + DESTINATION "${dir}/LatestBuildResult" + ) diff --git a/Tests/CFBundleTest/np_macmain.cpp b/Tests/CFBundleTest/np_macmain.cpp new file mode 100644 index 0000000..78004d0 --- /dev/null +++ b/Tests/CFBundleTest/np_macmain.cpp @@ -0,0 +1,49 @@ +/***********************************************************\ + Written by: Richard Bateman (taxilian) + + Based on the default np_macmain.cpp from FireBreath + http://firebreath.googlecode.com + + This file has been stripped to prevent it from accidently + doing anything useful. +\***********************************************************/ + + +#include + +typedef void (*NPP_ShutdownProcPtr)(void); +typedef short NPError; + +#pragma GCC visibility push(default) + +struct NPNetscapeFuncs; +struct NPPluginFuncs; + +extern "C" { + NPError NP_Initialize(NPNetscapeFuncs *browserFuncs); + NPError NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); + NPError NP_Shutdown(void); +} + +#pragma GCC visibility pop + +void initPluginModule() +{ +} + +NPError NP_GetEntryPoints(NPPluginFuncs* pFuncs) +{ + printf("NP_GetEntryPoints()\n"); + return 0; +} + +NPError NP_Initialize(NPNetscapeFuncs* pFuncs) +{ + printf("NP_Initialize()\n"); + return 0; +} + +NPError NP_Shutdown() +{ + return 0; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index faaa177..3da12d9 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1110,6 +1110,21 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest") + ADD_TEST(CFBundleTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CFBundleTest" + "${CMake_BINARY_DIR}/Tests/CFBundleTest" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project CFBundleTest + --test-command + ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE} + -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest + -Dgen=${CMAKE_TEST_GENERATOR} + -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest") + ADD_TEST_MACRO(ObjC++ ObjC++) ENDIF (APPLE AND CMAKE_COMPILER_IS_GNUCXX) -- cgit v0.12 From cabc407912bb3bc0bb954e317a999cb2ee64de57 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 11 Jan 2011 16:48:37 -0500 Subject: CFBundle Test: Add PATHS for finding Rez (#11295) Some older dashboard machines do not have Rez in /usr/bin like us modern folk. But most of them will have it in /Developer/Tools... So make sure we look there. --- Tests/CFBundleTest/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/CFBundleTest/CMakeLists.txt b/Tests/CFBundleTest/CMakeLists.txt index 347578b..8fd9efd 100644 --- a/Tests/CFBundleTest/CMakeLists.txt +++ b/Tests/CFBundleTest/CMakeLists.txt @@ -25,7 +25,10 @@ configure_file(Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) configure_file(InfoPlist.strings.in ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings) # Compile the resource file -find_program(RC_COMPILER Rez NO_DEFAULT_PATHS) +find_program(RC_COMPILER Rez NO_DEFAULT_PATHS PATHS /Developer/Tools) +if(NOT RC_COMPILER) + message(FATAL_ERROR "could not find Rez to build resources from .r file...") +endif() execute_process(COMMAND ${RC_COMPILER} ${RCFILES} -useDF -o ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc -- cgit v0.12