2011-05-27 01:16:58 +04:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(BundleUtilities)
|
|
|
|
|
|
|
|
###### the various types of dependencies we can have
|
|
|
|
|
|
|
|
# a shared library
|
|
|
|
add_library(shared SHARED shared.cpp shared.h)
|
|
|
|
|
|
|
|
# another shared library
|
|
|
|
add_library(shared2 SHARED shared2.cpp shared2.h)
|
|
|
|
|
|
|
|
|
|
|
|
# a framework library
|
|
|
|
add_library(framework SHARED framework.cpp framework.h)
|
2013-05-06 06:19:05 +04:00
|
|
|
set_target_properties(framework PROPERTIES FRAMEWORK 1)
|
2011-05-27 01:16:58 +04:00
|
|
|
|
|
|
|
# make sure rpaths are not helping BundleUtilities or the executables
|
2011-06-02 19:08:49 +04:00
|
|
|
set_target_properties(shared shared2 framework PROPERTIES
|
2011-05-27 01:16:58 +04:00
|
|
|
SKIP_BUILD_RPATH 1)
|
|
|
|
|
|
|
|
|
|
|
|
###### test a Bundle application using dependencies
|
|
|
|
|
2011-06-02 19:08:49 +04:00
|
|
|
# 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 "")
|
|
|
|
target_link_libraries(module1 shared2)
|
|
|
|
|
|
|
|
# a bundle application
|
|
|
|
add_executable(testbundleutils1 MACOSX_BUNDLE testbundleutils1.cpp)
|
2011-05-27 01:16:58 +04:00
|
|
|
target_link_libraries(testbundleutils1 shared framework ${CMAKE_DL_LIBS})
|
|
|
|
|
2011-06-02 19:08:49 +04:00
|
|
|
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
|
2011-05-27 01:16:58 +04:00
|
|
|
add_custom_target(testbundleutils1_test ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
2013-11-18 20:49:20 +04:00
|
|
|
"-DINPUT=$<TARGET_FILE:testbundleutils1>"
|
|
|
|
"-DMODULE=$<TARGET_FILE:module1>"
|
2011-05-27 01:16:58 +04:00
|
|
|
"-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}"
|
2011-06-02 19:08:49 +04:00
|
|
|
"-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir1"
|
2011-05-27 01:16:58 +04:00
|
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake"
|
2011-06-02 19:08:49 +04:00
|
|
|
DEPENDS testbundleutils1 module1
|
2011-05-27 01:16:58 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
add_dependencies(testbundleutils1_test testbundleutils1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###### test a non-Bundle application using dependencies
|
|
|
|
|
2011-06-02 19:08:49 +04:00
|
|
|
# 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 "")
|
|
|
|
target_link_libraries(module2 shared2)
|
|
|
|
|
|
|
|
# a non-bundle application
|
|
|
|
add_executable(testbundleutils2 testbundleutils2.cpp)
|
2011-05-27 01:16:58 +04:00
|
|
|
target_link_libraries(testbundleutils2 shared framework ${CMAKE_DL_LIBS})
|
|
|
|
|
2011-06-02 19:08:49 +04:00
|
|
|
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
|
2011-05-27 01:16:58 +04:00
|
|
|
add_custom_target(testbundleutils2_test ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
2013-11-18 20:49:20 +04:00
|
|
|
"-DINPUT=$<TARGET_FILE:testbundleutils2>"
|
|
|
|
"-DMODULE=$<TARGET_FILE:module2>"
|
2011-05-27 01:16:58 +04:00
|
|
|
"-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}"
|
2011-06-02 19:08:49 +04:00
|
|
|
"-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir2"
|
2011-05-27 01:16:58 +04:00
|
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake"
|
2011-06-02 19:08:49 +04:00
|
|
|
DEPENDS testbundleutils1 module2
|
2011-05-27 01:16:58 +04:00
|
|
|
)
|
|
|
|
add_dependencies(testbundleutils2_test testbundleutils2)
|
2012-01-20 09:03:06 +04:00
|
|
|
|
|
|
|
|
2012-01-20 17:59:17 +04:00
|
|
|
if(APPLE AND NOT CMAKE_SYSTEM_VERSION VERSION_LESS 9.0)
|
2012-01-20 09:03:06 +04:00
|
|
|
###### Test a Bundle application using dependencies
|
|
|
|
###### and @rpaths on Mac OS X 10.5 or greater
|
|
|
|
|
|
|
|
# a shared library
|
|
|
|
add_library(shared-3 SHARED shared.cpp shared.h)
|
|
|
|
|
|
|
|
# another shared library
|
|
|
|
add_library(shared2-3 SHARED shared2.cpp shared2.h)
|
|
|
|
|
|
|
|
# a framework library
|
|
|
|
add_library(framework-3 SHARED framework.cpp framework.h)
|
|
|
|
set_target_properties(framework-3 PROPERTIES FRAMEWORK 1)
|
|
|
|
|
|
|
|
# build dependencies with @rpath install name
|
|
|
|
set_target_properties(shared-3 shared2-3 framework-3 PROPERTIES
|
|
|
|
INSTALL_NAME_DIR "@rpath"
|
|
|
|
BUILD_WITH_INSTALL_RPATH 1)
|
|
|
|
|
|
|
|
# a loadable module (depends on shared2)
|
|
|
|
# testbundleutils1 will load this at runtime
|
|
|
|
add_library(module3 MODULE module.cpp module.h)
|
2012-01-21 09:02:01 +04:00
|
|
|
set_target_properties(module3 PROPERTIES PREFIX "" LINK_FLAGS "-Wl,-rpath,@loader_path/")
|
2012-01-20 09:03:06 +04:00
|
|
|
target_link_libraries(module3 shared2-3)
|
|
|
|
|
|
|
|
# a non-bundle application
|
|
|
|
add_executable(testbundleutils3 testbundleutils3.cpp)
|
|
|
|
target_link_libraries(testbundleutils3 shared-3 framework-3 ${CMAKE_DL_LIBS})
|
|
|
|
|
|
|
|
set_target_properties(testbundleutils3 module3 PROPERTIES
|
2012-01-21 09:02:01 +04:00
|
|
|
LINK_FLAGS "-Wl,-rpath,@loader_path/")
|
2012-01-20 09:03:06 +04:00
|
|
|
|
|
|
|
# add custom target to install and test the app
|
|
|
|
add_custom_target(testbundleutils3_test ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
2013-11-18 20:49:20 +04:00
|
|
|
"-DINPUT=$<TARGET_FILE:testbundleutils3>"
|
|
|
|
"-DMODULE=$<TARGET_FILE:module3>"
|
2012-01-20 09:03:06 +04:00
|
|
|
"-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}"
|
|
|
|
"-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir3"
|
|
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake"
|
|
|
|
DEPENDS testbundleutils3 module3
|
|
|
|
)
|
|
|
|
|
|
|
|
add_dependencies(testbundleutils3_test testbundleutils3)
|
|
|
|
endif()
|