From e17135e882188145e04c2ff455fad01273fdb375 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Thu, 2 Jun 2011 09:08:49 -0600 Subject: BundleUtilities: Add rpath to loadable modules in test. --- Tests/BundleUtilities/CMakeLists.txt | 54 ++++++++++++++++++------------ Tests/BundleUtilities/testbundleutils.cpp | 33 ------------------ Tests/BundleUtilities/testbundleutils1.cpp | 33 ++++++++++++++++++ Tests/BundleUtilities/testbundleutils2.cpp | 33 ++++++++++++++++++ 4 files changed, 99 insertions(+), 54 deletions(-) delete mode 100644 Tests/BundleUtilities/testbundleutils.cpp create mode 100644 Tests/BundleUtilities/testbundleutils1.cpp create mode 100644 Tests/BundleUtilities/testbundleutils2.cpp diff --git a/Tests/BundleUtilities/CMakeLists.txt b/Tests/BundleUtilities/CMakeLists.txt index be2b058..6209c8f 100644 --- a/Tests/BundleUtilities/CMakeLists.txt +++ b/Tests/BundleUtilities/CMakeLists.txt @@ -9,12 +9,6 @@ add_library(shared SHARED shared.cpp shared.h) # another shared library add_library(shared2 SHARED shared2.cpp shared2.h) -# a loadable module (depends on shared2) -# test app will load this at runtime -add_library(module MODULE module.cpp module.h) -set_target_properties(module PROPERTIES PREFIX "") -get_target_property(module_loc module LOCATION) -target_link_libraries(module shared2) # a framework library add_library(framework SHARED framework.cpp framework.h) @@ -22,28 +16,37 @@ add_library(framework SHARED framework.cpp framework.h) #set_target_properties(framework PROPERTIES FRAMEWORK 1) # make sure rpaths are not helping BundleUtilities or the executables -set_target_properties(shared shared2 module framework PROPERTIES +set_target_properties(shared shared2 framework PROPERTIES SKIP_BUILD_RPATH 1) ###### test a Bundle application using dependencies -set(TESTBUNDLEDIR "${CMAKE_CURRENT_BINARY_DIR}/testdir1") -add_executable(testbundleutils1 MACOSX_BUNDLE testbundleutils.cpp) +# a loadable module (depends on shared2) +# testbundleutils1 will load this at runtime +add_library(module1 MODULE module.cpp module.h) +set_target_properties(module1 PROPERTIES PREFIX "") +get_target_property(module_loc module1 LOCATION) +target_link_libraries(module1 shared2) + +# a bundle application +add_executable(testbundleutils1 MACOSX_BUNDLE testbundleutils1.cpp) target_link_libraries(testbundleutils1 shared framework ${CMAKE_DL_LIBS}) -set_target_properties(testbundleutils1 PROPERTIES - INSTALL_RPATH "${TESTBUNDLEDIR}" - BUILD_WITH_INSTALL_RPATH 1) get_target_property(loc testbundleutils1 LOCATION) +set_target_properties(testbundleutils1 module1 PROPERTIES + INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir1" + BUILD_WITH_INSTALL_RPATH 1) + +# add custom target to install and test the app add_custom_target(testbundleutils1_test ALL COMMAND ${CMAKE_COMMAND} "-DINPUT=${loc}" "-DMODULE=${module_loc}" "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" - "-DOUTPUTDIR=${TESTBUNDLEDIR}" + "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir1" -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" - DEPENDS testbundleutils1 module + DEPENDS testbundleutils1 module1 ) add_dependencies(testbundleutils1_test testbundleutils1) @@ -52,21 +55,30 @@ add_dependencies(testbundleutils1_test testbundleutils1) ###### test a non-Bundle application using dependencies -set(TESTBUNDLEDIR "${CMAKE_CURRENT_BINARY_DIR}/testdir2") -add_executable(testbundleutils2 testbundleutils.cpp) +# a loadable module (depends on shared2) +# testbundleutils2 will load this at runtime +add_library(module2 MODULE module.cpp module.h) +set_target_properties(module2 PROPERTIES PREFIX "") +get_target_property(module_loc module2 LOCATION) +target_link_libraries(module2 shared2) + +# a non-bundle application +add_executable(testbundleutils2 testbundleutils2.cpp) target_link_libraries(testbundleutils2 shared framework ${CMAKE_DL_LIBS}) -set_target_properties(testbundleutils2 PROPERTIES - INSTALL_RPATH "${TESTBUNDLEDIR}" - BUILD_WITH_INSTALL_RPATH 1) get_target_property(loc testbundleutils2 LOCATION) +set_target_properties(testbundleutils2 module2 PROPERTIES + INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir2" + BUILD_WITH_INSTALL_RPATH 1) + +# add custom target to install and test the app add_custom_target(testbundleutils2_test ALL COMMAND ${CMAKE_COMMAND} "-DINPUT=${loc}" "-DMODULE=${module_loc}" "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" - "-DOUTPUTDIR=${TESTBUNDLEDIR}" + "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir2" -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" - DEPENDS testbundleutils1 module + DEPENDS testbundleutils1 module2 ) add_dependencies(testbundleutils2_test testbundleutils2) diff --git a/Tests/BundleUtilities/testbundleutils.cpp b/Tests/BundleUtilities/testbundleutils.cpp deleted file mode 100644 index 77fe4b0..0000000 --- a/Tests/BundleUtilities/testbundleutils.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -#include "framework.h" -#include "shared.h" -#include "stdio.h" - -#if defined(WIN32) -#include -#else -#include "dlfcn.h" -#endif - -int main(int, char**) -{ - framework(); - shared(); - -#if defined(WIN32) - HANDLE lib = LoadLibraryA("module.dll"); - if(!lib) - { - printf("Failed to open module\n"); - } -#else - void* lib = dlopen("module.so", RTLD_LAZY); - if(!lib) - { - printf("Failed to open module\n%s\n", dlerror()); - } -#endif - - - return lib == 0 ? 1 : 0; -} diff --git a/Tests/BundleUtilities/testbundleutils1.cpp b/Tests/BundleUtilities/testbundleutils1.cpp new file mode 100644 index 0000000..23d3cbd --- /dev/null +++ b/Tests/BundleUtilities/testbundleutils1.cpp @@ -0,0 +1,33 @@ + +#include "framework.h" +#include "shared.h" +#include "stdio.h" + +#if defined(WIN32) +#include +#else +#include "dlfcn.h" +#endif + +int main(int, char**) +{ + framework(); + shared(); + +#if defined(WIN32) + HANDLE lib = LoadLibraryA("module1.dll"); + if(!lib) + { + printf("Failed to open module1\n"); + } +#else + void* lib = dlopen("module1.so", RTLD_LAZY); + if(!lib) + { + printf("Failed to open module1\n%s\n", dlerror()); + } +#endif + + + return lib == 0 ? 1 : 0; +} diff --git a/Tests/BundleUtilities/testbundleutils2.cpp b/Tests/BundleUtilities/testbundleutils2.cpp new file mode 100644 index 0000000..319be89 --- /dev/null +++ b/Tests/BundleUtilities/testbundleutils2.cpp @@ -0,0 +1,33 @@ + +#include "framework.h" +#include "shared.h" +#include "stdio.h" + +#if defined(WIN32) +#include +#else +#include "dlfcn.h" +#endif + +int main(int, char**) +{ + framework(); + shared(); + +#if defined(WIN32) + HANDLE lib = LoadLibraryA("module2.dll"); + if(!lib) + { + printf("Failed to open module2\n"); + } +#else + void* lib = dlopen("module2.so", RTLD_LAZY); + if(!lib) + { + printf("Failed to open module2\n%s\n", dlerror()); + } +#endif + + + return lib == 0 ? 1 : 0; +} -- cgit v0.12