CMakeLists.txt 2.22 KB
Newer Older
1
2
3
4
5
6
7
project(Export C)

# We need ansi C support.
if(CMAKE_ANSI_CFLAGS)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
endif(CMAKE_ANSI_CFLAGS)

8
add_library(testExe1lib STATIC testExe1lib.c) # not exported
9
add_executable(testExe1 testExe1.c)
10
target_link_libraries(testExe1 testExe1lib)
11
set_property(TARGET testExe1 PROPERTY VERSION 4)
12

13
add_library(testExe2libImp SHARED testExe2libImp.c)
14
set_property(TARGET testExe2libImp PROPERTY LIBRARY_OUTPUT_DIRECTORY impl)
15
16
17
add_library(testExe2lib SHARED testExe2lib.c)
target_link_libraries(testExe2lib testExe2libImp)
set_property(TARGET testExe2lib PROPERTY LINK_INTERFACE_LIBRARIES "")
18
19
add_executable(testExe2 testExe2.c)
set_property(TARGET testExe2 PROPERTY ENABLE_EXPORTS 1)
20
set_property(TARGET testExe2 PROPERTY LINK_INTERFACE_LIBRARIES testExe2lib)
21
22
23
24
25

add_library(testLib1 STATIC testLib1.c)
add_library(testLib2 STATIC testLib2.c)
target_link_libraries(testLib2 testLib1)

26
add_library(testLib3Imp SHARED testLib3Imp.c)
27
set_property(TARGET testLib3Imp PROPERTY LIBRARY_OUTPUT_DIRECTORY impl)
28
add_library(testLib3 SHARED testLib3.c)
29
30
target_link_libraries(testLib3 testLib3Imp)
set_property(TARGET testLib3 PROPERTY LINK_INTERFACE_LIBRARIES "")
31
32
set_property(TARGET testLib3 PROPERTY VERSION 1.2)
set_property(TARGET testLib3 PROPERTY SOVERSION 3)
33

34
35
36
add_library(testLib4 SHARED testLib4.c)
set_property(TARGET testLib4 PROPERTY FRAMEWORK 1)

37
38
39
add_executable(testExe3 testExe3.c)
set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1)

40
# Install and export from install tree.
41
42
install(
  TARGETS
43
44
  testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3
  testExe2lib
45
46
  EXPORT exp
  RUNTIME DESTINATION bin
47
  LIBRARY DESTINATION lib NAMELINK_SKIP
48
  ARCHIVE DESTINATION lib
49
  FRAMEWORK DESTINATION Frameworks
50
  BUNDLE DESTINATION Applications
51
  )
52
53
54
55
56
57
58
59
install(
  TARGETS
  testExe2libImp testLib3Imp
  EXPORT exp
  RUNTIME DESTINATION bin
  LIBRARY DESTINATION lib/impl
  ARCHIVE DESTINATION lib/impl
  )
60
61
62
install(EXPORT exp NAMESPACE exp_ DESTINATION lib/exp)

# Export from build tree.
63
export(TARGETS testExe1 testLib1 testLib2 testLib3
64
  testExe2libImp testLib3Imp
65
66
67
  NAMESPACE bld_
  FILE ExportBuildTree.cmake
  )
68
export(TARGETS testExe2 testLib4 testExe3 testExe2lib
69
70
71
  NAMESPACE bld_
  APPEND FILE ExportBuildTree.cmake
  )