• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
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 "Embeddable JSON database engine (EJDB2).")
19set(PROJECT_DESCRIPTION "Embeddable JSON database engine (EJDB2).")
20set(CHANGELOG_MESSAGE ${CHANGELOG_LAST_MESSAGE})
21set(PROJECT_PPA "ppa:adamansky/ejdb2")
22set(PROJECT_PPA_USER "adamansky")
23set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
24set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
25
26set(PROJECT_VERSION_MAJOR ${CHANGELOG_LAST_VERSION_MAJOR})
27set(PROJECT_VERSION_MINOR ${CHANGELOG_LAST_VERSION_MINOR})
28set(PROJECT_VERSION_PATCH ${CHANGELOG_LAST_VERSION_PATCH})
29set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
30set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION})
31set(${PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
32set(${PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR})
33set(${PROJECT_NAME}_VERSION_PATCH 0)
34
35option(BUILD_SHARED_LIBS "Build shared libraries" ON)
36option(ENABLE_HTTP "Enable HTTP endpoint and standalone server (jbs)" ON)
37option(INSTALL_FLAT_SUBPROJECT_INCLUDES
38       "Install iowow/iwnet headers into CMAKE_INSTALL_PREFIX/{iowow,iwnet} dir"
39       OFF)
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"
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
131set(DO_INSTALL_CORE ON)
132
133add_subdirectory(man)
134
135if(NOT ENABLE_PPA)
136  add_subdirectory(src)
137endif()
138
139if(CPACK_GENERATORS)
140  set(CPACK_GENERATOR "${CPACK_GENERATORS}")
141  set(CPACK_SOURCE_IGNORE_FILES
142      "/src/bindings/ejdb2_android"
143      "/src/bindings/ejdb2_dart"
144      "/src/bindings/ejdb2_flutter"
145      "/src/bindings/ejdb2_node"
146      "/src/bindings/ejdb2_react_native"
147      "/src/bindings/ejdb2_swift"
148      "/mxe/"
149      "/build/"
150      "/target/"
151      "/docker/"
152      "/benchmark/"
153      "/node_modules/"
154      "/cmake-.*/"
155      "/Makefile$"
156      "hints\\\\.txt$"
157      "/\\\\.clang/"
158      "/\\\\.cache/"
159      "/\\\\.git/"
160      "/\\\\.settings/"
161      "\\\\.classpath$"
162      "\\\\.editorconfig$"
163      "\\\\.log$"
164      "\\\\.mk$"
165      "uncrustify\\\\.cfg")
166  set(PROJECT_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
167  add_subdirectory(installer)
168endif(CPACK_GENERATORS)
169
170message("${PROJECT_NAME} GIT_REVISION: ${GIT_REVISION}")
171message("${PROJECT_NAME} CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
172message("${PROJECT_NAME} CPACK_GENERATORS: ${CPACK_GENERATORS}")
173message("${PROJECT_NAME} CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
174
175if(MXE_HOME)
176  message("${PROJECT_NAME} MXE_HOME: ${MXE_HOME}")
177endif()
178
179if(CMAKE_SYSTEM_NAME)
180  message("${PROJECT_NAME} CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
181endif()
182message("${PROJECT_NAME} CPU: ${CMAKE_SYSTEM_PROCESSOR}")
183
184if(CMAKE_SIZEOF_VOID_P)
185  message("${PROJECT_NAME} SIZEOF *VOID: ${CMAKE_SIZEOF_VOID_P}")
186endif()
187message("${PROJECT_NAME} PROJECT: ${CHANGELOG_LAST_LINE}")
188
189if(CHANGELOG_MESSAGE)
190  message("${PROJECT_NAME} CHANGELOG_MESSAGE:\n  ${CHANGELOG_MESSAGE}")
191endif()
192