blob: d6576a8219b4477062f2cdb607af9a0bd6e641dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -213,19 +219,28 @@
"snappy-stubs-public.h.in"
"${PROJECT_BINARY_DIR}/snappy-stubs-public.h")
+# When BUILD_SHARED_LIBS is:
+# ON it will generate a SHARED library
+# OFF it will generate a STATIC library
add_library(snappy "")
-target_sources(snappy
- PRIVATE
+
+# Used to generate both lib types
+if (BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
+ add_library(snappy_static STATIC "")
+ set_target_properties(snappy_static PROPERTIES OUTPUT_NAME snappy)
+ install(TARGETS snappy_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
+endif ()
+
+set(SNAPPY_SOURCE_PRIVATE
"snappy-internal.h"
"snappy-stubs-internal.h"
"snappy-c.cc"
"snappy-sinksource.cc"
"snappy-stubs-internal.cc"
"snappy.cc"
- "${PROJECT_BINARY_DIR}/config.h"
+ "${PROJECT_BINARY_DIR}/config.h")
- # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
- $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
+set(SNAPPY_SOURCE_PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h>
$<INSTALL_INTERFACE:include/snappy-c.h>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h>
@@ -233,18 +248,32 @@
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy.h>
$<INSTALL_INTERFACE:include/snappy.h>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snappy-stubs-public.h>
- $<INSTALL_INTERFACE:include/snappy-stubs-public.h>
-)
-target_include_directories(snappy
- PUBLIC
+ $<INSTALL_INTERFACE:include/snappy-stubs-public.h>)
+
+set(SNAPPY_INCLUDE_DIRS
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
- $<INSTALL_INTERFACE:include>
-)
+ $<INSTALL_INTERFACE:include>)
+
+# Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
+target_sources(snappy PRIVATE ${SNAPPY_SOURCE_PRIVATE}
+ $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC> ${SNAPPY_SOURCE_PUBLIC})
+
+target_include_directories(snappy PUBLIC ${SNAPPY_INCLUDE_DIRS})
+
+target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
+
+# Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
+target_sources(snappy_static PRIVATE ${SNAPPY_SOURCE_PRIVATE}
+ $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC> ${SNAPPY_SOURCE_PUBLIC})
+
+target_include_directories(snappy_static PUBLIC ${SNAPPY_INCLUDE_DIRS})
+
+target_compile_definitions(snappy_static PRIVATE -DHAVE_CONFIG_H)
+
set_target_properties(snappy
PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
-target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
if(BUILD_SHARED_LIBS)
set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif(BUILD_SHARED_LIBS)
|