summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorRichard Bateman <taxilian@gmail.com>2010-10-07 02:43:04 (GMT)
committerDavid Cole <david.cole@kitware.com>2011-01-11 17:54:44 (GMT)
commit5457b8254cb43e002fe90b7c81ae65134ec12b24 (patch)
tree5eddb832a213487dd64cd8adb5c2ea88bb3d2baa /Tests
parent6754b26bf0bb69ad6d65249bf4122dbbda446922 (diff)
downloadCMake-5457b8254cb43e002fe90b7c81ae65134ec12b24.zip
CMake-5457b8254cb43e002fe90b7c81ae65134ec12b24.tar.gz
CMake-5457b8254cb43e002fe90b7c81ae65134ec12b24.tar.bz2
Add support for CFBundle targets on the Mac (#11295)
This commit enables building, for example, plugin bundles to be loaded by web browsers.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CFBundleTest/CMakeLists.txt53
-rw-r--r--Tests/CFBundleTest/ExportList_plugin.txt3
-rw-r--r--Tests/CFBundleTest/Info.plist.in54
-rw-r--r--Tests/CFBundleTest/InfoPlist.strings.in4
-rw-r--r--Tests/CFBundleTest/Localized.r18
-rw-r--r--Tests/CFBundleTest/Localized.rsrcbin0 -> 496 bytes
-rw-r--r--Tests/CFBundleTest/PluginConfig.cmake21
-rw-r--r--Tests/CFBundleTest/README.txt16
-rw-r--r--Tests/CFBundleTest/VerifyResult.cmake32
-rw-r--r--Tests/CFBundleTest/np_macmain.cpp49
-rw-r--r--Tests/CMakeLists.txt15
11 files changed, 265 insertions, 0 deletions
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 @@
+<?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>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${PLUGIN_NAME}</string>
+ <key>CFBundleGetInfoString</key>
+ <string>${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION}, ${FBSTRING_LegalCopyright}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.${ACTIVEX_PROGID}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BRPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION}</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>${FBSTRING_PLUGIN_VERSION}</string>
+ <key>CFPlugInDynamicRegisterFunction</key>
+ <string></string>
+ <key>CFPlugInDynamicRegistration</key>
+ <string>NO</string>
+ <key>CFPlugInFactories</key>
+ <dict>
+ <key>00000000-0000-0000-0000-000000000000</key>
+ <string>MyFactoryFunction</string>
+ </dict>
+ <key>CFPlugInTypes</key>
+ <dict>
+ <key>00000000-0000-0000-0000-000000000000</key>
+ <array>
+ <string>00000000-0000-0000-0000-000000000000</string>
+ </array>
+ </dict>
+ <key>CFPlugInUnloadFunction</key>
+ <string></string>
+ <key>WebPluginName</key>
+ <string>${FBSTRING_ProductName}</string>
+ <key>WebPluginDescription</key>
+ <string>${FBSTRING_FileDescription}</string>
+ <key>WebPluginMIMETypes</key>
+ <dict>
+ <key>${FBSTRING_MIMEType}</key>
+ <dict>
+ <key>WebPluginTypeDescription</key>
+ <string>${FBSTRING_FileDescription}</string>
+ </dict>
+ </dict>
+</dict>
+</plist>
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 <CoreServices/CoreServices.r>
+
+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
--- /dev/null
+++ b/Tests/CFBundleTest/Localized.rsrc
Binary files 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 <stdio.h>
+
+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)