-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
116 lines (102 loc) · 4.32 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
#################################################################
# #
# Copyright (c) 2019-2023 YottaDB LLC and/or its subsidiaries. #
# All rights reserved. #
# #
# This source code contains the intellectual property #
# of its copyright holder(s), and is made available #
# under a license. If you do not know the terms of #
# the license, please stop and do not read further. #
# #
#################################################################
cmake_minimum_required(VERSION 3.14)
include(FetchContent)
# The GIT_TAG is, at the time of this writing, the latest commit in YDBCMake.
# It is fixed at that point to ensure reproducible builds.
# Keep this periodically up to date with future YDBCMake commits.
# If YDBCMake is updated, and the update is material to Octo, the tag needs to be updated.
FetchContent_Declare(YDBCMake
GIT_REPOSITORY https://gitlab.com/YottaDB/Tools/YDBCMake.git
GIT_TAG e980b310b464c43d98a9731f126bdc6375b3fe1e
)
# The following sets ydbcmake_SOURCE_DIR
FetchContent_MakeAvailable(YDBCMake)
message(STATUS "YDBCMake Source Directory: ${ydbcmake_SOURCE_DIR}")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/;${ydbcmake_SOURCE_DIR}/ydbcmake/")
# Find YottaDB
find_package(YOTTADB REQUIRED)
# Do this unconditionally, as our cmake plugin double-checks our values to
# ensure correctness; i.e. if you set a bad ydb_dist, our plugin will set the
# correct value. You must double check it yourself in the status messages.
set(ENV{ydb_dist} ${YOTTADB_INCLUDE_DIRS})
message(STATUS "$ydb_dist: $ENV{ydb_dist}")
project(YDBOcto C M)
set(CMAKE_C_STANDARD 11)
set(YDBOCTO_MAJOR_VERSION 1)
set(YDBOCTO_MINOR_VERSION 1)
set(YDBOCTO_PATCH_VERSION 0)
set(MIN_YDB_RELEASE "1.29")
execute_process(
COMMAND ${PROJECT_SOURCE_DIR}/tools/get_ydb_release.sh ${MIN_YDB_RELEASE}
OUTPUT_VARIABLE YDB_RELEASE_STRING
RESULT_VARIABLE version_accepted
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/fixtures
)
if(NOT version_accepted)
message(STATUS "YottaDB version: r${YDB_RELEASE_STRING}")
else()
message(FATAL_ERROR "YottaDB version r${YDB_RELEASE_STRING} not supported. Minimum supported version: ${MIN_YDB_RELEASE}")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
set(CMAKE_INSTALL_PREFIX "$ENV{ydb_dist}/plugin")
option(DISABLE_INSTALL "Disable Installation?" OFF)
option(FULL_TEST_SUITE "Run full test suite?" OFF)
option(TEST_SPEED "Run separate speed test?" OFF)
option(TEST_VISTA "Run separate VistA test (Database needs to be set-up separately)?" OFF)
option(ENABLE_ASAN "Enable address sanitizer in build?" OFF)
option(ENABLE_AUTO_VAR_INIT_PATTERN "Enable -ftrivial-auto-var-init=pattern in build?" OFF)
option(FORCE_BINARY_DEFINITION_AUTO_UPGRADE "Force binary table definition auto upgrade?" OFF)
if(NOT ${DISABLE_INSTALL})
message(STATUS "Install destination: ${CMAKE_INSTALL_PREFIX}")
endif()
if(NOT ${FULL_TEST_SUITE})
message(STATUS "Test suite run by `make test`: Limited")
else()
message(STATUS "Test suite run by `make test`: Full")
endif()
if(${TEST_SPEED})
message(STATUS "`make test` will run speed test")
endif()
if(${TEST_VISTA})
message(STATUS "`make test` will run VistA tests")
endif()
# Check if YottaDB is compiled using ASAN. If so, enable ASAN by default
execute_process(COMMAND nm $ENV{ydb_dist}/libyottadb.so
COMMAND grep -c "U __asan_init"
OUTPUT_VARIABLE YDBASAN)
if(${YDBASAN} GREATER_EQUAL 1)
set(ENABLE_ASAN ON)
message(STATUS "Forcing Address Sanitizer usage as YottaDB is compiled using Address Sanitizer")
endif()
if(${ENABLE_ASAN})
message(STATUS "All Octo operations will have Address Santizer enabled")
endif()
if(${ENABLE_AUTO_VAR_INIT_PATTERN})
message(STATUS "All files will be compiled with -ftrivial-auto-var-init=pattern")
endif()
if(NOT ${DISABLE_INSTALL})
message(STATUS "Install destination: ${CMAKE_INSTALL_PREFIX}")
endif()
# This has to be here, as cmake/bats-tests.cmake is invoked from `src`, and
# thus will have a CMAKE_CURRENT_BINARY_DIR which is build/src/. We usually
# want it just as build.
set(TEST_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
include(CTest)
add_subdirectory(src)
# Sanity check to ensure that required variables are set
if(${TEST_VISTA} AND NOT EXISTS ${TEST_VISTA_ENV_FILE})
message(FATAL_ERROR "You must set TEST_VISTA_ENV_FILE (e.g. '~vehu/etc/env') if you set TEST_VISTA")
endif()