forked from couchbase/couchbase-lite-C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
147 lines (121 loc) · 4.08 KB
/
CMakeLists.txt
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
cmake_minimum_required (VERSION 3.1)
cmake_policy(VERSION 3.1)
if(NOT DEFINED CMAKE_OSX_SYSROOT)
# Tells Mac builds to use the current SDK's headers & libs, not what's in the OS.
set(CMAKE_OSX_SYSROOT macosx) # this line MUST be above the 1st "project()" line!
endif()
project (CouchbaseLite_C)
### BUILD SETTINGS:
set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -Werror")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
option(BUILD_ENTERPRISE "Set whether or not to build enterprise edition" OFF)
if(CMAKE_COMPILER_IS_GNUCC)
# Suppress an annoying note about GCC 7 ABI changes
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
endif()
if(BUILD_ENTERPRISE)
add_definitions(-DCOUCHBASE_ENTERPRISE) # Tells CBL it's an EE build
endif()
add_definitions("-DCMAKE")
include(CheckIncludeFile)
include (CheckFunctionExists)
check_include_file(unistd.h CBL_HAVE_UNISTD_H)
check_include_file(direct.h CBL_HAVE_DIRECT_H)
check_function_exists(vasprintf CBL_HAVE_VASPRINTF)
configure_file(
"${PROJECT_SOURCE_DIR}/include/cbl/cbl_config.h.in"
"${PROJECT_BINARY_DIR}/include/cbl/cbl_config.h"
)
if(MSVC)
include("cmake/platform_win.cmake")
elseif(ANDROID)
include("cmake/platform_android.cmake")
elseif(APPLE)
include("cmake/platform_apple.cmake")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
include("cmake/platform_linux_desktop.cmake")
else()
message(FATAL_ERROR "Unknown platform")
endif()
init_vars()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CBL_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CBL_CXX_FLAGS}")
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:Debug>:DEBUG>
)
### SUBMODULES:
add_subdirectory(vendor/couchbase-lite-core EXCLUDE_FROM_ALL)
### SOURCE FILES:
include_directories("vendor/couchbase-lite-core/C/include"
"vendor/couchbase-lite-core/LiteCore/C"
"vendor/couchbase-lite-core/LiteCore/Support"
"vendor/couchbase-lite-core/vendor/fleece/API"
"vendor/couchbase-lite-core/vendor/fleece/Fleece/Support")
if(!MSVC)
set_source_files_properties(${C_SRC} PROPERTIES COMPILE_FLAGS -Wno-return-type-c-linkage)
endif()
### BUILDING THE LIBRARY:
set_platform_source_files(RESULT PLATFORM_SRC)
set(
ALL_SRC_FILES
src/CBLBase.cc
src/CBLBlob.cc
src/CBLDatabase.cc
src/CBLDocument.cc
src/CBLLog.cc
src/CBLQuery.cc
src/CBLReplicator.cc
src/ConflictResolver.cc
src/Listener.cc
src/Util.cc
${PLATFORM_SRC}
)
add_library(CouchbaseLiteCStatic STATIC ${ALL_SRC_FILES})
target_include_directories(CouchbaseLiteCStatic PUBLIC include/cbl)
set_platform_include_directories(RESULT PLATFORM_INCLUDE)
target_include_directories(
CouchbaseLiteCStatic
PRIVATE
src
vendor/couchbase-lite-core/C
${PROJECT_BINARY_DIR}/include/cbl/
${PLATFORM_INCLUDE}
)
target_link_libraries(
CouchbaseLiteCStatic INTERFACE
LiteCoreStatic
)
file(WRITE empty.cpp)
add_library(CouchbaseLiteC SHARED empty.cpp)
target_include_directories(CouchbaseLiteC PUBLIC include/cbl)
target_include_directories(
CouchbaseLiteC
PRIVATE
src
vendor/couchbase-lite-core/C
${PROJECT_BINARY_DIR}/include/cbl/
${PLATFORM_INCLUDE}
)
install (TARGETS CouchbaseLiteC
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include)
set(CBL_LIBRARIES_PRIVATE ${WHOLE_LIBRARY_FLAG}
CouchbaseLiteCStatic
FleeceStatic
LiteCoreStatic
${NO_WHOLE_LIBRARY_FLAG}
LiteCoreWebSocket)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^armv[67]")
# C/C++ atomic operations on ARM6/7 emit calls to functions in libatomic
set(CBL_LIBRARIES_PRIVATE ${CBL_LIBRARIES_PRIVATE}
atomic)
endif()
target_link_libraries(CouchbaseLiteC PRIVATE ${CBL_LIBRARIES_PRIVATE})
set_dylib_properties()
### TESTS:
add_subdirectory(test)