Ver código fonte

ENH: Add indirect dependency to Carbon and call a Carbon function from executable. This will allow detecting broken dependency chaining for '-framework blah' style lib dependencies.

David Cole 17 anos atrás
pai
commit
a54e97cf94

+ 7 - 0
Tests/BundleTest/BundleLib.cxx

@@ -3,6 +3,8 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <Carbon/Carbon.h>
+
 int fileExists(char* filename)
 {
 #ifndef R_OK
@@ -49,6 +51,11 @@ int findBundleFile(char* exec, const char* file)
 
 int foo(char *exec)
 {
+  // Call a "Carbon" function...
+  //
+  CFBundleRef br = CFBundleGetMainBundle();
+  (void) br;
+
   int res1 = findBundleFile(exec, "Resources/randomResourceFile.plist");
   int res2 = findBundleFile(exec, "MacOS/SomeRandomFile.txt");
   int res3 = findBundleFile(exec, "MacOS/ChangeLog.txt");

+ 11 - 0
Tests/BundleTest/BundleTest.cxx

@@ -1,9 +1,20 @@
 #include <stdio.h>
 
+#include <Carbon/Carbon.h>
+
 extern int foo(char* exec);
 
 int main(int argc, char* argv[])
 {
   printf("Started with: %d arguments\n", argc);
+
+  // Call a "Carbon" function... but pull in the link dependency on "-framework
+  // Carbon" via CMake's dependency chaining mechanism. This code exists to
+  // verify that the chaining mechanism works with "-framework blah" style
+  // link dependencies.
+  //
+  CFBundleRef br = CFBundleGetMainBundle();
+  (void) br;
+
   return foo(argv[0]);
 }

+ 13 - 2
Tests/BundleTest/CMakeLists.txt

@@ -24,8 +24,16 @@ SET_SOURCE_FILES_PROPERTIES(
 
 SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar")
 
-# Test building a bundle linking to a shared library.
+# Test building a bundle linking to a shared library where the
+# shared library links to Carbon, but the executable does not
+# explicitly link to Carbon, but the executable does *depend*
+# on Carbon. There should be a link failure for the executable
+# if CMake's dependency chaining for libraries with "-framework
+# blah" style dependencies gets broken...
+#
 ADD_LIBRARY(BundleTestLib SHARED BundleLib.cxx)
+TARGET_LINK_LIBRARIES(BundleTestLib "-framework Carbon")
+
 ADD_EXECUTABLE(BundleTest
   MACOSX_BUNDLE
   BundleTest.cxx
@@ -33,8 +41,11 @@ ADD_EXECUTABLE(BundleTest
   "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt"
   "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
   )
-
 TARGET_LINK_LIBRARIES(BundleTest BundleTestLib)
+#
+# DO NOT: TARGET_LINK_LIBRARIES(BundleTest "-framework Carbon")
+#   (see above comments about Carbon)
+#
 
 # Test bundle installation.
 #INSTALL(TARGETS BundleTestLib DESTINATION Applications/BundleTestExe.app/Contents/Plugins)