From a54e97cf946e82de6b73c26c64b7fe3efdf0be43 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 2 Sep 2008 11:07:04 -0400 Subject: [PATCH] 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. --- Tests/BundleTest/BundleLib.cxx | 7 +++++++ Tests/BundleTest/BundleTest.cxx | 11 +++++++++++ Tests/BundleTest/CMakeLists.txt | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Tests/BundleTest/BundleLib.cxx b/Tests/BundleTest/BundleLib.cxx index 4f353fba8..bab745e46 100644 --- a/Tests/BundleTest/BundleLib.cxx +++ b/Tests/BundleTest/BundleLib.cxx @@ -3,6 +3,8 @@ #include #include +#include + 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"); diff --git a/Tests/BundleTest/BundleTest.cxx b/Tests/BundleTest/BundleTest.cxx index 1e508ac09..29d17dbbe 100644 --- a/Tests/BundleTest/BundleTest.cxx +++ b/Tests/BundleTest/BundleTest.cxx @@ -1,9 +1,20 @@ #include +#include + 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]); } diff --git a/Tests/BundleTest/CMakeLists.txt b/Tests/BundleTest/CMakeLists.txt index 86e6232ac..5ccf2bf85 100644 --- a/Tests/BundleTest/CMakeLists.txt +++ b/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)