CMakeLists.txt 2.59 KB
Newer Older
Ken Martin's avatar
Ken Martin committed
1
cmake_minimum_required (VERSION 2.6)
2
project(Framework)
3

4
5
6
7
add_library(foo SHARED
  foo.cxx
  foo.h
  foo2.h
8
  fooExtensionlessResource
9
  fooPublic.h
10
  fooPublicExtensionlessHeader
11
  fooPrivate.h
12
  fooPrivateExtensionlessHeader
13
14
15
  fooNeither.h
  fooBoth.h
  test.lua
16
  fooDeepPublic.h
17
)
18
19
20
set_property(SOURCE fooDeepPublic.h
  PROPERTY MACOSX_PACKAGE_LOCATION Headers/Deep
  )
21
22
set(foo_ver ver4)

23
set_target_properties(foo PROPERTIES
24
  FRAMEWORK TRUE
25
  FRAMEWORK_VERSION ${foo_ver}
26
27
28
  PRIVATE_HEADER "fooPrivate.h;fooBoth.h;fooPrivateExtensionlessHeader"
  PUBLIC_HEADER "foo.h;foo2.h;fooPublic.h;fooBoth.h;fooPublicExtensionlessHeader"
  RESOURCE "fooExtensionlessResource;test.lua"
29
  INSTALL_NAME_DIR "@executable_path/../../../Library/Frameworks"
30
  DEBUG_POSTFIX -d
31
)
32
33
34
# fooBoth.h is listed as both public and private... (private wins...)
# fooNeither.h is listed as neither public nor private...

35
36
add_executable(bar bar.cxx)
target_link_libraries(bar foo)
37
install(TARGETS foo bar
38
39
  RUNTIME DESTINATION Applications/CMakeTestsFramework/bin
  FRAMEWORK DESTINATION Library/Frameworks
40
41
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib
42
43
44
45
46
47
48
49
50
51

  # These are ignored on the Mac... and things are automatically placed in
  # their appropriate Framework sub-folder at build time. (And then the built
  # framework is copied recursively when it is installed.)
  PRIVATE_HEADER DESTINATION share/foo-${foo_ver}/PrivateHeaders
  PUBLIC_HEADER DESTINATION include/foo-${foo_ver}
  RESOURCE DESTINATION share/foo-${foo_ver}/Resources
  # But they are required to be present so that installing a framework on other
  # other platforms will install the pieces of the framework without having to
  # duplicate install rules for the pieces of the framework.
52
)
53

54
55
56
57
58
# test that framework post-build commands run
add_custom_command(TARGET foo POST_BUILD COMMAND ${CMAKE_COMMAND} -E touch foo-post-build)
add_custom_target(fooCustom ALL COMMAND ${CMAKE_COMMAND} -E copy foo-post-build foo-custom)
add_dependencies(fooCustom foo)

59
60
61
62
63
# Make a static library and apply the framework properties to it to verify
# that everything still builds correctly, but it will not actually produce
# a framework... The framework properties only apply when the library type
# is SHARED.
#
64
65
66
67
add_library(fooStatic STATIC
  foo.cxx
  foo.h
  foo2.h
68
  fooExtensionlessResource
69
  fooPublic.h
70
  fooPublicExtensionlessHeader
71
  fooPrivate.h
72
  fooPrivateExtensionlessHeader
73
74
75
  fooNeither.h
  fooBoth.h
  test.lua
76
  fooDeepPublic.h
77
)
78
79
set_target_properties(fooStatic PROPERTIES
  FRAMEWORK TRUE
80
  FRAMEWORK_VERSION none
81
82
83
)
add_executable(barStatic bar.cxx)
target_link_libraries(barStatic fooStatic)
84
85

include(CPack)