diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2013-05-02 04:19:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-06-03 13:42:06 (GMT) |
commit | dc1d025197d48829f2c0389824c8273b9e257413 (patch) | |
tree | 2a606588819fc406e9ef45f303d031fb52f92364 /Tests/MacRuntimePath/A | |
parent | 8576b3f978e65a9c94630226e1da3f03047691a7 (diff) | |
download | CMake-dc1d025197d48829f2c0389824c8273b9e257413.zip CMake-dc1d025197d48829f2c0389824c8273b9e257413.tar.gz CMake-dc1d025197d48829f2c0389824c8273b9e257413.tar.bz2 |
OS X: Add test for rpaths on Mac.
This also tests rpaths through export/import.
Diffstat (limited to 'Tests/MacRuntimePath/A')
-rw-r--r-- | Tests/MacRuntimePath/A/CMakeLists.txt | 63 | ||||
-rw-r--r-- | Tests/MacRuntimePath/A/framework.cpp | 8 | ||||
-rw-r--r-- | Tests/MacRuntimePath/A/framework.h | 17 | ||||
-rw-r--r-- | Tests/MacRuntimePath/A/shared.cpp | 8 | ||||
-rw-r--r-- | Tests/MacRuntimePath/A/shared.h | 17 | ||||
-rw-r--r-- | Tests/MacRuntimePath/A/test1.cpp | 8 | ||||
-rw-r--r-- | Tests/MacRuntimePath/A/test2.cpp | 8 | ||||
-rw-r--r-- | Tests/MacRuntimePath/A/test3.cpp | 8 |
8 files changed, 137 insertions, 0 deletions
diff --git a/Tests/MacRuntimePath/A/CMakeLists.txt b/Tests/MacRuntimePath/A/CMakeLists.txt new file mode 100644 index 0000000..6e6de42 --- /dev/null +++ b/Tests/MacRuntimePath/A/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 2.8) +project(MacRuntimePath_A) + +# a shared library +add_library(shared SHARED shared.cpp shared.h) +set_target_properties(shared PROPERTIES MACOSX_RPATH 1) + +# a shared library with custom set @rpath +add_library(shared2 SHARED shared.cpp shared.h) +set_target_properties(shared2 PROPERTIES + BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@rpath") + +# a framework library +add_library(framework SHARED framework.cpp framework.h) +set_target_properties(framework PROPERTIES MACOSX_RPATH 1 FRAMEWORK 1) + +# executable to test a shared library dependency with install rpaths +add_executable(test1 test1.cpp) +target_link_libraries(test1 shared) +set_target_properties(test1 PROPERTIES + BUILD_WITH_INSTALL_RPATH 1 INSTALL_RPATH "@loader_path/../lib") + +# executable to test a framework library dependency with install rpaths +add_executable(test2 test2.cpp) +target_link_libraries(test2 framework) +set_target_properties(test2 PROPERTIES + BUILD_WITH_INSTALL_RPATH 1 INSTALL_RPATH "@loader_path/../lib") + +# executable to test a framework library dependency with build tree rpaths +add_executable(test3 test3.cpp) +target_link_libraries(test3 framework) + +# executable to test a framework library dependency with build tree rpaths +add_executable(test4 test1.cpp) +target_link_libraries(test4 shared2) + +set_target_properties(shared shared2 framework PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") +set_target_properties(test1 test2 test3 test4 PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") +foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${config} CONFIG) + set_target_properties(shared shared2 framework PROPERTIES + LIBRARY_OUTPUT_DIRECTORY_${CONFIG} + "${CMAKE_CURRENT_BINARY_DIR}/${config}/lib") + set_target_properties(test1 test2 test3 test4 PROPERTIES + RUNTIME_OUTPUT_DIRECTORY_${CONFIG} + "${CMAKE_CURRENT_BINARY_DIR}/${config}/bin") +endforeach() + +foreach(test test1 test2 test3 test4) + add_custom_target(${test}_run ALL + COMMAND ${test} + DEPENDS ${test} + ) +endforeach() + +export(TARGETS shared shared2 framework FILE "${CMAKE_CURRENT_BINARY_DIR}/exp.cmake") + +install(TARGETS shared EXPORT MyExport DESTINATION lib) +install(TARGETS shared2 EXPORT MyExport DESTINATION lib2) +install(TARGETS framework EXPORT MyExport DESTINATION lib-fw) +install(EXPORT MyExport DESTINATION lib FILE exp.cmake) diff --git a/Tests/MacRuntimePath/A/framework.cpp b/Tests/MacRuntimePath/A/framework.cpp new file mode 100644 index 0000000..abda195 --- /dev/null +++ b/Tests/MacRuntimePath/A/framework.cpp @@ -0,0 +1,8 @@ + +#include "framework.h" +#include "stdio.h" + +void framework() +{ + printf("framework\n"); +} diff --git a/Tests/MacRuntimePath/A/framework.h b/Tests/MacRuntimePath/A/framework.h new file mode 100644 index 0000000..bdd10f0 --- /dev/null +++ b/Tests/MacRuntimePath/A/framework.h @@ -0,0 +1,17 @@ + +#ifndef framework_h +#define framework_h + +#ifdef WIN32 +# ifdef framework_EXPORTS +# define FRAMEWORK_EXPORT __declspec(dllexport) +# else +# define FRAMEWORK_EXPORT __declspec(dllimport) +# endif +#else +# define FRAMEWORK_EXPORT +#endif + +void FRAMEWORK_EXPORT framework(); + +#endif diff --git a/Tests/MacRuntimePath/A/shared.cpp b/Tests/MacRuntimePath/A/shared.cpp new file mode 100644 index 0000000..e5e7dc5 --- /dev/null +++ b/Tests/MacRuntimePath/A/shared.cpp @@ -0,0 +1,8 @@ + +#include "shared.h" +#include "stdio.h" + +void shared() +{ + printf("shared\n"); +} diff --git a/Tests/MacRuntimePath/A/shared.h b/Tests/MacRuntimePath/A/shared.h new file mode 100644 index 0000000..3588fb8 --- /dev/null +++ b/Tests/MacRuntimePath/A/shared.h @@ -0,0 +1,17 @@ + +#ifndef shared_h +#define shared_h + +#ifdef WIN32 +# ifdef shared_EXPORTS +# define SHARED_EXPORT __declspec(dllexport) +# else +# define SHARED_EXPORT __declspec(dllimport) +# endif +#else +# define SHARED_EXPORT +#endif + +void SHARED_EXPORT shared(); + +#endif diff --git a/Tests/MacRuntimePath/A/test1.cpp b/Tests/MacRuntimePath/A/test1.cpp new file mode 100644 index 0000000..cb93448 --- /dev/null +++ b/Tests/MacRuntimePath/A/test1.cpp @@ -0,0 +1,8 @@ + +#include "shared.h" + +int main(int, char**) +{ + shared(); + return 0; +} diff --git a/Tests/MacRuntimePath/A/test2.cpp b/Tests/MacRuntimePath/A/test2.cpp new file mode 100644 index 0000000..26bc9dd --- /dev/null +++ b/Tests/MacRuntimePath/A/test2.cpp @@ -0,0 +1,8 @@ + +#include "framework.h" + +int main(int, char**) +{ + framework(); + return 0; +} diff --git a/Tests/MacRuntimePath/A/test3.cpp b/Tests/MacRuntimePath/A/test3.cpp new file mode 100644 index 0000000..26bc9dd --- /dev/null +++ b/Tests/MacRuntimePath/A/test3.cpp @@ -0,0 +1,8 @@ + +#include "framework.h" + +int main(int, char**) +{ + framework(); + return 0; +} |