• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1cmake_minimum_required(VERSION 3.5)
2
3set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
4                      "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
5include(CMakeToolsHelpers OPTIONAL)
6set(DEB_CHANGELOG_REQUIRED ON)
7set(DEB_CHANGELOG "${CMAKE_CURRENT_SOURCE_DIR}/Changelog")
8unset(CHANGELOG_LAST_VERSION)
9unset(CHANGELOG_LAST_MESSAGE)
10include(DebChangelog)
11
12set(PROJECT_NAME "ejdb2")
13project(${PROJECT_NAME} C)
14
15set(PROJECT_VENDOR "Softmotions (https://softmotions.com)")
16set(PROJECT_WEBSITE "http://ejdb.org")
17set(PROJECT_MAINTAINER "Anton Adamansky <adamansky@gmail.com>")
18set(PROJECT_DESCRIPTION_SUMMARY
19    "Embeddable JSON database engine with network support (EJDB2).")
20set(PROJECT_DESCRIPTION
21    "Embeddable JSON database engine with network support (EJDB2).")
22set(CHANGELOG_MESSAGE ${CHANGELOG_LAST_MESSAGE})
23set(PROJECT_PPA "ppa:adamansky/ejdb2")
24set(PROJECT_PPA_USER "adamansky")
25set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
26set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
27
28set(PROJECT_VERSION_MAJOR ${CHANGELOG_LAST_VERSION_MAJOR})
29set(PROJECT_VERSION_MINOR ${CHANGELOG_LAST_VERSION_MINOR})
30set(PROJECT_VERSION_PATCH ${CHANGELOG_LAST_VERSION_PATCH})
31set(PROJECT_VERSION
32    ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
33set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION})
34set(${PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
35set(${PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR})
36set(${PROJECT_NAME}_VERSION_PATCH ${PROJECT_VERSION_PATCH})
37
38option(BUILD_SHARED_LIBS "Build shared libraries" ON)
39option(ENABLE_HTTP "Enable HTTP endpoint and standalone server (jbs)" ON)
40option(BUILD_TESTS "Build test cases" OFF)
41option(ASAN "Turn on address sanitizer" OFF)
42option(BUILD_EXAMPLES "Build example projects" ON)
43option(BUILD_BENCHMARKS "Build benchmarks" OFF)
44option(BUILD_JNI_BINDING "Build Java native binding" OFF)
45option(BUILD_ANDROID_LIBS "Build Android libs" OFF)
46option(BUILD_DART_BINDING "Build Dart VM binding" OFF)
47option(BUILD_NODEJS_BINDING "Build Node.js binding" OFF)
48option(BUILD_REACT_NATIVE_BINDING "Build React Native binding" OFF)
49option(BUILD_FLUTTER_BINDING "Build Flutter binding" OFF)
50option(BUILD_SWIFT_BINDING "Build Swift binding" OFF)
51option(PACKAGE_DEB "Build .deb instalation packages" OFF)
52option(PACKAGE_RPM "Build .rpm instalation packages" OFF)
53option(PACKAGE_TGZ "Build .tgz package archive" ON)
54option(PACKAGE_ZIP "Build .zip package archive" ON)
55option(ENABLE_PPA "Enable PPA package build" OFF)
56option(UPLOAD_PPA "Upload debian packages to the launchpad ppa repository" OFF)
57
58set(PPA_DEBIAN_VERSION
59    "ppa1"
60    CACHE STRING "PPA version suffix for debian packages")
61
62set(PROJECT_PPA_DISTRIB_TARGET
63    "focal;bionic;xenial"
64    CACHE STRING "Ubuntu PPA distribution names")
65
66set(ANDROID_ABIS
67    "x86;x86_64;arm64-v8a;armeabi-v7a"
68    CACHE STRING "Android ABI list")
69
70set(ANDROID_AVD
71    "TestingAVD"
72    CACHE STRING "Android virtual device name for tests")
73
74set(CPACK_SET_DESTDIR ON)
75
76if(POLICY CMP0042)
77  cmake_policy(SET CMP0042 NEW)
78endif(POLICY CMP0042)
79
80if(POLICY CMP0087)
81  cmake_policy(SET CMP0087 NEW)
82endif(POLICY CMP0087)
83
84if(BUILD_REACT_NATIVE_BINDING
85   OR BUILD_FLUTTER_BINDING
86   OR BUILD_ANDROID_LIBS)
87  set(ENABLE_HTTP OFF)
88  set(BUILD_ANDROID_LIBS ON)
89endif()
90
91if(ANDROID_ABI OR IOS)
92  set(ENABLE_HTTP OFF)
93endif()
94
95if(DEFINED CMAKE_TOOLCHAIN_FILE)
96  get_filename_component(_CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE} ABSOLUTE)
97  set(CMAKE_TOOLCHAIN_FILE ${_CMAKE_TOOLCHAIN_FILE})
98endif()
99
100include(GitRevision)
101include(GNUInstallDirs)
102include(ProjectUtils)
103
104macro_ensure_out_of_source_build(
105  "${CMAKE_PROJECT_NAME} requires an out of source build.")
106
107if(BUILD_TESTS)
108  include(CTest)
109  find_package(CUnit REQUIRED)
110endif(BUILD_TESTS)
111
112if(UPLOAD_PPA)
113  set(ENABLE_PPA ON)
114  set(PACKAGE_DEB ON)
115endif(UPLOAD_PPA)
116
117set(CPACK_GENERATORS)
118if(PACKAGE_TGZ)
119  list(APPEND CPACK_GENERATORS "TGZ")
120endif()
121if(PACKAGE_ZIP)
122  list(APPEND CPACK_GENERATORS "ZIP")
123endif()
124if(PACKAGE_DEB)
125  list(APPEND CPACK_GENERATORS "DEB")
126endif()
127if(PACKAGE_RPM)
128  list(APPEND CPACK_GENERATORS "RPM")
129endif()
130
131if(NOT
132   (CPACK_GENERATORS
133    AND (BUILD_JNI_BINDING
134         OR BUILD_DART_BINDING
135         OR BUILD_NODEJS_BINDING)))
136  set(DO_INSTALL_CORE ON)
137endif()
138
139add_subdirectory(man)
140
141if(NOT ENABLE_PPA)
142  add_subdirectory(src)
143endif()
144
145if(CPACK_GENERATORS)
146  set(CPACK_GENERATOR "${CPACK_GENERATORS}")
147  set(CPACK_SOURCE_IGNORE_FILES
148      "/src/bindings/ejdb2_android"
149      "/src/bindings/ejdb2_dart"
150      "/src/bindings/ejdb2_flutter"
151      "/src/bindings/ejdb2_node"
152      "/src/bindings/ejdb2_react_native"
153      "/src/bindings/ejdb2_swift"
154      "/mxe/"
155      "/build/"
156      "/target/"
157      "/tools/"
158      "/docker/"
159      "/node_modules/"
160      "/cmake-.*/"
161      "/Makefile$"
162      "hints\\\\.txt$"
163      "/\\\\.clang/"
164      "/\\\\.codelite/"
165      "/\\\\.git/"
166      "/\\\\.idea/"
167      "/\\\\.settings/"
168      "/\\\\.vscode/"
169      "\\\\.classpath$"
170      "\\\\.editorconfig$"
171      "\\\\.iml$"
172      "\\\\.ipr$"
173      "\\\\.log$"
174      "\\\\.mk$"
175      "\\\\.project$"
176      "\\\\.workspace$"
177      "\\\\.astylerc$"
178      "uncrustify\\\\.cfg")
179  set(PROJECT_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
180  add_subdirectory(installer)
181endif(CPACK_GENERATORS)
182
183message("${PROJECT_NAME} GIT_REVISION: ${GIT_REVISION}")
184message("${PROJECT_NAME} CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
185message("${PROJECT_NAME} CPACK_GENERATORS: ${CPACK_GENERATORS}")
186message("${PROJECT_NAME} CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
187
188if(MXE_HOME)
189  message("${PROJECT_NAME} MXE_HOME: ${MXE_HOME}")
190endif()
191
192if(CMAKE_SYSTEM_NAME)
193  message("${PROJECT_NAME} CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
194endif()
195message("${PROJECT_NAME} CPU: ${CMAKE_SYSTEM_PROCESSOR}")
196
197if(CMAKE_SIZEOF_VOID_P)
198  message("${PROJECT_NAME} SIZEOF *VOID: ${CMAKE_SIZEOF_VOID_P}")
199endif()
200message("${PROJECT_NAME} PROJECT: ${CHANGELOG_LAST_LINE}")
201
202if(CHANGELOG_MESSAGE)
203  message("${PROJECT_NAME} CHANGELOG_MESSAGE:\n  ${CHANGELOG_MESSAGE}")
204endif()
205