CMakeLists.txt 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. cmake_minimum_required (VERSION 2.6)
  2. project(Framework)
  3. add_library(foo SHARED
  4. foo.cxx
  5. foo.h
  6. foo2.h
  7. fooExtensionlessResource
  8. fooPublic.h
  9. fooPublicExtensionlessHeader
  10. fooPrivate.h
  11. fooPrivateExtensionlessHeader
  12. fooNeither.h
  13. fooBoth.h
  14. test.lua
  15. fooDeepPublic.h
  16. )
  17. set_property(SOURCE fooDeepPublic.h
  18. PROPERTY MACOSX_PACKAGE_LOCATION Headers/Deep
  19. )
  20. set(foo_ver ver4)
  21. set_target_properties(foo PROPERTIES
  22. FRAMEWORK TRUE
  23. FRAMEWORK_VERSION ${foo_ver}
  24. PRIVATE_HEADER "fooPrivate.h;fooBoth.h;fooPrivateExtensionlessHeader"
  25. PUBLIC_HEADER "foo.h;foo2.h;fooPublic.h;fooBoth.h;fooPublicExtensionlessHeader"
  26. RESOURCE "fooExtensionlessResource;test.lua"
  27. INSTALL_NAME_DIR "@executable_path/../../../Library/Frameworks"
  28. DEBUG_POSTFIX -d
  29. )
  30. # fooBoth.h is listed as both public and private... (private wins...)
  31. # fooNeither.h is listed as neither public nor private...
  32. add_executable(bar bar.cxx)
  33. target_link_libraries(bar foo)
  34. install(TARGETS foo bar
  35. RUNTIME DESTINATION Applications/CMakeTestsFramework/bin
  36. FRAMEWORK DESTINATION Library/Frameworks
  37. LIBRARY DESTINATION lib
  38. ARCHIVE DESTINATION lib
  39. # These are ignored on the Mac... and things are automatically placed in
  40. # their appropriate Framework sub-folder at build time. (And then the built
  41. # framework is copied recursively when it is installed.)
  42. PRIVATE_HEADER DESTINATION share/foo-${foo_ver}/PrivateHeaders
  43. PUBLIC_HEADER DESTINATION include/foo-${foo_ver}
  44. RESOURCE DESTINATION share/foo-${foo_ver}/Resources
  45. # But they are required to be present so that installing a framework on other
  46. # other platforms will install the pieces of the framework without having to
  47. # duplicate install rules for the pieces of the framework.
  48. )
  49. # test that framework post-build commands run
  50. add_custom_command(TARGET foo POST_BUILD COMMAND ${CMAKE_COMMAND} -E touch foo-post-build)
  51. add_custom_target(fooCustom ALL COMMAND ${CMAKE_COMMAND} -E copy foo-post-build foo-custom)
  52. add_dependencies(fooCustom foo)
  53. # Make a static library and apply the framework properties to it to verify
  54. # that everything still builds correctly. Xcode prior to version 5 does not
  55. # support static Frameworks.
  56. #
  57. if(NOT XCODE OR NOT XCODE_VERSION VERSION_LESS 5)
  58. add_library(fooStatic STATIC
  59. foo.cxx
  60. foo.h
  61. foo2.h
  62. fooExtensionlessResource
  63. fooPublic.h
  64. fooPublicExtensionlessHeader
  65. fooPrivate.h
  66. fooPrivateExtensionlessHeader
  67. fooNeither.h
  68. fooBoth.h
  69. test.lua
  70. fooDeepPublic.h
  71. )
  72. set_target_properties(fooStatic PROPERTIES
  73. FRAMEWORK TRUE
  74. FRAMEWORK_VERSION none
  75. )
  76. add_executable(barStatic bar.cxx)
  77. target_link_libraries(barStatic fooStatic)
  78. endif()
  79. include(CPack)