CMakeLists.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. cmake_minimum_required(VERSION 2.8)
  2. project(BundleUtilities)
  3. ###### the various types of dependencies we can have
  4. # a shared library
  5. add_library(shared SHARED shared.cpp shared.h)
  6. # another shared library
  7. add_library(shared2 SHARED shared2.cpp shared2.h)
  8. # a framework library
  9. add_library(framework SHARED framework.cpp framework.h)
  10. # TODO: fix problems with local frameworks without rpaths
  11. #set_target_properties(framework PROPERTIES FRAMEWORK 1)
  12. # make sure rpaths are not helping BundleUtilities or the executables
  13. set_target_properties(shared shared2 framework PROPERTIES
  14. SKIP_BUILD_RPATH 1)
  15. ###### test a Bundle application using dependencies
  16. # a loadable module (depends on shared2)
  17. # testbundleutils1 will load this at runtime
  18. add_library(module1 MODULE module.cpp module.h)
  19. set_target_properties(module1 PROPERTIES PREFIX "")
  20. get_target_property(module_loc module1 LOCATION)
  21. target_link_libraries(module1 shared2)
  22. # a bundle application
  23. add_executable(testbundleutils1 MACOSX_BUNDLE testbundleutils1.cpp)
  24. target_link_libraries(testbundleutils1 shared framework ${CMAKE_DL_LIBS})
  25. get_target_property(loc testbundleutils1 LOCATION)
  26. set_target_properties(testbundleutils1 module1 PROPERTIES
  27. INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir1"
  28. BUILD_WITH_INSTALL_RPATH 1)
  29. # add custom target to install and test the app
  30. add_custom_target(testbundleutils1_test ALL
  31. COMMAND ${CMAKE_COMMAND}
  32. "-DINPUT=${loc}"
  33. "-DMODULE=${module_loc}"
  34. "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}"
  35. "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir1"
  36. -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake"
  37. DEPENDS testbundleutils1 module1
  38. )
  39. add_dependencies(testbundleutils1_test testbundleutils1)
  40. ###### test a non-Bundle application using dependencies
  41. # a loadable module (depends on shared2)
  42. # testbundleutils2 will load this at runtime
  43. add_library(module2 MODULE module.cpp module.h)
  44. set_target_properties(module2 PROPERTIES PREFIX "")
  45. get_target_property(module_loc module2 LOCATION)
  46. target_link_libraries(module2 shared2)
  47. # a non-bundle application
  48. add_executable(testbundleutils2 testbundleutils2.cpp)
  49. target_link_libraries(testbundleutils2 shared framework ${CMAKE_DL_LIBS})
  50. get_target_property(loc testbundleutils2 LOCATION)
  51. set_target_properties(testbundleutils2 module2 PROPERTIES
  52. INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir2"
  53. BUILD_WITH_INSTALL_RPATH 1)
  54. # add custom target to install and test the app
  55. add_custom_target(testbundleutils2_test ALL
  56. COMMAND ${CMAKE_COMMAND}
  57. "-DINPUT=${loc}"
  58. "-DMODULE=${module_loc}"
  59. "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}"
  60. "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir2"
  61. -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake"
  62. DEPENDS testbundleutils1 module2
  63. )
  64. add_dependencies(testbundleutils2_test testbundleutils2)