├── .gitattributes ├── .gitignore ├── Build.sh ├── CMakeLists.txt ├── GNUmakefile ├── LICENSE.txt ├── Makefile ├── README.markdown ├── clang-format-pre-commit-hook ├── cmake └── Modules │ ├── CBDownloadDeps.cmake │ ├── CouchbaseAddressSanitizer.cmake │ ├── CouchbaseClangOptions.cmake │ ├── CouchbaseCodeCoverage.cmake │ ├── CouchbaseCompilerOptions.cmake │ ├── CouchbaseCompression.cmake │ ├── CouchbaseDefaultValues.cmake │ ├── CouchbaseDefinitions.cmake │ ├── CouchbaseFunctions.cmake │ ├── CouchbaseGccOptions.cmake │ ├── CouchbaseGoogleTest.cmake │ ├── CouchbaseGoogleTestAddTests.cmake │ ├── CouchbaseInstall.cmake │ ├── CouchbaseLibFuzzer.cmake │ ├── CouchbaseMemoryAllocator.cmake │ ├── CouchbaseMsvcOptions.cmake │ ├── CouchbasePlugInUI.cmake │ ├── CouchbasePrecompiledHeaders.cmake │ ├── CouchbaseRpath.cmake │ ├── CouchbaseSanitizers.cmake │ ├── CouchbaseSelectCompiler.cmake │ ├── CouchbaseStandalonePackages.cmake │ ├── CouchbaseThreadSanitizer.cmake │ ├── CouchbaseUndefinedBehaviorSanitizer.cmake │ ├── CouchbaseUnityBuild.cmake │ ├── ErlangCheckPlt.cmake │ ├── FindCouchbaseBenchmark.cmake │ ├── FindCouchbaseBoost.cmake │ ├── FindCouchbaseBreakpad.cmake │ ├── FindCouchbaseCurl.cmake │ ├── FindCouchbaseDoubleConversion.cmake │ ├── FindCouchbaseErlang.cmake │ ├── FindCouchbaseFaiss.cmake │ ├── FindCouchbaseFlatbuffers.cmake │ ├── FindCouchbaseFmt.cmake │ ├── FindCouchbaseFolly.cmake │ ├── FindCouchbaseGflags.cmake │ ├── FindCouchbaseGlog.cmake │ ├── FindCouchbaseGo.cmake │ ├── FindCouchbaseGoogletest.cmake │ ├── FindCouchbaseGrpc.cmake │ ├── FindCouchbaseIcu.cmake │ ├── FindCouchbaseJemalloc.cmake │ ├── FindCouchbaseLZ4.cmake │ ├── FindCouchbaseLibevent.cmake │ ├── FindCouchbaseLibsodium.cmake │ ├── FindCouchbaseLiburing.cmake │ ├── FindCouchbaseLibuv.cmake │ ├── FindCouchbaseLua.cmake │ ├── FindCouchbaseNlohmannJson.cmake │ ├── FindCouchbaseNuma.cmake │ ├── FindCouchbaseOpenSSL.cmake │ ├── FindCouchbasePCRE.cmake │ ├── FindCouchbasePrometheus.cmake │ ├── FindCouchbaseSimdutf.cmake │ ├── FindCouchbaseSnappy.cmake │ ├── FindCouchbaseSpdlog.cmake │ ├── FindCouchbaseV8.cmake │ ├── FindCouchbaseValgrind.cmake │ ├── FindCouchbaseZstd.cmake │ ├── HeaderObjectLibrary.cmake │ ├── ListTargetProperties.cmake │ ├── MetricsMetadata.cmake │ ├── ParseArguments.cmake │ ├── PlatformIntrospection.cmake │ ├── README.md │ ├── add_metrics_metadata.cmake │ ├── cb_install_helper.cmake │ ├── go-buildyacc.cmake │ ├── go-modbuild.cmake │ ├── go-modtidy.cmake │ ├── go-modtidyall.cmake │ ├── go-test.cmake │ ├── go-yacc.cmake │ ├── rebar │ ├── rebar3 │ └── try_search_sanitizer_library.c ├── deps ├── CMakeLists.txt ├── couchbase-server-black-duck-manifest.yaml ├── manifest.cmake ├── packages │ ├── CMakeLists.txt │ ├── benchmark │ │ └── CMakeLists.txt │ ├── boost │ │ └── CMakeLists.txt │ ├── double-conversion │ │ └── CMakeLists.txt │ ├── flatbuffers │ │ ├── CMakeLists.txt │ │ └── macos_disable_werror.patch │ ├── fmt │ │ └── CMakeLists.txt │ ├── folly │ │ ├── CMakeLists.txt │ │ └── CMakeLists_package.txt │ ├── glog │ │ └── CMakeLists.txt │ ├── googletest │ │ └── CMakeLists.txt │ ├── grpc │ │ ├── CMakeLists.txt │ │ ├── grpc_unix.sh │ │ └── grpc_windows.bat │ ├── icu4c │ │ ├── CMakeLists.txt │ │ ├── check_xlocale_h.sh │ │ ├── icu4c_mac.patch │ │ ├── icu4c_unix.cmake │ │ ├── icu4c_windows.bat │ │ └── icu4c_windows.cmake │ ├── json │ │ └── CMakeLists.txt │ ├── libcxx │ │ └── CMakeLists.txt │ ├── libevent │ │ ├── CMakeLists.txt │ │ └── CMakeLists_package.txt │ ├── libsqlite3 │ │ └── CMakeLists.txt │ ├── libuv │ │ ├── CMakeLists.txt │ │ ├── CMakeLists_package.txt │ │ ├── libuv_unix.sh │ │ └── libuv_windows.bat │ ├── maven │ │ ├── CMakeLists.txt │ │ ├── CMakeLists_package.txt │ │ ├── maven_unix.sh │ │ └── maven_windows.bat │ ├── numactl │ │ ├── CMakeLists.txt │ │ ├── CMakeLists_package.txt │ │ ├── numactl_define.patch │ │ ├── numactl_unix.sh │ │ └── numactl_windows.bat │ ├── openjdk-rt │ │ ├── CMakeLists.txt │ │ └── dl_rt_jar.cmake │ ├── pcre │ │ ├── CMakeLists.txt │ │ ├── CMakeLists_package.txt │ │ ├── pcre_unix.sh │ │ └── pcre_windows.bat │ ├── prometheus-cpp │ │ └── CMakeLists.txt │ ├── python-snappy │ │ └── CMakeLists.txt │ ├── snappy │ │ ├── CMakeLists.txt │ │ ├── CMakeLists_package.txt │ │ └── snappy.patch │ ├── spdlog │ │ ├── CMakeLists.txt │ │ └── custom_level_names.patch │ ├── util │ │ └── GenMD5.cmake │ └── zlib │ │ ├── CMakeLists.txt │ │ ├── CMakeLists_package.txt │ │ ├── zlib_unix.sh │ │ └── zlib_windows.bat └── scripts │ ├── build-one-cbdep │ └── build-one-cbdep.bat ├── dot-clang-format ├── dot-clang-tidy ├── install_hook.sh ├── licenses ├── APL2.txt └── BSL-Couchbase.txt ├── lsan.suppressions ├── python ├── CMakeLists.txt ├── PyWrapperFunctions.cmake ├── py-wrapper.c.tmpl └── py-wrapper.sh.tmpl ├── scripts ├── calc_header_costs.py ├── create-builder ├── enter-builder ├── get_manifest_annot.py └── show_ninja_build_stats ├── tag_release.py ├── third-party-CMakeLists.txt ├── tsan.suppressions ├── ubsan.suppressions ├── valgrind.supp └── win32 └── environment.bat /.gitattributes: -------------------------------------------------------------------------------- 1 | deps/packages/erlang/erlang_windows.sh text eol=lf 2 | deps/packages/erlang/cygwin.bash_profile text eol=lf 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .DS_Store 3 | deps/packages/build/ 4 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | # PLEASE NOTE: This Makefile is provided as a convenience for those 2 | # who do not wish to interact with CMake. It is NOT SUPPORTED by the 3 | # Couchbase build team, and the production builds do NOT make use of 4 | # it, so bugs filed against it will need to be handled by those devs 5 | # who care to use it. 6 | 7 | ROOT:=$(CURDIR) 8 | PREFIX:=$(ROOT)/install 9 | MAKEFLAGS=--no-print-directory 10 | 11 | PASSTHRU_TARGETS=all all-go analytics-install analyze clean clean-all clean-xfd clean-xfd-hard \ 12 | e2etest e2eviewtests everything geocouch-build-for-testing go-mod-tidy install reset run-mats \ 13 | test unset-version build/Makefile 14 | 15 | $(PASSTHRU_TARGETS): 16 | @$(MAKE) -f Makefile \ 17 | MAKETYPE="Unix Makefiles" \ 18 | PREFIX="$(PREFIX)" CHMODCMD="chmod u+w" CP=cp \ 19 | SEPARATOR=/ RM=rm RMOPTS=-rf $@ 20 | 21 | DEPS_DIR := $(ROOT)/tlm/deps/packages 22 | 23 | # it's a little wasteful to call cmake all the time, but the code path taken 24 | # there might depend on the presence/absence of downloaded dependencies 25 | .PHONY: build_deps deps-all 26 | build_deps: 27 | mkdir -p build_deps 28 | (cd build_deps && cmake $(DEPS_DIR)) 29 | 30 | dep-%: build_deps 31 | $(MAKE) -C "build_deps" $(@:dep-%=build-and-cache-%) 32 | 33 | deps-all: build_deps 34 | $(MAKE) -C "build_deps" build-and-cache-all 35 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Source code in this repository is licensed under various licenses. The 2 | Business Source License 1.1 (BSL) is one such license. Each file indicates in 3 | a section at the beginning of the file the name of the license that applies to 4 | it. All licenses used in this repository can be found in the top-level 5 | licenses directory. 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # -*- Mode: makefile -*- 2 | 3 | # PLEASE NOTE: This Makefile is provided as a convenience for those 4 | # who do not wish to interact with CMake. It is NOT SUPPORTED by the 5 | # Couchbase build team, and the production builds do NOT make use of 6 | # it, so bugs filed against it will need to be handled by those devs 7 | # who care to use it. 8 | 9 | # The default destination for installing. CMake will also search for 10 | # dependencies in this directory, so you may pre-build dependencies 11 | # that you wish to ship with your compiled Couchbase into this 12 | # directory. 13 | PREFIX=$(MAKEDIR)\\install 14 | # The makefile type to generate 15 | MAKETYPE=NMake Makefiles 16 | # The command used to delete directories 17 | RM=rmdir 18 | # Options passed to the command to nuke directories 19 | RMOPTS=/Q /S 20 | # Other options you would like to pass to cmake 21 | EXTRA_CMAKE_OPTIONS= 22 | # Command used to remove read only flag for files 23 | CHMODCMD=attrib -r 24 | # Command used for copying files 25 | CP=copy 26 | # path separator 27 | SEPARATOR=\\ 28 | 29 | CMAKE=cmake 30 | 31 | CMAKE_ARGS=-G "$(MAKETYPE)" $(EXTRA_CMAKE_OPTIONS) 32 | 33 | 34 | all: CMakeLists.txt Makefile GNUmakefile build/Makefile compile 35 | 36 | everything: build/Makefile 37 | (cd build && $(MAKE) everything install) 38 | 39 | compile: build/Makefile 40 | (cd build && $(MAKE) all install) 41 | 42 | test: all 43 | (cd build && $(MAKE) test) 44 | 45 | build/Makefile: CMakeLists.txt 46 | @-mkdir build 47 | (cd build && $(CMAKE) $(CMAKE_ARGS) ..) 48 | 49 | CMakeLists.txt: tlm/CMakeLists.txt 50 | $(CHMODCMD) CMakeLists.txt 51 | $(CP) tlm$(SEPARATOR)CMakeLists.txt CMakeLists.txt 52 | 53 | GNUmakefile: tlm/GNUmakefile 54 | $(CHMODCMD) GNUmakefile 55 | $(CP) tlm$(SEPARATOR)GNUmakefile GNUmakefile 56 | 57 | Makefile: tlm/Makefile 58 | $(CHMODCMD) Makefile 59 | $(CP) tlm$(SEPARATOR)Makefile Makefile 60 | 61 | 62 | # Invoke static analyser. Requires Clang Static Analyser 63 | # (http://clang-analyzer.llvm.org). See tlm/README.markdown for more 64 | # information. 65 | analyze: 66 | @-mkdir build-analyzer 67 | (cd build-analyzer && \ 68 | scan-build --use-analyzer=Xcode $(CMAKE) $(CMAKE_ARGS) -DCOUCHBASE_DISABLE_CCACHE=1 .. && \ 69 | scan-build --use-analyzer=Xcode -o analyser-results/ $(MAKE) all) 70 | 71 | # geocouch needs a special build for running the unit tests 72 | geocouch-build-for-testing: compile 73 | @-mkdir build/geocouch-for-tests 74 | (cd build/geocouch-for-tests && \ 75 | $(CMAKE) $(CMAKE_ARGS) -D CMAKE_INSTALL_PREFIX="$(PREFIX)" \ 76 | -D GEOCOUCH_BUILD_FOR_UNIT_TESTS=1 ../../geocouch && \ 77 | $(MAKE)) 78 | 79 | go-mod-tidy: build/Makefile 80 | (cd build && make go-mod-tidy) 81 | 82 | all-go: build/Makefile 83 | cd build && $(MAKE) all-go 84 | 85 | analytics-install: build/Makefile 86 | (cd build && make analytics) 87 | 88 | run-mats: 89 | cd testrunner && $(MAKE) simple-test 90 | 91 | e2etest: 92 | cd testrunner && $(MAKE) test 93 | 94 | e2eviewtests: 95 | cd testrunner && $(MAKE) test-views 96 | 97 | clean: 98 | -(cd build && $(MAKE) realclean) 99 | -$(RM) $(RMOPTS) build ns_server$(SEPARATOR)_build install voltron$(SEPARATOR)build analytics$(SEPARATOR)target 100 | 101 | reset: 102 | (cd build && $(MAKE) reset) 103 | 104 | clean-xfd: clean 105 | -(cd ns_server && git clean -dfxq) 106 | 107 | clean-xfd-hard: clean-xfd 108 | 109 | clean-all: clean-xfd-hard 110 | 111 | 112 | # "Convenience" target for forcing CMake to recompute PRODUCT_VERSION. 113 | # Only useful if PRODUCT_VERSION was previously explicitly specified with 114 | # -D on the CMake command line, or if you're re-syncing your manifest from 115 | # an older version which always cached PRODUCT_VERSION. 116 | # Only works on Unix. 117 | unset-version: 118 | sed -i -e 's/PRODUCT_VERSION:STRING=.*//' build/CMakeCache.txt 119 | -------------------------------------------------------------------------------- /clang-format-pre-commit-hook: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | config=$(git config couchbase.clangformat) 12 | 13 | has_issues () { 14 | diff=$(git clang-format --diff) 15 | [[ $diff == diff* ]] 16 | } 17 | 18 | reformat () { 19 | if [ ! $config = "commit" ] ; then 20 | echo -n "Commit rejected. " 21 | fi 22 | echo "Running \`git clang-format\` to fix style..." 23 | reformat_results=$(git clang-format) 24 | ret_val=$? 25 | echo "$reformat_results" 26 | return $ret_val 27 | } 28 | 29 | add_reformatted_files () { 30 | # Hacky. Skips the first line of the output from clang-format, 31 | # strips leading spaces, and replaces newlines with nulls, to 32 | # pass to xargs -0 (because xargs -d is a GNU extension) 33 | # to stage all changes. Better ways would be appreciated! 34 | echo "$reformat_results" | tail -n +2 | sed -e 's/^[[:space:]]*//' | tr '\n' '\0' | xargs -0 git add 35 | } 36 | 37 | if has_issues ; then 38 | case $config in 39 | (fix) 40 | reformat 41 | if [ $? = 0 ] ; then 42 | echo "Review changes, add, and commit again." 43 | fi 44 | exit 1 45 | ;; 46 | (stage) 47 | reformat 48 | if [ $? = 0 ] ; then 49 | add_reformatted_files 50 | fi 51 | exit 1 52 | ;; 53 | (commit) 54 | reformat 55 | if [ $? = 0 ] ; then 56 | add_reformatted_files 57 | exit 0 58 | fi 59 | exit 1 60 | ;; 61 | (*) 62 | echo "Commit rejected as clang-format detected formatting issues." 63 | echo " Run \`git clang-format --diff\` to view suggested changes" 64 | echo " and \`git clang-format\` to apply them." 65 | echo " Alternatively, use \`git commit --no-verify\` to skip hooks." 66 | exit 1 67 | ;; 68 | esac 69 | fi 70 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseCodeCoverage.cmake: -------------------------------------------------------------------------------- 1 | # Support for running code coverage reporting. 2 | # 3 | # Usage: 4 | # 1). Add a call to ENABLE_CODE_COVERAGE_REPORT() to the module(s) you wish to 5 | # obtain code coverage reports on. 6 | # 2). Enable the option CB_CODE_COVERAGE (e.g. pass -DCB_CODE_COVERAGE=ON to cmake). 7 | # 3). Build as normal. 8 | # 4). Run unit test(s) to exercise the codebase. 9 | # 5). Run `make coverage-report-html` and/or `coverage-report-xml` 10 | # (from the selected module subdirectory) to generate the reports. 11 | # 6) (Optional) to zero coverage counters before a re-run run `make coverage-zero-counters`. 12 | # 13 | # Note 1: Do make sure you have gcov and gcovr installed! 14 | # 15 | # Note 2: If you followed all the steps above but the coverage report is empty, 16 | # try to use "touch CMakeCache.txt" in your build directory, then rebuild the project and rerun the coverage report 17 | 18 | OPTION(CB_CODE_COVERAGE "Enable code coverage testing." 19 | OFF) 20 | 21 | IF (CB_CODE_COVERAGE) 22 | FIND_PROGRAM(GCOV_PATH gcov) 23 | FIND_PROGRAM(GCOVR_PATH gcovr) 24 | 25 | IF (NOT GCOV_PATH) 26 | MESSAGE(STATUS "gcov not found.") 27 | ENDIF (NOT GCOV_PATH) 28 | 29 | IF (NOT GCOVR_PATH) 30 | MESSAGE(STATUS "gcovr [www.gcovr.com] not found. HTML / XML coverage report rules will not be available") 31 | ENDIF () 32 | 33 | IF (NOT GCOV_PATH) 34 | MESSAGE(FATAL_ERROR "CB_CODE_COVERAGE enabled but a required tool (gcov) was not found - cannot continue.") 35 | ENDIF() 36 | ENDIF(CB_CODE_COVERAGE) 37 | 38 | # Defines a coverage report for the current module. If CB_CODE_COVERAGE is enabled, 39 | # adds three new targets to that module: 40 | # -coverage-zero-counters: Zeros the code coverage counters for the module. 41 | # -coverage-report-html: Generates a code coverage report in HTML. 42 | # -coverage-report-xml: Generates a code coverage report in XML. 43 | # 44 | # Note: The html and xml report targets are not added if gcovr is not found 45 | # 46 | # Usage: 47 | # 1) `make -coverage-zero-counters` to clear any counters from 48 | # previously-executed programs. 49 | # 2) Run whatever programs to excercise the code (unit tests, etc). 50 | # 3) `make -coverage-report-{html,xml}` to generate a report. 51 | # 52 | FUNCTION(ENABLE_CODE_COVERAGE_REPORT) 53 | GET_FILENAME_COMPONENT(_cc_project ${CMAKE_CURRENT_BINARY_DIR} NAME) 54 | 55 | IF (CB_CODE_COVERAGE) 56 | MESSAGE(STATUS "Setting up code coverage for ${PROJECT_NAME}") 57 | 58 | ADD_CUSTOM_TARGET(${_cc_project}-coverage-zero-counters 59 | COMMAND find . -name *.gcda -exec rm {} \; 60 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 61 | COMMENT "Zeroing coverage counters for objects in ${CMAKE_CURRENT_BINARY_DIR}" 62 | VERBATIM) 63 | 64 | IF (GCOVR_PATH) 65 | ADD_CUSTOM_TARGET(${_cc_project}-coverage-report-html 66 | COMMAND ${CMAKE_COMMAND} -E remove_directory coverage 67 | COMMAND ${CMAKE_COMMAND} -E make_directory coverage 68 | COMMAND ${GCOVR_PATH} --root=${CMAKE_SOURCE_DIR} --filter="${CMAKE_CURRENT_SOURCE_DIR}/.*" --html --html-details -o coverage/index.html 69 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 70 | COMMENT "Generating code coverage report for ${PROJECT_NAME} to ${CMAKE_CURRENT_BINARY_DIR}/coverage/index.html") 71 | 72 | ADD_CUSTOM_TARGET(${_cc_project}-coverage-report-xml 73 | COMMAND ${GCOVR_PATH} --root=${CMAKE_SOURCE_DIR} --filter="${CMAKE_CURRENT_SOURCE_DIR}/.*" --xml -o coverage.xml 74 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 75 | COMMENT "Generating code coverage report for ${PROJECT_NAME} to ${CMAKE_CURRENT_BINARY_DIR}/coverage.xml") 76 | ENDIF (GCOVR_PATH) 77 | ENDIF (CB_CODE_COVERAGE) 78 | ENDFUNCTION() 79 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseCompression.cmake: -------------------------------------------------------------------------------- 1 | # Setup all of the compression related stuff 2 | include(FindCouchbaseLZ4) 3 | include(FindCouchbaseSnappy) 4 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseDefaultValues.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Set up default values for couchbase related variables 3 | # 4 | 5 | IF ("${INSTALL_HEADER_FILES}" STREQUAL "") 6 | SET(INSTALL_HEADER_FILES false) 7 | ENDIF () 8 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseDefinitions.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (WIN32) 3 | add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) 4 | add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) 5 | # Valgrind's macros doesn't support MSVC - disable any attempt to use them. 6 | add_definitions(-DNVALGRIND) 7 | add_definitions(-DNOMINMAX=1) 8 | 9 | # MSVC 2017 warns about deprecation of TR1 namespace which cause 10 | # the build to fail 11 | add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1) 12 | else () 13 | add_definitions(-D_POSIX_PTHREAD_SEMANTICS) 14 | add_definitions(-D_GNU_SOURCE=1) 15 | add_definitions(-D__EXTENSIONS__=1) 16 | endif () 17 | 18 | add_definitions(-D__STDC_FORMAT_MACROS) 19 | add_definitions(-Dgsl_CONFIG_CONTRACT_VIOLATION_THROWS) 20 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseFunctions.cmake: -------------------------------------------------------------------------------- 1 | # Add an executable for a test program / benchmark. 2 | # 3 | # This target is not added to the "all" target, so will not be built by 4 | # default. It is instead added as a dependency of the "everything" target. 5 | # Is it also added to a project-specific "_everything" target, allowing 6 | # an easy way to build everything in a given project - e.g kv_engine_everything. 7 | function(cb_add_test_executable name) 8 | add_executable(${name} EXCLUDE_FROM_ALL ${ARGN}) 9 | set_property(TARGET ${name} PROPERTY CB_TEST_EXECUTABLE ON) 10 | endfunction() 11 | 12 | macro(get_all_targets_recursive targets dir) 13 | get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) 14 | foreach(subdir ${subdirectories}) 15 | get_property(exclude_from_all DIRECTORY ${subdir} PROPERTY EXCLUDE_FROM_ALL) 16 | if(NOT exclude_from_all) 17 | get_all_targets_recursive(${targets} ${subdir}) 18 | endif() 19 | endforeach() 20 | 21 | get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) 22 | list(APPEND ${targets} ${current_targets}) 23 | endmacro() 24 | 25 | # Define 'everything' custom target - build "everything". 26 | # 27 | # Define a target named "everything" which builds: 28 | # a) Targets which are part of 'ALL' (i.e. everything which isn't marked as 29 | # EXCLUDE_FROM_ALL), plus 30 | # b) all targets built via cb_add_test_executable(). 31 | # 32 | # This doesn't build absolutely everything; it will not build targets which 33 | # are explictly marked as EXCLUDE_FROM_ALL and not otherwise marked as 34 | # CB_TEST_EXECUTABLE - for example third-party libraries' test programs will 35 | # still be skipped. 36 | # 37 | # Note this function must be called after all targets have been defined - as 38 | # it must recursively scan all directories to locate all defined targets. 39 | function(define_everything_targets) 40 | add_custom_target(everything) 41 | set(targets) 42 | get_all_targets_recursive(targets ${CMAKE_CURRENT_SOURCE_DIR}) 43 | 44 | # Add to project-specific everything target (_everything): 45 | foreach(target ${targets}) 46 | # Skip INTERFACE targets - they aren't part of all or test executables, 47 | # and additionally it's an error for us to try to read custom 48 | # properties on them. 49 | get_property(target_type TARGET ${target} PROPERTY TYPE) 50 | if(NOT (target_type STREQUAL "INTERFACE" OR target_type STREQUAL "INTERFACE_LIBRARY")) 51 | # Read EXCLUDE_FROM_ALL and CB_TEST_EXECUTABLE properties of 52 | # the target. 53 | get_property(exclude_from_all TARGET ${target} PROPERTY EXCLUDE_FROM_ALL) 54 | get_property(cb_test_executable TARGET ${target} PROPERTY CB_TEST_EXECUTABLE) 55 | 56 | # Add to the *everything targets if target doesn't have 57 | # EXCLUDE_FROM_ALL set or does have CB_TEST_EXECUTABLE set. 58 | if ((NOT exclude_from_all) OR cb_test_executable) 59 | # Get the relative project source dir for the target 60 | # e.g. /Users/dave/repos/couchbase/server/source/kv_engine -> kv_engine 61 | get_property(target_source_dir TARGET ${target} PROPERTY SOURCE_DIR) 62 | string(REPLACE "${CMAKE_SOURCE_DIR}/" "" relative_project_dir ${target_source_dir}) 63 | 64 | # Get the base directory if this is a sub-project 65 | # e.g. kv_engine/engines/ep -> kv_engine 66 | string(REGEX REPLACE "/.*$" "" base_project_dir ${relative_project_dir}) 67 | 68 | # Define the _everything target if it doesn't already 69 | # exist. 70 | if(NOT TARGET "${base_project_dir}_everything") 71 | add_custom_target("${base_project_dir}_everything") 72 | add_dependencies("everything" "${base_project_dir}_everything") 73 | endif() 74 | add_dependencies("${base_project_dir}_everything" ${target}) 75 | endif ((NOT exclude_from_all) OR cb_test_executable) 76 | endif(NOT (target_type STREQUAL "INTERFACE" OR target_type STREQUAL "INTERFACE_LIBRARY")) 77 | endforeach() 78 | endfunction() 79 | 80 | # Register the above as an end-of-cmake-time hook. 81 | SET_PROPERTY (GLOBAL APPEND PROPERTY CB_CMAKE_END_HOOKS define_everything_targets) 82 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseGccOptions.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Set the compiler flags for gcc and g++ compilator 17 | 18 | # Add common flags for C and C++ 19 | if (CB_CODE_COVERAGE) 20 | list(APPEND _cb_c_flags --coverage) 21 | set(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} --coverage") 22 | endif () 23 | 24 | if (NOT COUCHBASE_OMIT_FRAME_POINTER) 25 | message(STATUS "Add -fno-omit-frame-pointer") 26 | list(APPEND _cb_c_flags -fno-omit-frame-pointer) 27 | endif() 28 | 29 | list(APPEND _cb_c_flags -fvisibility=hidden -pthread) 30 | # Copy the flags over to C++ 31 | set(_cb_cxx_flags ${_cb_c_flags}) 32 | 33 | # Add C specific options 34 | list(APPEND cb_c_flags 35 | -std=gnu99 36 | -Wall 37 | -pedantic 38 | -Werror=missing-prototypes 39 | -Werror=missing-declarations 40 | -Wredundant-decls 41 | -fno-strict-aliasing 42 | -Wno-overlength-strings 43 | -Wshadow=compatible-local) 44 | 45 | # Convert the list to a string 46 | string(REPLACE ";" " " _cb_c_options "${_cb_c_flags}") 47 | 48 | # We want RelWithDebInfo to have the same optimization level as 49 | # Release, only differing in whether debugging information is enabled. 50 | set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") 51 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -DNDEBUG -g") 52 | set(CMAKE_C_FLAGS_DEBUG "-Og -g") 53 | set(CB_C_FLAGS_NO_OPTIMIZE "-O0") 54 | set(CB_FLAGS_OPTIMIZE_FOR_DEBUG ${CMAKE_C_FLAGS_DEBUG}) 55 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_cb_c_options}") 56 | 57 | # Configure the C++ compiler 58 | list(APPEND _cb_cxx_flags 59 | -pedantic 60 | -Wall 61 | -Wredundant-decls 62 | -fno-strict-aliasing 63 | -Werror=switch 64 | -Wshadow=compatible-local) 65 | 66 | SET(CB_GNU_CXX11_OPTION "-std=gnu++17") 67 | 68 | # Convert the list to a string 69 | string(REPLACE ";" " " _cb_cxx_options "${_cb_cxx_flags}") 70 | 71 | # We want RelWithDebInfo to have the same optimization level as 72 | # Release, only differing in whether debugging information is enabled. 73 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") 74 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -DNDEBUG -g") 75 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 76 | set(CB_CXX_FLAGS_NO_OPTIMIZE "-O0") 77 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cb_cxx_options}") 78 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseInstall.cmake: -------------------------------------------------------------------------------- 1 | # Functions for installing targets and their dependencies. 2 | 3 | if (NOT CouchbaseInstall_INCLUDED) 4 | 5 | include (ParseArguments) 6 | 7 | # Load the helper functions into the install scripts. 8 | install(SCRIPT "${CMAKE_CURRENT_LIST_DIR}/cb_install_helper.cmake" ALL_COMPONENTS) 9 | 10 | # Installs the runtime dependencies of a target. 11 | # 12 | # Required arguments: 13 | # 14 | # TARGET - name of an existing target. The target must be either a 15 | # standard ADD_EXECUTABLE() or ADD_LIBRARY(SHARED) target. 16 | function (InstallDeps) 17 | 18 | parse_arguments(Ins "TARGET" "" "" ${ARGN}) 19 | if (NOT Ins_TARGET) 20 | message(FATAL_ERROR "TARGET is required!") 21 | endif () 22 | 23 | # Determine the target type 24 | get_target_property (_type ${Ins_TARGET} TYPE) 25 | if (_type STREQUAL "EXECUTABLE") 26 | set (_install_type EXECUTABLES) 27 | elseif (_type STREQUAL "SHARED_LIBRARY") 28 | set (_install_type LIBRARIES) 29 | else () 30 | message(FATAL_ERROR "TARGET '${Ins_TARGET}' must be an executable or shared library!") 31 | endif () 32 | set (_binary "$") 33 | 34 | # MB-63898: Hack! Until we have proper "Modern CMake" IMPORTED 35 | # targets for each of these, we need to manually pass in the paths 36 | # to the DLLs for each of the depenedencies of the `magma_shared` 37 | # target (the only one using InstallWithDeps() so far). This is only 38 | # needed on Windows. Once they can all be removed, we can also drop 39 | # ${_deps_dirs} from the install(CODE) below. 40 | if (WIN32) 41 | set(TLM_DEPS_DIR "${CMAKE_BINARY_DIR}/tlm/deps") 42 | if (CMAKE_BUILD_TYPE STREQUAL Debug) 43 | set (_deps_dirs "${TLM_DEPS_DIR}/jemalloc.exploded/Debug/bin") 44 | else () 45 | set (_deps_dirs "${TLM_DEPS_DIR}/jemalloc.exploded/Release/bin") 46 | endif () 47 | list (APPEND _deps_dirs 48 | "${TLM_DEPS_DIR}/openssl.exploded/bin" 49 | "${TLM_DEPS_DIR}/snappy.exploded/bin" 50 | "${TLM_DEPS_DIR}/zstd-cpp.exploded/bin" 51 | ) 52 | endif () 53 | 54 | # Pass the paths to DLLs that CMake knows about from imported targets 55 | install (CODE "InstallDependencies(${_binary} ${_install_type} $ ${_deps_dirs})") 56 | 57 | endfunction(InstallDeps) 58 | 59 | # Installs targets with all their runtime dependencies. 60 | # 61 | # Required arguments: 62 | # 63 | # TARGETS - names of existing targets. Each target must be either a 64 | # standard ADD_EXECUTABLE() or ADD_LIBRARY(SHARED) target. 65 | function (InstallWithDeps) 66 | 67 | parse_arguments(Ins "" "TARGETS" "" ${ARGN}) 68 | if (NOT Ins_TARGETS) 69 | message(FATAL_ERROR "TARGETS is required!") 70 | endif () 71 | 72 | foreach (_target ${Ins_TARGETS}) 73 | # Check the target type is appropriate 74 | get_target_property (_type ${_target} TYPE) 75 | if (NOT ( _type STREQUAL "EXECUTABLE" OR _type STREQUAL "SHARED_LIBRARY" ) ) 76 | message(FATAL_ERROR "TARGET must be an executable or shared library!") 77 | endif () 78 | 79 | # Install the target itself 80 | install (TARGETS ${_target}) 81 | 82 | # Install the target's runtime dependencies 83 | InstallDeps(TARGET ${_target}) 84 | endforeach (_target) 85 | 86 | endfunction(InstallWithDeps) 87 | 88 | set(CouchbaseInstall_INCLUDED 1) 89 | endif (NOT CouchbaseInstall_INCLUDED) -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseLibFuzzer.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCCompilerFlag) 2 | include(CheckCXXCompilerFlag) 3 | include(CMakePushCheckState) 4 | 5 | option(CB_LIBFUZZER "Enable LibFuzzer (https://llvm.org/docs/LibFuzzer.html)") 6 | 7 | if (CB_LIBFUZZER) 8 | cmake_push_check_state(RESET) 9 | set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link") 10 | check_c_compiler_flag("-fsanitize=fuzzer-no-link" HAVE_FLAG_SANITIZE_FUZZER_C) 11 | check_cxx_compiler_flag("-fsanitize=fuzzer-no-link" HAVE_FLAG_SANITIZE_FUZZER_CXX) 12 | cmake_pop_check_state() 13 | 14 | if (HAVE_FLAG_SANITIZE_FUZZER_C AND HAVE_FLAG_SANITIZE_FUZZER_CXX) 15 | set(LIBFUZZER_SANITIZER_FLAG "-fsanitize=fuzzer-no-link") 16 | set(LIBFUZZER_SANITIZER_FLAG_DISABLE "-fno-sanitize=fuzzer-no-link") 17 | add_definitions(-DFUZZ_SANITIZER) 18 | message(STATUS "LibFuzzer Sanitizer enabled") 19 | else () 20 | message(FATAL_ERROR "CB_LIBFUZZER enabled but compiler doesn't support fuzzer-no-link - cannot continue.") 21 | endif () 22 | endif () 23 | 24 | function(add_sanitize_libfuzzer TARGET) 25 | if (CB_LIBFUZZER) 26 | set_property(TARGET ${TARGET} APPEND_STRING 27 | PROPERTY COMPILE_FLAGS " ${LIBFUZZER_SANITIZER_FLAG}") 28 | set_property(TARGET ${TARGET} APPEND_STRING 29 | PROPERTY LINK_FLAGS " ${LIBFUZZER_SANITIZER_FLAG}") 30 | endif () 31 | endfunction() 32 | 33 | # Link a program and supply the main driver for libfuzzer 34 | function(cb_link_libfuzzer_main TARGET) 35 | target_link_options(${TARGET} PUBLIC -fsanitize=fuzzer) 36 | endfunction() 37 | 38 | function(remove_sanitize_libfuzzer TARGET) 39 | if (CB_LIBFUZZER) 40 | remove_from_property(${TARGET} COMPILE_OPTIONS ${LIBFUZZER_SANITIZER_FLAG}) 41 | remove_from_property(${TARGET} LINK_OPTIONS ${LIBFUZZER_SANITIZER_FLAG}) 42 | set_property(TARGET ${TARGET} APPEND_STRING 43 | PROPERTY COMPILE_FLAGS " ${LIBFUZZER_SANITIZER_FLAG_DISABLE}") 44 | set_property(TARGET ${TARGET} APPEND_STRING 45 | PROPERTY LINK_FLAGS " ${LIBFUZZER_SANITIZER_FLAG_DISABLE}") 46 | endif () 47 | endfunction() 48 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseMemoryAllocator.cmake: -------------------------------------------------------------------------------- 1 | SET(COUCHBASE_MEMORY_ALLOCATOR "" CACHE STRING "The memory allocator to use. ") 2 | SET_PROPERTY(CACHE COUCHBASE_MEMORY_ALLOCATOR PROPERTY STRINGS 3 | system jemalloc) 4 | 5 | INCLUDE(FindCouchbaseJemalloc) 6 | 7 | IF (COUCHBASE_MEMORY_ALLOCATOR) 8 | IF ("${COUCHBASE_MEMORY_ALLOCATOR}" STREQUAL "jemalloc") 9 | IF (JEMALLOC_FOUND) 10 | SET(MEMORY_ALLOCATOR jemalloc) 11 | ELSE (JEMALLOC_FOUND) 12 | MESSAGE(FATAL_ERROR "Could not find JEMalloc") 13 | ENDIF (JEMALLOC_FOUND) 14 | ELSEIF ("${COUCHBASE_MEMORY_ALLOCATOR}" STREQUAL "badmalloc") 15 | SET(MEMORY_ALLOCATOR badmalloc) 16 | ELSEIF ("${COUCHBASE_MEMORY_ALLOCATOR}" STREQUAL "system") 17 | SET(MEMORY_ALLOCATOR system) 18 | ELSE ("${COUCHBASE_MEMORY_ALLOCATOR}" STREQUAL "system") 19 | MESSAGE(FATAL_ERROR "Unknown memory allocator specified") 20 | ENDIF ("${COUCHBASE_MEMORY_ALLOCATOR}" STREQUAL "jemalloc") 21 | 22 | ELSE (COUCHBASE_MEMORY_ALLOCATOR) 23 | # No allocator explicitly selected by user, prefer jemalloc if available 24 | IF (JEMALLOC_FOUND) 25 | SET(MEMORY_ALLOCATOR jemalloc) 26 | ELSE () 27 | SET(MEMORY_ALLOCATOR system) 28 | ENDIF () 29 | ENDIF (COUCHBASE_MEMORY_ALLOCATOR) 30 | 31 | # Finally, set the appropriate defines for our selected memory allocator. 32 | IF (MEMORY_ALLOCATOR STREQUAL "jemalloc") 33 | ADD_DEFINITIONS(-DHAVE_JEMALLOC) 34 | SET(MALLOC_LIBRARIES ${JEMALLOC_LIBRARIES}) 35 | SET(MALLOC_INCLUDE_DIR ${JEMALLOC_INCLUDE_DIR}) 36 | MESSAGE(STATUS "Using JEMalloc") 37 | IF (HAVE_JEMALLOC_SDALLOCX) 38 | ADD_DEFINITIONS(-DHAVE_JEMALLOC_SDALLOCX) 39 | ENDIF() 40 | ELSEIF (MEMORY_ALLOCATOR STREQUAL "system") 41 | ADD_DEFINITIONS(-DHAVE_SYSTEM_MALLOC) 42 | MESSAGE(STATUS "Using system-supplied malloc") 43 | ENDIF (MEMORY_ALLOCATOR STREQUAL "jemalloc") 44 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbasePlugInUI.cmake: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED (VERSION 3.19) 2 | 3 | # Prevent double-definition if two projects use this script 4 | IF (NOT PLUG_IN_UI_INCLUDED) 5 | SET (PLUG_IN_UI_INCLUDED 1) 6 | SET (NS_UI_BUILD_DIR "${CMAKE_BINARY_DIR}/ui-build") 7 | SET (NS_UI_INSTALL_DIR "lib/ns_server/erlang/lib/ns_server/priv/public") 8 | SET (NS_UI_PUB_DIR "${NS_UI_BUILD_DIR}/public") 9 | FILE (REMOVE "${NS_UI_BUILD_DIR}/public/pluggable-uis.js") 10 | 11 | MACRO(WATCH_AND_COPY_SOURCES src_dir bin_dir stamp_path service_name) 12 | FILE (GLOB_RECURSE UI_SRC_JS_FILES CONFIGURE_DEPENDS "${src_dir}/*.js") 13 | FILE (GLOB_RECURSE UI_SRC_HTML_FILES CONFIGURE_DEPENDS "${src_dir}/*.html") 14 | ADD_CUSTOM_COMMAND (OUTPUT "${bin_dir}" 15 | COMMAND ${CMAKE_COMMAND} -E create_symlink "${src_dir}" "${bin_dir}") 16 | ADD_CUSTOM_COMMAND (OUTPUT "${stamp_path}.js.stamp" 17 | COMMAND "${CMAKE_COMMAND}" -E touch "${stamp_path}.js.stamp" 18 | DEPENDS ${UI_SRC_JS_FILES} ${UI_SRC_HTML_FILES} 19 | VERBATIM) 20 | ADD_CUSTOM_TARGET ("${service_name}_ui_build_prepare" 21 | DEPENDS "${bin_dir}" 22 | DEPENDS "${stamp_path}.js.stamp") 23 | ADD_DEPENDENCIES (ui_build "${service_name}_ui_build_prepare") 24 | ENDMACRO(WATCH_AND_COPY_SOURCES) 25 | 26 | MACRO(PLUG_IN_UI pluggable_ui_json_name) 27 | SET (PLUGGABLE_UI_BUILD_DIR "${NS_UI_BUILD_DIR}/public/_p/ui") 28 | SET (PLUGGABLE_UI_JSON_NAME "${pluggable_ui_json_name}.json") 29 | 30 | # rewrite the config file for installation 31 | SET (BIN_PREFIX "") 32 | CONFIGURE_FILE ("${PLUGGABLE_UI_JSON_NAME}.in" "${PLUGGABLE_UI_JSON_NAME}") 33 | # read interesting json fields 34 | FILE (READ "${CMAKE_CURRENT_BINARY_DIR}/${PLUGGABLE_UI_JSON_NAME}" PLUGGABLE_UI_JSON) 35 | STRING (JSON SERVICE_NAME GET ${PLUGGABLE_UI_JSON} service) 36 | STRING (JSON RES_API_PREFIX MEMBER ${PLUGGABLE_UI_JSON} rest-api-prefixes 0) 37 | STRING (JSON DOC_ROOT GET ${PLUGGABLE_UI_JSON} doc-root) 38 | STRING (JSON VERSION_DIR GET ${PLUGGABLE_UI_JSON} version-dirs 0 dir) 39 | STRING (JSON MODULE_JS GET ${PLUGGABLE_UI_JSON} module) 40 | FILE (APPEND "${NS_UI_BUILD_DIR}/public/pluggable-uis.js" 41 | "import pluggableUI_${SERVICE_NAME} from \"./_p/ui/${RES_API_PREFIX}/${VERSION_DIR}/${MODULE_JS}\";\nexport {pluggableUI_${SERVICE_NAME}}\n") 42 | 43 | 44 | SET (PLUGGABLE_UI_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${DOC_ROOT}") 45 | SET (PLUGGABLE_UI_BIN "${PLUGGABLE_UI_BUILD_DIR}/${RES_API_PREFIX}") 46 | SET (PLUGGABLE_UI_STAMP "${NS_UI_BUILD_DIR}/${RES_API_PREFIX}") 47 | 48 | FILE (MAKE_DIRECTORY "${PLUGGABLE_UI_BUILD_DIR}") 49 | WATCH_AND_COPY_SOURCES( 50 | ${PLUGGABLE_UI_SRC} 51 | ${PLUGGABLE_UI_BIN} 52 | ${PLUGGABLE_UI_STAMP} 53 | ${RES_API_PREFIX}) 54 | # copy rewritten config file and code to install directory 55 | INSTALL ( 56 | FILES "${PROJECT_BINARY_DIR}/${PLUGGABLE_UI_JSON_NAME}" 57 | DESTINATION "etc/couchbase") 58 | 59 | INSTALL (DIRECTORY "${PLUGGABLE_UI_SRC}/" 60 | DESTINATION "${NS_UI_INSTALL_DIR}/_p/ui/${RES_API_PREFIX}" 61 | REGEX libs-standalone EXCLUDE 62 | PATTERN "*standalone.*" EXCLUDE 63 | PATTERN "*.js" EXCLUDE) 64 | 65 | ENDMACRO(PLUG_IN_UI) 66 | 67 | ENDIF(NOT PLUG_IN_UI_INCLUDED) 68 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbasePrecompiledHeaders.cmake: -------------------------------------------------------------------------------- 1 | # reuse_pch will reuse the precompiled header of the given target for the given target. 2 | # The function can be globally 'disabled' with CB_PCH=OFF 3 | 4 | option(CB_PCH "CB_PCH defines if targets will use pre-compiled headers where configured." ON) 5 | 6 | # Clang-11 (and at least AppleClang 12.0.5) upwards support instantiating 7 | # templates as part of precompiled headers; this can significantly speed up 8 | # (1.3x) building as we only need to instantiate templates from precompiled 9 | # headers once, instead of every time the templates are needed. 10 | # While CMake 3.19 enables this automatically for Clang when supported, it does 11 | # not for AppleClang - see 12 | # https://gitlab.kitware.com/cmake/cmake/-/issues/21133 13 | # Given the boost this gives, manually enable it for AppleClang here if 14 | # compiler supports it. 15 | if (CB_PCH AND APPLE) 16 | check_cxx_compiler_flag(-fpch-instantiate-templates 17 | HAVE_PCH_INSTANTIATE_TEMPLATES) 18 | if (HAVE_PCH_INSTANTIATE_TEMPLATES) 19 | # Note: Technically we only need this to be added to the compilation 20 | # of the precompiled header itself, not all targets, however CMake 21 | # doesn't expose an easy way to set compile arguments for PCH building, 22 | # and (Apple)Clang ignores it if not compiling a header, so just 23 | # add to the global CXX flags variable. 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpch-instantiate-templates") 25 | endif() 26 | endif() 27 | 28 | function(reuse_pch target pch_target) 29 | if (CB_PCH) 30 | target_precompile_headers(${target} REUSE_FROM ${pch_target}) 31 | 32 | # Also need to propogate any include directories from the pch_target, 33 | # so the target picks up include paths for the preprocessed headers. 34 | # This isn't _strictly_ needed for a straight CMake build; but ccache 35 | # wants to preprocess each source file by taking CMake-generated 36 | # compile command and adding '-E' or similar, which requires the actual 37 | # target source files can locate all "raw" precompiled headers 38 | # themselves. 39 | # Note: We don't want to propagate _all_ dependancies (libraries etc), 40 | # just the include paths - if we propogate libraries say using: 41 | # 42 | # target_link_libraries(${target} PRIVATE ${pch_target}) 43 | # 44 | # then we can end up lnking the PCH "library" twice - once via 45 | # target_precompile_headers() above and once via target_link_libraries() 46 | # which results in linker warnings with MSVC. 47 | 48 | # Propagate INTERFACE_INCLUDE_DIRECTORIES properties set directly on 49 | # the PCH target to the target. 50 | get_target_property(include_dirs ${pch_target} INTERFACE_INCLUDE_DIRECTORIES) 51 | set_property(TARGET ${target} APPEND PROPERTY INCLUDE_DIRECTORIES ${include_dirs}) 52 | 53 | # Propagate any INTERFACE_INCLUDE_DIRECTORIES which come via 54 | # LINK_LIBRARIES on the PCH target to the target. 55 | get_target_property(target_type "${pch_target}" TYPE) 56 | if (${target_type} STREQUAL "INTERFACE_LIBRARY") 57 | get_target_property(libs "${pch_target}" INTERFACE_LINK_LIBRARIES) 58 | else() 59 | get_target_property(libs "${pch_target}" LINK_LIBRARIES) 60 | endif() 61 | foreach(lib IN LISTS libs) 62 | if(NOT TARGET "${lib}") 63 | continue() 64 | endif() 65 | 66 | get_target_property(include_dirs ${lib} INTERFACE_INCLUDE_DIRECTORIES) 67 | set_property(TARGET ${target} APPEND PROPERTY INCLUDE_DIRECTORIES ${include_dirs}) 68 | endforeach() 69 | endif() 70 | endfunction() 71 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseRpath.cmake: -------------------------------------------------------------------------------- 1 | SET(CMAKE_SKIP_BUILD_RPATH FALSE) 2 | SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) 3 | 4 | # If the system supports it we want to add in $ORIGIN 5 | IF (UNIX) 6 | IF(APPLE) 7 | SET (ORIGIN @executable_path) 8 | ELSE(APPLE) 9 | SET (ORIGIN \$ORIGIN) 10 | ENDIF(APPLE) 11 | SET(RPATH ${ORIGIN}/../lib) 12 | ENDIF() 13 | 14 | SET(RPATH "${RPATH};${CMAKE_INSTALL_PREFIX}/lib") 15 | IF ("${CMAKE_INSTALL_RPATH}" STREQUAL "") 16 | ELSE() 17 | SET(RPATH "${RPATH};${CMAKE_INSTALL_RPATH}") 18 | ENDIF() 19 | SET(CMAKE_INSTALL_RPATH "${RPATH}") 20 | 21 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 22 | 23 | # Remove any rpath added by the toolchain. This is necessary to remove 24 | # the local '/opt/gcc-10.2.0/lib64' rpath added by our local gcc-10 25 | # binary to allow the binary to locate libstdc++ et al at build 26 | # time. At install time we locate libstdc++ via the above 27 | # origin-relative path. 28 | SET(CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH TRUE) 29 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseSelectCompiler.cmake: -------------------------------------------------------------------------------- 1 | # Select the compiler to use by default, if not specified by user. 2 | # Sets CMAKE_C_COMPILER and CMAKE_CXX_COMPILER - note this file should 3 | # be include()'d before the project() command as CMAKE_C_COMPILER 4 | # cannot be changed after project(). 5 | 6 | # Use gcc from an alternate location if available (and the user didn't 7 | # ask for something else using the standard CMAKE_C/CXX_COMPILER 8 | # variables or CC / CXX env vars). 9 | set (CB_GCC_PATH /opt/gcc-13.2.0 CACHE PATH "Preferred location for GCC, if available") 10 | if(NOT DEFINED CMAKE_C_COMPILER AND 11 | NOT DEFINED CMAKE_CXX_COMPILER AND 12 | NOT DEFINED ENV{CC} AND 13 | NOT DEFINED ENV{CXX}) 14 | if(EXISTS "${CB_GCC_PATH}") 15 | set(CMAKE_C_COMPILER "${CB_GCC_PATH}/bin/gcc" CACHE PATH "Path to C Compiler" FORCE) 16 | set(CMAKE_CXX_COMPILER "${CB_GCC_PATH}/bin/g++" CACHE PATH "Path to C++ Compiler" FORCE) 17 | endif() 18 | endif() 19 | -------------------------------------------------------------------------------- /cmake/Modules/CouchbaseUnityBuild.cmake: -------------------------------------------------------------------------------- 1 | # cb_enable_unity_build will enable unity building for the given TARGET. 2 | # The function can be globally 'disabled' with CB_UNITY_BUILD=OFF 3 | 4 | option(CB_UNITY_BUILD "CB_UNITY_BUILD defines if targets that use cb_enable_unity_build will use a unity build." ON) 5 | 6 | function(cb_enable_unity_build TARGET) 7 | if (CB_UNITY_BUILD) 8 | set_target_properties(${TARGET} PROPERTIES UNITY_BUILD ON) 9 | endif() 10 | endfunction() 11 | -------------------------------------------------------------------------------- /cmake/Modules/ErlangCheckPlt.cmake: -------------------------------------------------------------------------------- 1 | EXECUTE_PROCESS(COMMAND dialyzer --plt ${PLT_FILE} --check_plt 2 | RESULT_VARIABLE result) 3 | IF(NOT "${result}" STREQUAL "0") 4 | MESSAGE(STATUS "dialyzer --check_plt failed. Deleting ${PLT_FILE}") 5 | FILE(REMOVE ${PLT_FILE}) 6 | ENDIF(NOT "${result}" STREQUAL "0") 7 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseBenchmark.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | if (NOT DEFINED benchmark_ROOT AND EXISTS ${CMAKE_BINARY_DIR}/tlm/deps/benchmark.exploded) 17 | set(benchmark_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/benchmark.exploded) 18 | endif() 19 | 20 | find_package(benchmark REQUIRED CONFIG) 21 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseBoost.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate Boost headers. 17 | # This module defines all the variables defined by the standard FindBoost 18 | # module (https://cmake.org/cmake/help/latest/module/FindBoost.html), plus 19 | # the following variables for compability with our original custom logic to 20 | # locate Boost: 21 | # BOOST_INCLUDE_DIR, where to find the boost headers (copy of 22 | # Boost_INCLUDE_DIR - note the case). 23 | 24 | if (NOT DEFINED Boost_FOUND) 25 | include(PlatformIntrospection) 26 | 27 | cb_get_supported_platform(_is_supported_platform) 28 | if (_is_supported_platform) 29 | # Supported platforms should only use the provided hints and pick it up 30 | # from cbdeps 31 | set(Boost_NO_SYSTEM_PATHS ON) 32 | # We don't want to use any system-provided boost package configuration 33 | # files (Boost 1.70.0 upwards) on supported platforms - just our own 34 | # cbdep. 35 | set(Boost_NO_BOOST_CMAKE ON) 36 | endif () 37 | 38 | set(Boost_ADDITIONAL_VERSIONS "1.82") 39 | set(Boost_DETAILED_FAILURE_MSG ON) 40 | set(Boost_USE_STATIC_LIBS ON) 41 | 42 | set(BOOST_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/boost.exploded) 43 | 44 | find_package(Boost 45 | REQUIRED 46 | COMPONENTS container context filesystem program_options regex system thread) 47 | 48 | if(Boost_INCLUDE_DIR) 49 | message(STATUS "Found Boost in ${Boost_INCLUDE_DIR}") 50 | # Backwards compatabilty 51 | set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIR} CACHE STRING 52 | "Boost include directory (copy of Boost_INCLUDE_DIR)") 53 | else() 54 | message(FATAL_ERROR "Boost headers not found") 55 | endif() 56 | endif() 57 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseCurl.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate cURL library 17 | # This module defines 18 | # CURL_FOUND, if false, do not try to link with cURL 19 | # CURL_LIBRARIES, Library path and libs 20 | # CURL_INCLUDE_DIR, where to find the cURL headers 21 | # 22 | if (NOT DEFINED FindCouchbaseCurl_INCLUDED) 23 | include(PlatformIntrospection) 24 | # Use include files directly from cbdeps exploded download 25 | set(_curl_exploded "${CMAKE_BINARY_DIR}/tlm/deps/curl.exploded") 26 | 27 | cb_get_supported_platform(_is_supported_platform) 28 | if (_is_supported_platform) 29 | if (EXISTS ${_curl_exploded} AND IS_DIRECTORY ${_curl_exploded}) 30 | # Supported platforms should only use the provided hints and 31 | # pick it up from cbdeps (but we don't bundle this for all 32 | # platforms) 33 | set(_curl_no_default_path NO_DEFAULT_PATH) 34 | endif () 35 | endif () 36 | 37 | find_path(CURL_INCLUDE_DIR curl/curl.h 38 | HINTS ${_curl_exploded}/include 39 | ${_curl_no_default_path}) 40 | 41 | if (NOT CURL_INCLUDE_DIR) 42 | message(FATAL_ERROR "Failed to locate curl/curl.h") 43 | endif () 44 | 45 | find_library(CURL_LIBRARIES 46 | NAMES curl libcurl libcurl_imp 47 | HINTS ${CMAKE_INSTALL_PREFIX}/lib 48 | ${_curl_no_default_path}) 49 | 50 | if (NOT CURL_LIBRARIES) 51 | message(FATAL_ERROR "Failed to locate curl, libcurl or libcurl_imp") 52 | endif () 53 | 54 | message(STATUS "Found cURL headers in: ${CURL_INCLUDE_DIR}") 55 | message(STATUS " libraries: ${CURL_LIBRARIES}") 56 | set(CURL_FOUND true CACHE BOOL "Found cURL" FORCE) 57 | mark_as_advanced(CURL_FOUND CURL_INCLUDE_DIR CURL_LIBRARIES) 58 | 59 | # Pretend we're using Modern CMake to find this thing. 60 | add_library(Curl::libcurl SHARED IMPORTED) 61 | set_target_properties(Curl::libcurl 62 | PROPERTIES 63 | IMPORTED_LOCATION ${CURL_LIBRARIES}) 64 | target_include_directories(Curl::libcurl INTERFACE 65 | ${CURL_INCLUDE_DIR}) 66 | 67 | set(FindCouchbaseCurl_INCLUDED 1) 68 | 69 | endif (NOT DEFINED FindCouchbaseCurl_INCLUDED) 70 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseDoubleConversion.cmake: -------------------------------------------------------------------------------- 1 | # Locate Google's double-conversion library (required by Folly). 2 | # This module defines 3 | # DOUBLE_CONVERSION_FOUND, if false, do not try to use double-conversion 4 | # DOUBLE_CONVERSION_LIBRARIES, Library path and libs 5 | # DOUBLE_CONVERSION_INCLUDE_DIR, where to find the headers 6 | if (NOT DEFINED DOUBLE_CONVERSION_FOUND) 7 | include(PlatformIntrospection) 8 | 9 | cb_get_supported_platform(_is_supported_platform) 10 | if (_is_supported_platform) 11 | # Supported platforms should only use the provided hints and pick it up 12 | # from cbdeps 13 | set(_double_conversion_no_default_path NO_DEFAULT_PATH) 14 | endif () 15 | 16 | set(_double_conversion_exploded ${CMAKE_BINARY_DIR}/tlm/deps/double-conversion.exploded) 17 | 18 | find_path(DOUBLE_CONVERSION_INCLUDE_DIR double-conversion/double-conversion.h 19 | PATH_SUFFIXES include 20 | PATHS ${_double_conversion_exploded} 21 | ${_double_conversion_no_default_path}) 22 | 23 | find_library(DOUBLE_CONVERSION_LIBRARIES 24 | NAMES double-conversion 25 | HINTS ${_double_conversion_exploded}/lib 26 | ${_double_conversion_no_default_path}) 27 | 28 | if(DOUBLE_CONVERSION_INCLUDE_DIR AND DOUBLE_CONVERSION_LIBRARIES) 29 | MESSAGE(STATUS "Found double-conversion headers: ${DOUBLE_CONVERSION_INCLUDE_DIR}") 30 | MESSAGE(STATUS " libraries: ${DOUBLE_CONVERSION_LIBRARIES}") 31 | set(DOUBLE_CONVERSION_FOUND true CACHE BOOL "Found double-conversion" FORCE) 32 | else() 33 | set(DOUBLE_CONVERSION_FOUND false CACHE BOOL "Found double-conversion" FORCE) 34 | endif() 35 | 36 | mark_as_advanced(DOUBLE_CONVERSION_FOUND DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARIES) 37 | endif() 38 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseFaiss.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2024-present Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate the Faiss library. This module utilizes the Faiss cbdeps 17 | # package's CMake config, and so it defines "Modern CMake" imported 18 | # targets named eg. "faiss" and "faiss_c". As such, there is no need for 19 | # things like FAISS_LIBRARIES etc. 20 | # 21 | # We set the flag CB_USE_FAISS, which will be OFF on for non-Enterprise 22 | # builds. 23 | 24 | SET (_use_faiss OFF) 25 | IF (NOT BUILD_ENTERPRISE) 26 | # No Faiss for CE builds 27 | 28 | ELSEIF (BUILD_ONLY_TOOLS) 29 | # No Faiss for tools-only builds 30 | 31 | ELSE () 32 | SET (_use_faiss ON) 33 | FIND_PACKAGE (faiss CONFIG REQUIRED) 34 | MESSAGE (STATUS "Found faiss") 35 | 36 | # Add faiss's transitive dependencies to the install set 37 | IF (TARGET faiss_avx2) 38 | SET (_faisslib faiss_avx2) 39 | ELSEIF (TARGET faiss) 40 | SET (_faisslib faiss) 41 | ELSE () 42 | MESSAGE (FATAL_ERROR "faiss package doesn't declare `faiss` or `faiss_avx2` target!") 43 | ENDIF () 44 | INSTALL (IMPORTED_RUNTIME_ARTIFACTS faiss_c ${_faisslib}) 45 | 46 | # On Mac and Windows, our Faiss package also includes the OpenMP runtime. 47 | # I couldn't find a useful way for Faiss's CMake config to include this, 48 | # so just manually install it here. 49 | IF (WIN32) 50 | INSTALL (FILES "${faiss_ROOT}/bin/libomp140.x86_64.dll" DESTINATION bin) 51 | ELSEIF (APPLE) 52 | INSTALL (FILES "${faiss_ROOT}/lib/libomp.dylib" DESTINATION lib) 53 | ENDIF () 54 | ENDIF () 55 | 56 | SET (CB_USE_FAISS ${_use_faiss} CACHE BOOL "Whether Faiss is available in the build" FORCE) 57 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseFlatbuffers.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate Google flatbuffers 17 | # This module defines 18 | # FLATBUFFERS_INCLUDE_DIR, where to find the flatbuffer headers 19 | # FLATC, the flatc binary 20 | include(PlatformIntrospection) 21 | 22 | cb_get_supported_platform(_is_supported_platform) 23 | if (_is_supported_platform) 24 | # Supported platforms should only use the provided hints and pick it up 25 | # from cbdeps 26 | set(_flatbuffers_no_default_path NO_DEFAULT_PATH) 27 | endif () 28 | 29 | set(google_flatbuffers_exploded ${CMAKE_BINARY_DIR}/tlm/deps/flatbuffers.exploded) 30 | 31 | find_path(FLATBUFFERS_INCLUDE_DIR flatbuffers/flatbuffers.h 32 | HINTS ${google_flatbuffers_exploded}/include 33 | ${_flatbuffers_no_default_path}) 34 | if (NOT FLATBUFFERS_INCLUDE_DIR) 35 | message(FATAL_ERROR "Failed to locate flatbuffers/flatbuffers.h") 36 | endif () 37 | 38 | find_program(FLATC flatc HINTS ${google_flatbuffers_exploded}/bin ${_flatbuffers_no_default_path}) 39 | if (NOT FLATC) 40 | message(FATAL_ERROR "Failed to locate flatc") 41 | endif () 42 | 43 | find_library(FLATBUFFERS_LIBRARY_RELEASE 44 | NAMES flatbuffers 45 | PATHS ${google_flatbuffers_exploded}/lib/) 46 | 47 | find_library(FLATBUFFERS_LIBRARY_DEBUG 48 | NAMES flatbuffersd 49 | PATHS ${google_flatbuffers_exploded}/lib/) 50 | 51 | # Defines FLATBUFFERS_LIBRARY / LIBRARIES to the correct Debug / Release 52 | # lib based on the current BUILD_TYPE 53 | select_library_configurations(FLATBUFFERS) 54 | 55 | if (NOT FLATBUFFERS_LIBRARIES) 56 | message(FATAL_ERROR "Failed to locate flatbuffers library") 57 | endif () 58 | 59 | message(STATUS "Found Google Flatbuffers headers in: ${FLATBUFFERS_INCLUDE_DIR}") 60 | message(STATUS " library: ${FLATBUFFERS_LIBRARIES}") 61 | message(STATUS " compiler: ${FLATC}") 62 | 63 | mark_as_advanced(FLATBUFFERS_INCLUDE_DIR FLATC FLATBUFFERS_LIBRARIES) 64 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseFmt.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate fmt library from cbdeps. 17 | set(fmt_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/fmt.exploded) 18 | 19 | find_package(fmt REQUIRED) 20 | if(fmt_FOUND) 21 | message(STATUS "Found fmt at: ${fmt_DIR}") 22 | endif() 23 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseGflags.cmake: -------------------------------------------------------------------------------- 1 | set(gflags_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/gflags.exploded) 2 | 3 | find_package(gflags REQUIRED) 4 | if(gflags_FOUND) 5 | message(STATUS "Found gflags at: ${gflags_DIR}") 6 | endif() 7 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseGlog.cmake: -------------------------------------------------------------------------------- 1 | # Locate Google Glog library 2 | # This module defines 3 | # GLOG_LIBRARIES, Library path and libs 4 | # GLOG_INCLUDE_DIR, where to find the headers 5 | 6 | include(FindPackageHandleStandardArgs) 7 | include(PlatformIntrospection) 8 | include(SelectLibraryConfigurations) 9 | 10 | set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) 11 | 12 | cb_get_supported_platform(_is_supported_platform) 13 | if (_is_supported_platform) 14 | # Supported platforms should only use the provided hints and pick it up 15 | # from cbdeps 16 | set(_glog_no_default_path NO_DEFAULT_PATH) 17 | endif () 18 | 19 | set(_glog_exploded ${CMAKE_BINARY_DIR}/tlm/deps/glog.exploded) 20 | 21 | find_path(GLOG_INCLUDE_DIR glog/logging.h 22 | PATH_SUFFIXES include 23 | PATHS ${_glog_exploded} 24 | ${_glog_no_default_path}) 25 | 26 | find_library(GLOG_LIBRARY_RELEASE 27 | NAMES glog 28 | HINTS ${_glog_exploded}/lib 29 | ${_glog_no_default_path}) 30 | 31 | find_library(GLOG_LIBRARY_DEBUG 32 | NAMES glogd 33 | HINTS ${_glog_exploded}/lib 34 | ${_glog_no_default_path}) 35 | 36 | # Defines GLOG_LIBRARY / LIBRARIES to the correct Debug / Release 37 | # lib based on the current BUILD_TYPE 38 | select_library_configurations(GLOG) 39 | 40 | find_package_handle_standard_args(GLOG 41 | REQUIRED_VARS GLOG_LIBRARIES GLOG_INCLUDE_DIR) 42 | 43 | # Set GOOGLE_GLOG_DLL_DECL to an empty value to avoid incorrect dllimport 44 | # decoration (we build static versions of GLOG which should have an empty 45 | # DLL declaration). 46 | add_compile_definitions(GOOGLE_GLOG_DLL_DECL=) 47 | 48 | # Set GLOG_NO_ABBREVIATED_SEVERITIES to disable the abbreviated severity macros 49 | # ERROR, WARNING, etc - which on Windows can collide with macros defined by 50 | # windgi.h (which is included via Windows.h). 51 | add_compile_definitions(GLOG_NO_ABBREVIATED_SEVERITIES) 52 | 53 | mark_as_advanced(GLOG_INCLUDE_DIR GLOG_LIBRARIES) 54 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseGoogletest.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | if (NOT DEFINED GTest_ROOT AND EXISTS ${CMAKE_BINARY_DIR}/tlm/deps/googletest.exploded) 17 | set(GTest_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/googletest.exploded) 18 | endif() 19 | 20 | find_package(GTest REQUIRED CONFIG) 21 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseGrpc.cmake: -------------------------------------------------------------------------------- 1 | # Locate the gRPC library 2 | # This module defines 3 | # GRPC_FOUND 4 | # GRPC_LIBRARIES, library path and libs 5 | # GRPC_INCLUDE_DIR, where to find the headers 6 | # PROTOC, protoc compiler 7 | # GRPC_CPP_PLUGIN_EXE, plugin for generating C++ gRPC client and server 8 | # PROTOC_GEN_GO_EXE, plugin for generating Go gRPC client and server 9 | 10 | if (NOT DEFINED GRPC_FOUND) 11 | include (PlatformIntrospection) 12 | cb_get_supported_platform (_is_supported_platform) 13 | 14 | if (_is_supported_platform) 15 | set (_grpc_no_default_path NO_DEFAULT_PATH) 16 | endif () 17 | 18 | set (_grpc_exploded ${CMAKE_BINARY_DIR}/tlm/deps/grpc.exploded) 19 | set (_protoc_gen_go_exploded ${CMAKE_BINARY_DIR}/tlm/deps/protoc-gen-go.exploded) 20 | 21 | find_path (GRPC_INCLUDE_DIR grpc 22 | HINTS ${_grpc_exploded}/include 23 | ${_grpc_no_default_path}) 24 | if (NOT GRPC_INCLUDE_DIR) 25 | message (FATAL_ERROR "Failed to locate gRPC headers") 26 | endif () 27 | 28 | find_program(PROTOC protoc 29 | HINTS ${_grpc_exploded}/bin) 30 | if (NOT PROTOC) 31 | message(FATAL_ERROR "Failed to locate protoc") 32 | endif () 33 | 34 | find_program(GRPC_CPP_PLUGIN_EXE grpc_cpp_plugin 35 | HINTS ${_grpc_exploded}/bin) 36 | if (NOT GRPC_CPP_PLUGIN_EXE) 37 | message(FATAL_ERROR "Failed to locate grpc_cpp_plugin") 38 | endif () 39 | 40 | find_program (PROTOC_GEN_GO_EXE protoc-gen-go 41 | HINTS ${_protoc_gen_go_exploded}/bin) 42 | if (NOT PROTOC_GEN_GO_EXE) 43 | message(FATAL_ERROR "Failed to locate protoc-gen-go") 44 | endif () 45 | 46 | find_package (ZLIB REQUIRED) 47 | 48 | if (NOT GRPC_LIBRARIES) 49 | set (_grpc_libraries 50 | grpc++ 51 | grpc++_error_details 52 | grpc++_reflection 53 | grpc++_unsecure 54 | grpc_unsecure 55 | grpc 56 | address_sorting 57 | gpr 58 | cares 59 | absl_strings 60 | absl_str_format_internal 61 | absl_strings_internal 62 | absl_raw_logging_internal 63 | absl_throw_delegate 64 | absl_int128 65 | absl_log_severity 66 | absl_bad_optional_access 67 | absl_spinlock_wait 68 | absl_base 69 | upb 70 | ) 71 | # Additional static libs copied in from the GRPC package build 72 | # (some have different names on Unix and Windows) 73 | if (WIN32) 74 | list (APPEND _grpc_libraries 75 | libprotobuf) 76 | else () 77 | list (APPEND _grpc_libraries 78 | protobuf) 79 | endif () 80 | foreach (_mylib ${_grpc_libraries}) 81 | unset (_the_lib CACHE) 82 | find_library (_the_lib 83 | NAMES ${_mylib} 84 | HINTS ${_grpc_exploded}/lib 85 | ${_grpc_no_default_path}) 86 | if (_the_lib) 87 | list (APPEND _grpc_libs_found ${_the_lib}) 88 | else (_the_lib) 89 | message (FATAL_ERROR "Can't build Couchbase without ${_mylib}") 90 | endif (_the_lib) 91 | endforeach (_mylib) 92 | set (GRPC_LIBRARIES ${_grpc_libs_found} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} 93 | CACHE STRING "gRPC Libraries" FORCE) 94 | endif (NOT GRPC_LIBRARIES) 95 | 96 | if (GRPC_LIBRARIES) 97 | message (STATUS "Found gRPC headers in: ${GRPC_INCLUDE_DIR}") 98 | message (STATUS " libraries: ${GRPC_LIBRARIES}") 99 | else (GRPC_LIBRARIES) 100 | message (FATAL_ERROR "Can't build Couchbase without gRPC") 101 | endif (GRPC_LIBRARIES) 102 | 103 | set (GRPC_FOUND true CACHE BOOL "Found gRPC" FORCE) 104 | mark_as_advanced (GRPC_FOUND GRPC_INCLUDE_DIR GRPC_LIBRARIES PROTOC GRPC_CPP_PLUGIN_EXE PROTOC_GEN_GO_EXE) 105 | endif (NOT DEFINED GRPC_FOUND) -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseIcu.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate icu4c library 17 | # This module defines 18 | # ICU_FOUND, if false, do not try to link with ICU 19 | # ICU_LIBRARIES, Library path and libs 20 | # ICU_INCLUDE_DIR, where to find the ICU headers 21 | 22 | if (NOT DEFINED ICU_FOUND) 23 | # CBD-2634: We use ICU from V8 build as most uses of ICU is with V8 24 | if (NOT DEFINED V8_FOUND) 25 | include(FindCouchbaseV8) 26 | endif () 27 | 28 | find_path(ICU_INCLUDE_DIR unicode/utypes.h 29 | HINTS ${V8_INCLUDE_DIR} 30 | NO_CMAKE_PATH 31 | NO_CMAKE_ENVIRONMENT_PATH 32 | NO_DEFAULT_PATH) 33 | 34 | if (NOT ICU_INCLUDE_DIR) 35 | message(FATAL_ERROR "Failed to locate unicode/utypes.h (ICU)") 36 | endif () 37 | 38 | if (WIN32) 39 | if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") 40 | set(_build_type "Release") 41 | else () 42 | set(_build_type ${CMAKE_BUILD_TYPE}) 43 | ENDIF() 44 | 45 | if (NOT ICU_LIBRARIES) 46 | set(_icu_libraries "icuuc.dll;third_party_icu_icui18n.dll") 47 | foreach (_mylib ${_icu_libraries}) 48 | unset(_the_lib CACHE) 49 | find_library(_the_lib 50 | NAMES ${_mylib} 51 | HINTS ${_v8_exploded}/lib/${_build_type} 52 | NO_DEFAULT_PATH) 53 | if (_the_lib) 54 | list(APPEND _icu_libs_found ${_the_lib}) 55 | endif (_the_lib) 56 | endforeach (_mylib) 57 | set(ICU_LIBRARIES ${_icu_libs_found} CACHE STRING "V8 Libraries" FORCE) 58 | endif (NOT ICU_LIBRARIES) 59 | else (WIN32) 60 | if (NOT ICU_LIBRARIES) 61 | set(_icu_libraries "icuuc;third_party_icu_icui18n") 62 | foreach (_mylib ${_icu_libraries}) 63 | unset(_the_lib CACHE) 64 | find_library(_the_lib 65 | NAMES ${_mylib} 66 | HINTS ${CMAKE_INSTALL_PREFIX}/lib 67 | NO_DEFAULT_PATH) 68 | if (_the_lib) 69 | list(APPEND _icu_libs_found ${_the_lib}) 70 | endif (_the_lib) 71 | endforeach (_mylib) 72 | set(ICU_LIBRARIES ${_icu_libs_found} CACHE STRING "V8 Libraries" FORCE) 73 | endif (NOT ICU_LIBRARIES) 74 | endif (WIN32) 75 | 76 | if (NOT ICU_LIBRARIES) 77 | message(FATAL_ERROR "Failed to locate any of the ICU libraries") 78 | endif () 79 | 80 | message(STATUS "Found ICU headers in: ${ICU_INCLUDE_DIR}") 81 | message(STATUS " libraries: ${ICU_LIBRARIES}") 82 | 83 | set(ICU_FOUND true CACHE BOOL "Found ICU" FORCE) 84 | MARK_AS_ADVANCED(ICU_FOUND ICU_INCLUDE_DIR ICU_LIBRARIES) 85 | endif (NOT DEFINED ICU_FOUND) 86 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseJemalloc.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate jemalloc library 17 | # This module defines 18 | # JEMALLOC_FOUND and JEMALLOC_NOPREFIX_FOUND 19 | # JEMALLOC_LIBRARIES, path to selected (Debug / Release) library variant 20 | # JEMALLOC_INCLUDE_DIR, where to find the jemalloc headers (may be a list!) 21 | # 22 | # It also defines well-formed "Modern CMake" imported targets 23 | # Jemalloc::jemalloc and Jemalloc::noprefix. 24 | 25 | if (NOT FindCouchbaseJemalloc_INCLUDED) 26 | 27 | include(CheckFunctionExists) 28 | include(CMakePushCheckState) 29 | include(CheckSymbolExists) 30 | 31 | set(Jemalloc_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/jemalloc.exploded) 32 | find_package(Jemalloc REQUIRED) 33 | 34 | # "Translate" variables to the old-school all-upper-case form we use. 35 | set(JEMALLOC_FOUND 1) 36 | set(JEMALLOC_INCLUDE_DIR ${Jemalloc_INCLUDE_DIRS}) 37 | set(JEMALLOC_LIBRARIES ${Jemalloc_LIBRARIES}) 38 | 39 | # plasma and nitro also use this - they probably shouldn't 40 | set(JEMALLOC_LIBRARY_RELEASE ${Jemalloc_LIBRARY_RELEASE}) 41 | 42 | mark_as_advanced(JEMALLOC_INCLUDE_DIR) 43 | 44 | message(STATUS "Found jemalloc headers: ${JEMALLOC_INCLUDE_DIR}") 45 | message(STATUS " libraries: ${JEMALLOC_LIBRARIES}") 46 | 47 | # Check that the found jemalloc library has it's symbols prefixed with 'je_' 48 | cmake_push_check_state(RESET) 49 | set(CMAKE_REQUIRED_LIBRARIES ${JEMALLOC_LIBRARIES}) 50 | set(CMAKE_REQUIRED_INCLUDES ${JEMALLOC_INCLUDE_DIR}) 51 | check_symbol_exists(je_malloc "stdbool.h;jemalloc/jemalloc.h" HAVE_JE_SYMBOLS) 52 | check_symbol_exists(je_sdallocx "stdbool.h;jemalloc/jemalloc.h" HAVE_JEMALLOC_SDALLOCX) 53 | cmake_pop_check_state() 54 | 55 | if (NOT HAVE_JE_SYMBOLS) 56 | message(FATAL_ERROR "Found jemalloc in ${JEMALLOC_INCLUDE_DIR}, but was built without 'je_' prefix on symbols so cannot be used.") 57 | endif () 58 | 59 | set (Jemalloc_noprefix_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/jemalloc_noprefix.exploded) 60 | find_package(Jemalloc_noprefix REQUIRED) 61 | set(JEMALLOC_NOPREFIX_FOUND 1) 62 | get_target_property(_noprefix_inc Jemalloc::noprefix INTERFACE_INCLUDE_DIRECTORIES) 63 | message(STATUS " noprefix headers: ${_noprefix_inc}") 64 | 65 | set (FindCouchbaseJemalloc_INCLUDED 1) 66 | endif (NOT FindCouchbaseJemalloc_INCLUDED) 67 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseLZ4.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate lz4 library 17 | # This module defines 18 | # LZ4_FOUND, if false, do not try to link with lz4 19 | 20 | # We want to only find our cbdeps package 21 | SET (lz4_ROOT "${CMAKE_BINARY_DIR}/tlm/deps/lz4.exploded") 22 | FIND_PACKAGE (lz4 CONFIG 23 | NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_INSTALL_PREFIX) 24 | if (TARGET LZ4::lz4_shared) 25 | set(LZ4_FOUND True CACHE BOOL "Whether LZ4 has been found" FORCE) 26 | get_target_property(_lz4_location LZ4::lz4_shared LOCATION) 27 | # Annoyingly, the exported targets for LZ4 don't have INCLUDE_DIRECTORIES 28 | # even though it looks like they should, so force it in 29 | set_target_properties(LZ4::lz4_shared PROPERTIES 30 | INTERFACE_INCLUDE_DIRECTORIES "${lz4_ROOT}/include") 31 | message(STATUS "Found LZ4: ${_lz4_location}") 32 | message(STATUS " : ${lz4_ROOT}/include") 33 | else () 34 | message(WARNING "LZ4 not found") 35 | set(LZ4_FOUND False CACHE BOOL "Whether LZ4 has been found" FORCE) 36 | endif () 37 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseLibsodium.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2022 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate libsodium library 17 | # This module defines 18 | # LIBSODIUM_FOUND, if libsodium was found 19 | # LIBSODIUM_LIBRARIES, Library path and libs 20 | # LIBSODIUM_INCLUDE_DIR, where to find the libsodium headers 21 | if (NOT DEFINED LIBSODIUM_FOUND) 22 | include(PlatformIntrospection) 23 | 24 | cb_get_supported_platform(_is_supported_platform) 25 | if (_is_supported_platform) 26 | # Supported platforms should only use the provided hints and pick it up 27 | # from cbdeps 28 | set(_libsodium_no_default_path NO_DEFAULT_PATH) 29 | endif () 30 | 31 | set(_libsodium_exploded ${CMAKE_BINARY_DIR}/tlm/deps/libsodium.exploded) 32 | find_path(LIBSODIUM_INCLUDE_DIR sodium.h 33 | HINTS ${_libsodium_exploded}/include 34 | ${_libsodium_no_default_path}) 35 | 36 | if (NOT LIBSODIUM_INCLUDE_DIR) 37 | message(FATAL_ERROR "Failed to locate sodium.h") 38 | endif () 39 | 40 | find_library(LIBSODIUM_LIBRARIES 41 | NAMES sodium libsodium 42 | HINTS ${CMAKE_INSTALL_PREFIX}/lib 43 | ${_libsodium_no_default_path}) 44 | if (NOT LIBSODIUM_LIBRARIES) 45 | message(FATAL_ERROR "Failed to locate libsodium") 46 | endif () 47 | 48 | message(STATUS "Found libsodium headers in: ${LIBSODIUM_INCLUDE_DIR}") 49 | message(STATUS " libraries: ${LIBSODIUM_LIBRARIES}") 50 | 51 | set(LIBSODIUM_FOUND true CACHE BOOL "Found libsodium" FORCE) 52 | mark_as_advanced(LIBSODIUM_FOUND LIBSODIUM_INCLUDE_DIR LIBSODIUM_LIBRARIES) 53 | endif (NOT DEFINED LIBSODIUM_FOUND) 54 | 55 | if (NOT TARGET libsodium::libsodium) 56 | add_library(libsodium::libsodium STATIC IMPORTED) 57 | set_target_properties(libsodium::libsodium 58 | PROPERTIES 59 | IMPORTED_LOCATION ${LIBSODIUM_LIBRARIES}) 60 | target_include_directories(libsodium::libsodium 61 | INTERFACE ${LIBSODIUM_INCLUDE_DIR}) 62 | endif () 63 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseLiburing.cmake: -------------------------------------------------------------------------------- 1 | # Locate liburing 2 | # This module defines 3 | # LIBURING_LIBRARIES, Library path and libs 4 | # LIBURING_INCLUDE_DIR, where to find the headers 5 | # LIBURING_FOUND, whether it was found or not 6 | if (NOT DEFINED LIBURING_FOUND) 7 | include(PlatformIntrospection) 8 | 9 | cb_get_supported_platform(_is_supported_platform) 10 | if (_is_supported_platform) 11 | set(_liburing_no_default_path NO_DEFAULT_PATH) 12 | endif () 13 | 14 | set(_liburing_include_dir ${CMAKE_BINARY_DIR}/tlm/deps/liburing.exploded/include) 15 | set(_liburing_library_dir ${CMAKE_INSTALL_PREFIX}/lib) 16 | 17 | find_path(LIBURING_INCLUDE_DIR liburing.h 18 | HINTS ${_liburing_include_dir} 19 | ${_liburing_no_default_path}) 20 | 21 | find_library(LIBURING_LIBRARIES 22 | NAMES uring 23 | HINTS ${_liburing_library_dir} 24 | ${_liburing_no_default_path}) 25 | 26 | if (LIBURING_INCLUDE_DIR AND LIBURING_LIBRARIES) 27 | message(STATUS "Found liburing headers in: ${LIBURING_INCLUDE_DIR}") 28 | message(STATUS "Found liburing library : ${LIBURING_LIBRARIES}") 29 | set(LIBURING_FOUND true CACHE BOOL "Found liburing" FORCE) 30 | else () 31 | message(STATUS "Did not find liburing") 32 | set(liburing_FOUND false CACHE BOOL "Found liburing" FORCE) 33 | endif () 34 | endif (NOT DEFINED LIBURING_FOUND) 35 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseLibuv.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate libuv library 17 | # This module defines 18 | # LIBUV_FOUND, if libuv was found 19 | # LIBUV_LIBRARIES, Library path and libs 20 | # LIBUV_INCLUDE_DIR, where to find the libuv headers 21 | if (NOT DEFINED LIBUV_FOUND) 22 | include(PlatformIntrospection) 23 | 24 | cb_get_supported_platform(_is_supported_platform) 25 | if (_is_supported_platform) 26 | # Supported platforms should only use the provided hints and pick it up 27 | # from cbdeps 28 | set(_libuv_no_default_path NO_DEFAULT_PATH) 29 | endif () 30 | 31 | set(_libuv_exploded ${CMAKE_BINARY_DIR}/tlm/deps/libuv.exploded) 32 | find_path(LIBUV_INCLUDE_DIR uv.h 33 | HINTS ${_libuv_exploded}/include 34 | ${_libuv_no_default_path}) 35 | 36 | if (NOT LIBUV_INCLUDE_DIR) 37 | message(FATAL_ERROR "Failed to locate uv.h") 38 | endif () 39 | 40 | find_library(LIBUV_LIBRARIES 41 | NAMES uv libuv 42 | HINTS ${CMAKE_INSTALL_PREFIX}/lib 43 | ${_libuv_no_default_path}) 44 | if (NOT LIBUV_LIBRARIES) 45 | message(FATAL_ERROR "Failed to locate libuv") 46 | endif () 47 | 48 | message(STATUS "Found libuv headers in: ${LIBUV_INCLUDE_DIR}") 49 | message(STATUS " libraries: ${LIBUV_LIBRARIES}") 50 | 51 | set(LIBUV_FOUND true CACHE BOOL "Found libuv" FORCE) 52 | mark_as_advanced(LIBUV_FOUND LIBUV_INCLUDE_DIR LIBUV_LIBRARIES) 53 | endif (NOT DEFINED LIBUV_FOUND) 54 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseLua.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Couchbase, Inc. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Locate lua library 16 | # This module defines 17 | # LUA_FOUND, if false, do not try to link with lua 18 | # LUA_LIBRARIES, Library path and libs 19 | # LUA_INCLUDE_DIR, where to find the ICU headers 20 | 21 | if (NOT DEFINED LUA_FOUND) 22 | find_path(LUA_INCLUDE_DIR lua.h 23 | HINTS 24 | ENV LUA_DIR 25 | PATH_SUFFIXES lua5.2 26 | lua-5.2 27 | lua5.1 28 | lua-5.1 29 | PATHS 30 | ~/Library/Frameworks 31 | /Library/Frameworks 32 | /opt/local 33 | /opt/csw 34 | /opt/lua 35 | /opt) 36 | 37 | find_library(LUA_LIBRARIES 38 | NAMES lua5.2 lua5.1 lua 39 | HINTS 40 | ENV LUA_DIR 41 | PATHS 42 | ~/Library/Frameworks 43 | /Library/Frameworks 44 | /opt/local 45 | /opt/csw 46 | /opt/lua 47 | /opt) 48 | 49 | if (LUA_LIBRARIES AND LUA_INCLUDE_DIR) 50 | set(LUA_FOUND true CACHE BOOL "Found LUA" FORCE) 51 | message(STATUS "Found lua headers in: ${LUA_INCLUDE_DIR}") 52 | message(STATUS " libraries: ${LUA_LIBRARIES}") 53 | else (LUA_LIBRARIES AND LUA_INCLUDE_DIR) 54 | set(LUA_FOUND false CACHE BOOL "LUA not available" FORCE) 55 | endif (LUA_LIBRARIES AND LUA_INCLUDE_DIR) 56 | 57 | mark_as_advanced(LUA_FOUND LUA_INCLUDE_DIR LUA_LIBRARIES) 58 | endif (NOT DEFINED LUA_FOUND) 59 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseNlohmannJson.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | if (NOT DEFINED nlohmann_json_ROOT AND EXISTS ${CMAKE_BINARY_DIR}/tlm/deps/json.exploded) 17 | set(nlohmann_json_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/json.exploded) 18 | endif() 19 | find_package(nlohmann_json REQUIRED CONFIG) 20 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseNuma.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2020 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | 17 | # Try to locate libnuma and set NUMA_FOUND to true or false depending on 18 | # the availability. 19 | # 20 | # If found: 21 | # A new compile flag is set: -D HAVE_LIBNUMA=1 22 | # CMake variables for include NUMA_INCLUDE_DIR and library NUMA_LIBRARIES 23 | # is set with the appropriate values 24 | if (NOT DEFINED NUMA_FOUND) 25 | include(PlatformIntrospection) 26 | 27 | cb_get_supported_platform(_is_supported_platform) 28 | if (_is_supported_platform) 29 | # Supported platforms should only use the provided hints and pick it up 30 | # from cbdeps 31 | set(_numa_no_default_path NO_DEFAULT_PATH) 32 | endif () 33 | 34 | set(_numa_exploded ${CMAKE_BINARY_DIR}/tlm/deps/numactl.exploded) 35 | 36 | find_path(NUMA_INCLUDE_DIR numa.h 37 | HINTS ${_numa_exploded}/include 38 | ${_numa_no_default_path}) 39 | find_library(NUMA_LIBRARIES 40 | NAMES numa 41 | PATHS ${CMAKE_INSTALL_PREFIX}/lib/ 42 | ${_numa_no_default_path}) 43 | 44 | if (NUMA_INCLUDE_DIR AND NUMA_LIBRARIES) 45 | cmake_push_check_state(RESET) 46 | set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${NUMA_INCLUDE_DIR}) 47 | set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${NUMA_LIBRARIES}) 48 | check_c_source_compiles(" 49 | #include 50 | int main() { 51 | numa_available(); 52 | }" HAVE_LIBNUMA) 53 | cmake_pop_check_state() 54 | 55 | if (HAVE_LIBNUMA) 56 | add_definitions(-DHAVE_LIBNUMA=1) 57 | message(STATUS "Found numa headers in: ${NUMA_INCLUDE_DIR}") 58 | message(STATUS " library: ${NUMA_LIBRARIES}") 59 | set(NUMA_FOUND true CACHE BOOL "Found numa" FORCE) 60 | else () 61 | # we failed to build the program with numa 62 | set(NUMA_FOUND false CACHE BOOL "Found numa" FORCE) 63 | endif () 64 | else () 65 | # we don't have the header and library 66 | set(NUMA_FOUND false CACHE BOOL "Found numa" FORCE) 67 | endif () 68 | 69 | if (_supported_platform AND NOT WIN32 AND NOT APPLE AND NOT NUMA_FOUND) 70 | # verify that we have libnuma available in our supported builds 71 | # (should pick it up from cbdeps) 72 | # If only cmake could have defined LINUX ;) 73 | message(FATAL_ERROR "Can't build Couchbase server without libnuma") 74 | endif() 75 | 76 | mark_as_advanced(NUMA_FOUND NUMA_INCLUDE_DIR NUMA_LIBRARIES) 77 | endif() 78 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseOpenSSL.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate OpenSSL library 17 | # 18 | # This module defines the same outputs as CMake's FindOpenSSL.cmake 19 | # (https://cmake.org/cmake/help/latest/module/FindOpenSSL.html), primarily: 20 | # 21 | # The import targets: 22 | # 23 | # OpenSSL::SSL - The OpenSSL ssl library, if found. 24 | # OpenSSL::Crypto - The OpenSSL crypto library, if found. 25 | # 26 | # The variables: 27 | # 28 | # OPENSSL_FOUND, Set when OpenSSL is detected 29 | # OPENSSL_LIBRARIES, All OpenSSL libraries and their dependancies. 30 | # OPENSSL_INCLUDE_DIR, where to find the OpenSSL headers 31 | 32 | include(PlatformIntrospection) 33 | cb_get_supported_platform(_is_supported_platform) 34 | if (_is_supported_platform) 35 | # Supported platforms should only use the provided hints and pick it up 36 | # from cbdeps 37 | set(OPENSSL_ROOT_DIR ${CMAKE_BINARY_DIR}/tlm/deps/openssl.exploded) 38 | 39 | set(original_CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ${CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH}) 40 | set(original_CMAKE_FIND_USE_CMAKE_SYSTEM_PATH ${CMAKE_FIND_USE_CMAKE_SYSTEM_PATH}) 41 | 42 | set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) 43 | set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE) 44 | endif () 45 | 46 | find_package(OpenSSL REQUIRED COMPONENTS Crypto SSL) 47 | 48 | if (_is_supported_platform) 49 | set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH ${original_CMAKE_FIND_USE_CMAKE_SYSTEM_PATH}) 50 | set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ${original_CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH}) 51 | endif () 52 | 53 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbasePCRE.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019 Couchbase 2 | # 3 | # Finds the PCRE lib and headers. Only guaranteed to work with the cbdeps 4 | # PCRE package as part of the Couchbase Server build, but it does use 5 | # standard CMake conventions so it may work in other environments as well. 6 | # Sets: 7 | # PCRE_INCLUDE_DIR 8 | # PCRE_LIBRARY_DIR 9 | # 10 | # Important: the PCRE cbdep package is only expected to work with CGo. 11 | # Linking it to MSVC-compiled C/C++ code will likely not work due to the 12 | # absence of the .lib link library. See comment further down. 13 | 14 | IF (NOT DEFINED PCRE_FOUND) 15 | 16 | # Supported platforms should only use the provided hints 17 | CB_GET_SUPPORTED_PLATFORM (_is_supported_platform) 18 | IF (_is_supported_platform) 19 | SET (_no_default_path NO_DEFAULT_PATH) 20 | ENDIF () 21 | 22 | SET (_exploded_dir "${CMAKE_BINARY_DIR}/tlm/deps/pcre.exploded") 23 | 24 | FIND_PATH (PCRE_INCLUDE_DIR 25 | NAMES pcre.h 26 | HINTS "${_exploded_dir}" 27 | PATH_SUFFIXES include 28 | ${_no_default_path}) 29 | 30 | # I am theorizing a bit here, but: On Windows I do not believe we can use 31 | # FIND_LIBRARY() here. This is because PCRE was built using MinGW (due to 32 | # insurmountable problems getting it to compile correctly in MSVC), but 33 | # our overall Server CMake project is in "MSVC Mode" and hence is expecting 34 | # to "find" a pcre.lib link library for building. No such library is produced 35 | # by MinGW, and while there is some evidence that it can be convinced to do 36 | # so, the doc I've been able to find online left me too confused to try. 37 | # Moreover, since PCRE is only actually linked by Go code in our project 38 | # (which uses MinGW under the covers anyway), we never actually NEED the 39 | # .lib file; all we need is the path to the directory containing libpcre.dll. 40 | # There is extensive confusing commentary about this on MB-32895. 41 | FIND_PATH (PCRE_LIBRARY_DIR 42 | NAMES libpcre.dll libpcre.so libpcre.dylib 43 | HINTS "${CMAKE_INSTALL_PREFIX}/bin" "${CMAKE_INSTALL_PREFIX}/lib" 44 | ${_no_default_path}) 45 | 46 | INCLUDE (FindPackageHandleStandardArgs) 47 | FIND_PACKAGE_HANDLE_STANDARD_ARGS (PCRE DEFAULT_MSG PCRE_LIBRARY_DIR PCRE_INCLUDE_DIR) 48 | 49 | IF (PCRE_FOUND) 50 | MESSAGE (STATUS "PCRE header dir: ${PCRE_INCLUDE_DIR}") 51 | MESSAGE (STATUS "PCRE library dir: ${PCRE_LIBRARY_DIR}") 52 | ELSE (PCRE_FOUND) 53 | MESSAGE (FATAL_ERROR "PCRE is required for building Couchbase, but was not found") 54 | ENDIF (PCRE_FOUND) 55 | 56 | MARK_AS_ADVANCED (PCRE_INCLUDE_DIR PCRE_LIBRARY PCRE_LIBRARY_DIR PCRE_LIBRARIES) 57 | 58 | ENDIF (NOT DEFINED PCRE_FOUND) 59 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbasePrometheus.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) 17 | 18 | set(_prometheus_exploded ${CMAKE_BINARY_DIR}/tlm/deps/prometheus-cpp.exploded) 19 | 20 | if (NOT DEFINED prometheus-cpp_ROOT AND EXISTS ${_prometheus_exploded}) 21 | set(prometheus-cpp_ROOT ${_prometheus_exploded}) 22 | endif () 23 | 24 | find_package(prometheus-cpp REQUIRED) 25 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseSimdutf.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2023 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | if (NOT DEFINED simdutf_ROOT AND EXISTS ${CMAKE_BINARY_DIR}/tlm/deps/simdutf.exploded) 17 | set(simdutf_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/simdutf.exploded) 18 | endif() 19 | 20 | find_package(simdutf REQUIRED CONFIG) 21 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseSnappy.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate snappy library 17 | # This module defines 18 | # SNAPPY_FOUND, if false, do not try to link with snappy 19 | # SNAPPY_LIBRARIES, Library path and libs 20 | # SNAPPY_INCLUDE_DIR, where to find the ICU headers 21 | 22 | if (NOT DEFINED SNAPPY_FOUND) 23 | include(PlatformIntrospection) 24 | 25 | cb_get_supported_platform(_is_supported_platform) 26 | if (_is_supported_platform) 27 | # Supported platforms should only use the provided hints and pick it up 28 | # from cbdeps 29 | set(_snappy_no_default_path NO_DEFAULT_PATH) 30 | endif () 31 | 32 | set(_snappy_exploded ${CMAKE_BINARY_DIR}/tlm/deps/snappy.exploded) 33 | 34 | find_path(SNAPPY_INCLUDE_DIR snappy.h 35 | HINTS ${_snappy_exploded}/include 36 | ${_snappy_no_default_path}) 37 | 38 | if (NOT SNAPPY_INCLUDE_DIR) 39 | message(FATAL_ERROR "Failed to locate snappy.h") 40 | endif () 41 | 42 | find_library(SNAPPY_LIBRARIES 43 | NAMES snappy 44 | HINTS 45 | ${_snappy_exploded}/lib 46 | ${_snappy_no_default_path}) 47 | 48 | if (NOT SNAPPY_LIBRARIES) 49 | message(FATAL_ERROR "Failed to locate snappy library") 50 | endif () 51 | 52 | message(STATUS "Found snappy headers in: ${SNAPPY_INCLUDE_DIR}") 53 | message(STATUS " libraries: ${SNAPPY_LIBRARIES}") 54 | set(SNAPPY_FOUND true CACHE BOOL "Found Google Snappy" FORCE) 55 | mark_as_advanced(SNAPPY_FOUND SNAPPY_INCLUDE_DIR SNAPPY_LIBRARIES) 56 | endif (NOT DEFINED SNAPPY_FOUND) 57 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseSpdlog.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2021 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate https://github.com/gabime/spdlog library. 17 | 18 | set(spdlog_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/spdlog.exploded) 19 | # When building with ThreadSanitizer, prepend its root dir so we pick up 20 | # the TSan-enabled library ahead of the vanilla one. 21 | if(CB_THREADSANITIZER) 22 | list(PREPEND spdlog_ROOT ${CMAKE_BINARY_DIR}/tlm/deps/spdlog.exploded/tsan_root) 23 | endif() 24 | 25 | find_package(spdlog REQUIRED) 26 | if(spdlog_FOUND) 27 | message(STATUS "Found spdlog at: ${spdlog_DIR}") 28 | endif() 29 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseV8.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate v8 library 17 | # This module defines 18 | # V8_FOUND, if V8 was found 19 | # V8_LIBRARIES, Library path and libs 20 | # V8_INCLUDE_DIR, where to find V8 headers 21 | if (NOT DEFINED V8_FOUND) 22 | include(PlatformIntrospection) 23 | 24 | cb_get_supported_platform(_is_supported_platform) 25 | if (_is_supported_platform) 26 | # Supported platforms should only use the provided hints and pick it up 27 | # from cbdeps 28 | set(_v8_no_default_path NO_DEFAULT_PATH) 29 | endif () 30 | 31 | set(_v8_exploded ${CMAKE_BINARY_DIR}/tlm/deps/v8.exploded) 32 | 33 | find_path(V8_INCLUDE_DIR v8.h 34 | HINTS ${_v8_exploded}/include 35 | ${_v8_no_default_path}) 36 | 37 | if (NOT V8_INCLUDE_DIR) 38 | message(FATAL_ERROR "Failed to locate v8.h") 39 | endif () 40 | 41 | if (WIN32) 42 | # RelWithDebInfo & MinSizeRel should use the Release libraries, otherwise use 43 | # the same directory as the build type. 44 | if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") 45 | set(_build_type "Release") 46 | else () 47 | set(_build_type ${CMAKE_BUILD_TYPE}) 48 | ENDIF () 49 | 50 | if (NOT V8_LIBRARIES) 51 | set(_v8_libraries "v8.dll;v8_libplatform.dll;v8_libbase.dll;icuuc.dll;third_party_abseil-cpp_absl.dll;third_party_icu_icui18n.dll;third_party_zlib.dll") 52 | foreach (_mylib ${_v8_libraries}) 53 | unset(_the_lib CACHE) 54 | find_library(_the_lib 55 | NAMES ${_mylib} 56 | HINTS ${_v8_exploded}/lib/${_build_type} 57 | ${_v8_no_default_path}) 58 | if (_the_lib) 59 | list(APPEND _v8_libs_found ${_the_lib}) 60 | else() 61 | message(FATAL_ERROR "Didn't find V8 library ${_mylib}!") 62 | endif (_the_lib) 63 | endforeach (_mylib) 64 | set(V8_LIBRARIES ${_v8_libs_found} CACHE STRING "V8 Libraries" FORCE) 65 | endif (NOT V8_LIBRARIES) 66 | else (WIN32) 67 | if (NOT V8_LIBRARIES) 68 | set(_v8_libraries "v8;v8_libplatform;v8_libbase;chrome_zlib;icuuc;third_party_abseil-cpp_absl;third_party_icu_icui18n") 69 | foreach (_mylib ${_v8_libraries}) 70 | unset(_the_lib CACHE) 71 | find_library(_the_lib 72 | NAMES ${_mylib} 73 | HINTS ${CMAKE_INSTALL_PREFIX}/lib 74 | ${_v8_no_default_path}) 75 | if (_the_lib) 76 | list(APPEND _v8_libs_found ${_the_lib}) 77 | else() 78 | message(FATAL_ERROR "Didn't find V8 library ${_mylib}!") 79 | endif (_the_lib) 80 | endforeach (_mylib) 81 | set(V8_LIBRARIES ${_v8_libs_found} CACHE STRING "V8 Libraries" FORCE) 82 | endif (NOT V8_LIBRARIES) 83 | endif (WIN32) 84 | 85 | if (V8_LIBRARIES) 86 | message(STATUS "Found v8 headers in: ${V8_INCLUDE_DIR}") 87 | message(STATUS " libraries: ${V8_LIBRARIES}") 88 | else (V8_LIBRARIES) 89 | message(FATAL_ERROR "Can't build Couchbase without V8") 90 | endif (V8_LIBRARIES) 91 | 92 | set(V8_FOUND true CACHE BOOL "Found V8" FORCE) 93 | mark_as_advanced(V8_FOUND V8_INCLUDE_DIR V8_LIBRARIES) 94 | endif (NOT DEFINED V8_FOUND) 95 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseValgrind.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # Locate and configure Valgrind for memory checking. 17 | # This module defines 18 | # MEMORYCHECK_COMMAND - containing the path to valgrind 19 | # MEMORYCHECK_COMMAND_OPTIONS - The options to pass to valgrind 20 | if (NOT DEFINED MEMORYCHECK_COMMAND) 21 | find_program(MEMORYCHECK_COMMAND valgrind) 22 | set(_valgrind_options 23 | "--gen-suppressions=all" 24 | "--leak-check=full" 25 | "--num-callers=32" 26 | "--partial-loads-ok=yes" 27 | "--show-leak-kinds=all" 28 | # MB-26684: New features we introduced in RocksDBKVStore 29 | # led to the execution of the 'malloc_usable_size' function. 30 | # While the 'new' and 'delete' operators in 'libstd++' are 31 | # correctly redirected to the Valgrind ones, we need to tell 32 | # Valgrind to redirect also the 'malloc_usable_size' function in 33 | # 'libplatform'. Missing that leads to SegFault when the 34 | # non-Valgrind 'malloc_usable_size' is called giving in input a 35 | # pointer to a Valgrind-allocated block of memory. 36 | "--soname-synonyms=somalloc=libplatform_so.*" 37 | "--suppressions=${CMAKE_SOURCE_DIR}/tlm/valgrind.supp" 38 | "--trace-children=yes" 39 | "--track-origins=yes" 40 | "--xml=yes --xml-file=memcheck.%p.xml") 41 | 42 | string(REPLACE ";" " " MEMORYCHECK_COMMAND_OPTIONS "${_valgrind_options}") 43 | endif (NOT DEFINED MEMORYCHECK_COMMAND) 44 | -------------------------------------------------------------------------------- /cmake/Modules/FindCouchbaseZstd.cmake: -------------------------------------------------------------------------------- 1 | # Locate zstd-cpp 2 | # This module defines 3 | # ZSTD_CPP_LIBRARIES, Library path and libs 4 | # ZSTD_CPP_INCLUDE_DIR, where to find the headers 5 | # ZSTD_CPP_FOUND, whether it was found or not 6 | if (NOT DEFINED ZSTD_CPP_FOUND) 7 | include(PlatformIntrospection) 8 | 9 | cb_get_supported_platform(_is_supported_platform) 10 | if (_is_supported_platform) 11 | set(_zstd_cpp_no_default_path NO_DEFAULT_PATH) 12 | endif () 13 | 14 | if (NOT DEFINED _zstd_cpp_include_dir) 15 | set(_zstd_cpp_include_dir ${CMAKE_BINARY_DIR}/tlm/deps/zstd-cpp.exploded/include) 16 | endif () 17 | if (NOT DEFINED _zstd_cpp_library_dir) 18 | set(_zstd_cpp_library_dir ${CMAKE_BINARY_DIR}/tlm/deps/zstd-cpp.exploded/lib) 19 | endif () 20 | 21 | find_path(ZSTD_CPP_INCLUDE_DIR 22 | NAMES zstd.h 23 | PATHS 24 | ${_zstd_cpp_include_dir} 25 | ${_zstd_cpp_no_default_path}) 26 | 27 | find_library(ZSTD_CPP_LIBRARIES 28 | NAMES zstd 29 | PATHS 30 | ${_zstd_cpp_library_dir} 31 | ${_zstd_cpp_no_default_path}) 32 | 33 | if (ZSTD_CPP_INCLUDE_DIR AND ZSTD_CPP_LIBRARIES) 34 | message(STATUS "Found zstd-cpp headers in: ${ZSTD_CPP_INCLUDE_DIR}") 35 | message(STATUS "Found zstd-cpp library : ${ZSTD_CPP_LIBRARIES}") 36 | set(ZSTD_CPP_FOUND true CACHE BOOL "Found zstd-cpp" FORCE) 37 | else () 38 | message(STATUS "Did not find zstd-cpp") 39 | set(ZSTD_CPP_FOUND false CACHE BOOL "Found zstd-cpp" FORCE) 40 | endif () 41 | endif (NOT DEFINED ZSTD_CPP_FOUND) 42 | 43 | IF (ZSTD_CPP_FOUND AND NOT TARGET Zstd::zstd) 44 | # Pretend we're using Modern CMake to find this thing. 45 | add_library(Zstd::zstd STATIC IMPORTED) 46 | set_target_properties(Zstd::zstd 47 | PROPERTIES 48 | IMPORTED_LOCATION ${ZSTD_CPP_LIBRARIES}) 49 | target_include_directories(Zstd::zstd INTERFACE 50 | ${ZSTD_CPP_INCLUDE_DIR}) 51 | ENDIF () 52 | -------------------------------------------------------------------------------- /cmake/Modules/MetricsMetadata.cmake: -------------------------------------------------------------------------------- 1 | # Provides functions for testing and installing metrics_metadata.json files. 2 | 3 | IF (NOT MetricsMetadata_INCLUDED) 4 | 5 | # Have to remember cwd when this file is INCLUDE()d 6 | SET (TLM_MODULES_DIR "${CMAKE_CURRENT_LIST_DIR}") 7 | 8 | # We'll use this if it's available 9 | FIND_PROGRAM(JQ_EXE jq) 10 | 11 | # Adds a target to verify and install a metrics_metadata.json file. 12 | # 13 | # Required arguments: 14 | # JSON - path to .json file 15 | # COMPONENT - name of the component these metrics are for. 16 | # 17 | # This will install the JSON file as 18 | # ${CMAKE_INSTALL_PREFIX}/etc/couchbase/COMPONENT/metrics_metadata.json. 19 | # 20 | # If the 'jq' utility was found, it will sort the top-level keys of this 21 | # file (this is required for production builds). Otherwise it will simply 22 | # parse the file to ensure it is valid JSON. 23 | MACRO (AddMetricsMetadata) 24 | PARSE_ARGUMENTS(mm "JSON;COMPONENT" "" "" ${ARGN}) 25 | 26 | IF (NOT mm_JSON) 27 | MESSAGE (FATAL_ERROR "JSON is required!") 28 | ENDIF () 29 | IF (NOT mm_COMPONENT) 30 | MESSAGE (FATAL_ERROR "COMPONENT is required!") 31 | ENDIF () 32 | 33 | IF (CB_PRODUCTION_BUILD AND NOT JQ_EXE AND UNIX AND NOT APPLE) 34 | MESSAGE (FATAL_ERROR "'jq' not found - required for Linux production builds!") 35 | ENDIF () 36 | 37 | SET (_outdir "${CMAKE_CURRENT_BINARY_DIR}/etc/couchbase/${mm_COMPONENT}") 38 | FILE (MAKE_DIRECTORY "${_outdir}") 39 | SET (_outputfile "${_outdir}/metrics_metadata.json") 40 | 41 | ADD_CUSTOM_COMMAND( 42 | OUTPUT "${_outputfile}" 43 | DEPENDS "${mm_JSON}" 44 | COMMAND "${CMAKE_COMMAND}" 45 | -D "JQ_EXE=${JQ_EXE}" 46 | -D "JSON_IN=${mm_JSON}" 47 | -D "JSON_OUT=${_outputfile}" 48 | -P "${TLM_MODULES_DIR}/add_metrics_metadata.cmake" 49 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 50 | VERBATIM 51 | ) 52 | ADD_CUSTOM_TARGET( 53 | "${mm_COMPONENT}_metrics_metadata" ALL 54 | DEPENDS "${_outputfile}" 55 | ) 56 | INSTALL( 57 | FILES "${_outputfile}" 58 | DESTINATION "etc/couchbase/${mm_COMPONENT}" 59 | ) 60 | 61 | ENDMACRO (AddMetricsMetadata) 62 | 63 | SET (MetricsMetadata_INCLUDED 1) 64 | ENDIF (NOT MetricsMetadata_INCLUDED) 65 | -------------------------------------------------------------------------------- /cmake/Modules/ParseArguments.cmake: -------------------------------------------------------------------------------- 1 | # Prevent double-definition if two projects use this script 2 | IF (NOT ParseArguments_INCLUDED) 3 | SET (ParseArguments_INCLUDED 1) 4 | 5 | # Utility macro to parse CMake-style argument lists. Arguments: 6 | # prefix - a common prefix for variables set by this function (see below). 7 | # arg_names - arguments that may take multiple values. 8 | # onearg_names - arguments that may take a single value. 9 | # option_names - arguments that take zero values. 10 | # 11 | # For each argument specified, this function will set a variable named 12 | # ${prefix}_${argname}. The value of this variable will be: 13 | # 14 | # - a list of all specified values (arg_names) 15 | # - the single value (onearg_names) 16 | # - 1 or 0, depending on whether the option was specified (option_names) 17 | # 18 | # This macro has no concept of "required" or "optional" arguments; that logic 19 | # must be implemented by the calling code. 20 | MACRO(PARSE_ARGUMENTS prefix arg_names onearg_names option_names) 21 | SET(DEFAULT_ARGS) 22 | FOREACH(arg_name ${arg_names} ${onearg_names}) 23 | SET(${prefix}_${arg_name}) 24 | ENDFOREACH(arg_name) 25 | FOREACH(option ${option_names}) 26 | SET(${prefix}_${option} 0) 27 | ENDFOREACH(option) 28 | 29 | SET(current_arg_name DEFAULT_ARGS) 30 | SET(current_arg_list) 31 | SET(current_arg_is_singular) 32 | SET(larg_names ${arg_names}) 33 | SET(lonearg_names ${onearg_names}) 34 | SET(loption_names ${option_names}) 35 | FOREACH(arg ${ARGN}) 36 | LIST(FIND larg_names "${arg}" is_arg_name) 37 | LIST(FIND lonearg_names "${arg}" is_onearg_name) 38 | IF (is_arg_name GREATER -1 OR is_onearg_name GREATER -1) 39 | SET(${prefix}_${current_arg_name} ${current_arg_list}) 40 | SET(current_arg_name ${arg}) 41 | SET(current_arg_list) 42 | IF (is_arg_name GREATER -1) 43 | SET(current_arg_is_singular) 44 | ELSE (is_arg_name GREATER -1) 45 | SET(current_arg_is_singular 1) 46 | ENDIF (is_arg_name GREATER -1) 47 | ELSE (is_arg_name GREATER -1 OR is_onearg_name GREATER -1) 48 | LIST(FIND loption_names "${arg}" is_option) 49 | IF (is_option GREATER -1) 50 | SET(${prefix}_${arg} 1) 51 | ELSE (is_option GREATER -1) 52 | SET(current_arg_list ${current_arg_list} ${arg}) 53 | IF (current_arg_is_singular) 54 | LIST(LENGTH current_arg_list current_list_len) 55 | IF (current_list_len GREATER 1) 56 | MESSAGE (FATAL_ERROR "Argument ${current_arg_name} may only have one value") 57 | ENDIF (current_list_len GREATER 1) 58 | ENDIF (current_arg_is_singular) 59 | ENDIF (is_option GREATER -1) 60 | ENDIF (is_arg_name GREATER -1 OR is_onearg_name GREATER -1) 61 | ENDFOREACH(arg) 62 | SET(${prefix}_${current_arg_name} ${current_arg_list}) 63 | ENDMACRO(PARSE_ARGUMENTS) 64 | 65 | ENDIF (NOT ParseArguments_INCLUDED) 66 | -------------------------------------------------------------------------------- /cmake/Modules/add_metrics_metadata.cmake: -------------------------------------------------------------------------------- 1 | # Different steps based on whether 'jq' was found 2 | IF (JQ_EXE) 3 | EXECUTE_PROCESS( 4 | COMMAND "${JQ_EXE}" . --sort-keys "${JSON_IN}" 5 | OUTPUT_FILE "${JSON_OUT}" 6 | RESULT_VARIABLE _failure 7 | ERROR_VARIABLE _errormsg 8 | ) 9 | IF (_failure) 10 | MESSAGE (FATAL_ERROR "Error generating ${JSON_OUT}: ${_errormsg}") 11 | ENDIF () 12 | ELSE (JQ_EXE) 13 | # Use CMake to verify the JSON contents. CMake is unfortunately forgiving 14 | # of some JSON errors, but this is better than nothing. 15 | FILE (READ "${JSON_IN}" _mmjson) 16 | STRING (JSON _unused ERROR_VARIABLE _error MEMBER "${_mmjson}" 1) 17 | IF (_error) 18 | MESSAGE (FATAL_ERROR "Error parsing ${JSON_IN}: ${_error}") 19 | ENDIF (_error) 20 | 21 | # Write the original contents to the output file 22 | FILE (WRITE "${JSON_OUT}" "${_mmjson}") 23 | ENDIF (JQ_EXE) 24 | -------------------------------------------------------------------------------- /cmake/Modules/cb_install_helper.cmake: -------------------------------------------------------------------------------- 1 | # Helper functions for installing dependencies of an executable. These 2 | # functions are intended to be called via an `INSTALL(CODE)` directive, 3 | # not at configuration time. 4 | # 5 | # These functions generally assume everything is to be installed into 6 | # `bin` or `lib` directories. 7 | 8 | 9 | # Install the runtime dependencies of an executable. 10 | # Required arguments: 11 | # 12 | # binary - The path to the binary to install dependencies for. 13 | # type - The type of the binary; must be EXECUTABLES or LIBRARIES. 14 | # 15 | # Any additional arguments will be treated as directories to search for 16 | # dependencies at install time. This should generally only be used on 17 | # Windows, where the runtime search paths are not embedded in the binary. 18 | FUNCTION (InstallDependencies binary type) 19 | MESSAGE (STATUS "Installing ${binary} dependencies") 20 | # We exclude GCC libs that we've already copied to the right place in 21 | # the top-level CMakeLists.txt, as well as any libc-like libraries 22 | # that come from the OS itself. We also exclude deps found under 23 | # CMAKE_INSTALL_PREFIX; we prefer to install them from the binary 24 | # tree. 25 | FILE ( 26 | GET_RUNTIME_DEPENDENCIES 27 | ${type} "${binary}" 28 | DIRECTORIES ${ARGN} 29 | PRE_EXCLUDE_REGEXES 30 | "^ld-linux.*" 31 | "^api-ms-win.*" "^ext-ms-win.*" "^ext-ms-onecore.*" 32 | POST_EXCLUDE_REGEXES 33 | "^/lib.*" "^/usr/lib.*" "^/opt/gcc.*" "${CMAKE_INSTALL_PREFIX}/.*" 34 | RESOLVED_DEPENDENCIES_VAR _deplibs 35 | UNRESOLVED_DEPENDENCIES_VAR _unresolvedeps 36 | CONFLICTING_DEPENDENCIES_PREFIX _conflicts 37 | ) 38 | 39 | # Fail if we have any conflicting or unresolved dependencies. 40 | FOREACH (_con ${_conflicts_FILENAMES}) 41 | message( 42 | WARNING "Dependency `${_con}` resolved to multiple locations: " 43 | "${_conflicts_${_con}}" 44 | ) 45 | ENDFOREACH() 46 | IF (_unresolvedeps) 47 | message(WARNING "Unresolved dependencies: ${_unresolvedeps}") 48 | ENDIF () 49 | IF (_conflicts_FILENAMES OR _unresolvedeps) 50 | message( 51 | FATAL_ERROR "Failed to resolve dependencies for ${binary} " 52 | "(see above messages)" 53 | ) 54 | ENDIF () 55 | 56 | # All dependencies are libraries, so they all go to the same dir. 57 | IF (WIN32) 58 | SET (_libdir bin) 59 | ELSE () 60 | SET (_libdir lib) 61 | ENDIF () 62 | SET (_installlibdir "${CMAKE_INSTALL_PREFIX}/${_libdir}") 63 | 64 | # Copy the dependencies to the install lib directory. 65 | FOREACH (_dep ${_deplibs}) 66 | FILE ( 67 | INSTALL "${_dep}" 68 | DESTINATION "${_installlibdir}" 69 | FOLLOW_SYMLINK_CHAIN USE_SOURCE_PERMISSIONS 70 | ) 71 | CMAKE_PATH (GET _dep FILENAME _depname) 72 | SET (_installdep "${_installlibdir}/${_depname}") 73 | 74 | # Optionally strip the installed dependency. 75 | IF (CMAKE_INSTALL_DO_STRIP) 76 | MESSAGE (STATUS "Stripping: ${CMAKE_STRIP} ${_installdep}") 77 | IF (APPLE) 78 | EXECUTE_PROCESS ( 79 | COMMAND "${CMAKE_STRIP}" -x "${_installdep}" 80 | ) 81 | ELSE () 82 | EXECUTE_PROCESS ( 83 | COMMAND "${CMAKE_STRIP}" --strip-all "${_installdep}" 84 | ) 85 | ENDIF () 86 | ENDIF () 87 | ENDFOREACH () 88 | ENDFUNCTION (InstallDependencies) 89 | -------------------------------------------------------------------------------- /cmake/Modules/go-buildyacc.cmake: -------------------------------------------------------------------------------- 1 | IF (DEFINED ENV{VERBOSE}) 2 | SET (CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT) 3 | endif() 4 | 5 | # Set GOROOT environment 6 | SET (ENV{GOROOT} "${GOROOT}") 7 | SET (GO_EXECUTABLE "${GOROOT}/bin/go") 8 | 9 | # Set GOBIN to direct the output somewhere else 10 | GET_FILENAME_COMPONENT (_outdir "${GOYACC_EXE}" PATH) 11 | SET (ENV{GOBIN} "${_outdir}") 12 | 13 | # Execute "go install". 14 | EXECUTE_PROCESS (RESULT_VARIABLE _failure 15 | COMMAND "${GO_EXECUTABLE}" install golang.org/x/tools/cmd/goyacc@v0.24.0) 16 | IF (_failure) 17 | MESSAGE (FATAL_ERROR "Failed running go install for goyacc") 18 | ENDIF (_failure) 19 | -------------------------------------------------------------------------------- /cmake/Modules/go-modtidy.cmake: -------------------------------------------------------------------------------- 1 | # Unset GOROOT in the environment (which will make Go figure it out from 2 | # the path to the go compiler on disk, which is what we want) 3 | SET (ENV{GOROOT}) 4 | 5 | # Use GOPATH to tell Go where to store downloaded and cached Go modules. 6 | # It will put things into pkg/mod. 7 | SET (ENV{GOPATH} "${GO_BINARY_DIR}") 8 | 9 | # Use GOCACHE to tell Go where to store intermediate compilation artifacts. 10 | # It places things directly into this directory, so we append /cache. 11 | SET (ENV{GOCACHE} "${GO_BINARY_DIR}/cache") 12 | 13 | # If this is a production build, set/override GOPROXY. 14 | # (For now, not on AWS since it doesn't have access to our proxy.) 15 | IF (CB_PRODUCTION_BUILD AND NOT EXISTS "/aws") 16 | SET (ENV{GOPROXY} "http://goproxy.build.couchbase.com/") 17 | ENDIF () 18 | 19 | # Execute "go mod tidy". 20 | EXECUTE_PROCESS ( 21 | RESULT_VARIABLE _failure 22 | COMMAND "${GOEXE}" mod tidy -v -modcacherw) 23 | 24 | IF (_failure) 25 | MESSAGE (FATAL_ERROR "Failed running go mod tidy") 26 | ENDIF (_failure) 27 | -------------------------------------------------------------------------------- /cmake/Modules/go-modtidyall.cmake: -------------------------------------------------------------------------------- 1 | # Write a checksum of the current repo state into the variable named by "var" 2 | MACRO (_DETERMINE_REPO_CHECKSUM var) 3 | EXECUTE_PROCESS ( 4 | COMMAND repo diff -u 5 | WORKING_DIRECTORY ${REPO_SYNC_DIR} 6 | OUTPUT_VARIABLE _diff_output 7 | RESULT_VARIABLE _failed 8 | ERROR_VARIABLE _stderr 9 | ) 10 | IF (_failed) 11 | MESSAGE (FATAL_ERROR "Error running 'repo diff' (${_failed}): ${_diff_output}") 12 | ENDIF () 13 | 14 | STRING (SHA256 ${var} "${_diff_output}") 15 | ENDMACRO (_DETERMINE_REPO_CHECKSUM) 16 | 17 | # Get initial state of repo sync 18 | _DETERMINE_REPO_CHECKSUM (_init_checksum) 19 | 20 | # Loop forever (will break out manually) 21 | WHILE (1) 22 | MESSAGE (STATUS "Running 'go mod tidy' for all projects") 23 | EXECUTE_PROCESS ( 24 | COMMAND "${CMAKE_COMMAND}" --build . --target go-mod-tidy 25 | RESULT_VARIABLE _failed 26 | ERROR_VARIABLE _stderr 27 | ) 28 | IF (_failed) 29 | MESSAGE (FATAL_ERROR "Error running 'go-mod-tidy' target: ${_stderr}") 30 | ENDIF () 31 | 32 | # Get new repo checksum 33 | _DETERMINE_REPO_CHECKSUM (_curr_checksum) 34 | 35 | # If no changes, great! All done 36 | IF (_curr_checksum STREQUAL _init_checksum) 37 | BREAK () 38 | ENDIF () 39 | 40 | MESSAGE (STATUS "Repo was changed - re-running go-mod-tidy") 41 | SET (_init_checksum "${_curr_checksum}") 42 | ENDWHILE () 43 | -------------------------------------------------------------------------------- /cmake/Modules/go-test.cmake: -------------------------------------------------------------------------------- 1 | # Convert GOPATH list, if set, to proper GOPATH environment variable. 2 | # Otherwise we'll inherit the caller's GOPATH environment. 3 | IF (GOPATH) 4 | SET (_gopath "${GOPATH}") 5 | IF (NOT WIN32) 6 | STRING (REPLACE ";" ":" _gopath "${_gopath}") 7 | ENDIF (NOT WIN32) 8 | SET (ENV{GOPATH} "${_gopath}") 9 | ENDIF (GOPATH) 10 | 11 | MACRO (EXPORT_FLAGS var envvar flag) 12 | IF (${var}) 13 | SET (_value) 14 | FOREACH (_dir ${${var}}) 15 | SET (_value "${_value} ${flag} ${_dir}") 16 | ENDFOREACH (_dir) 17 | SET (ENV{${envvar}} "${_value}") 18 | ENDIF (${var}) 19 | ENDMACRO (EXPORT_FLAGS) 20 | 21 | # Convert CGO_xxx_DIRS values into platform- and compiler-appropriate 22 | # CGO_ environment variables. Currently only known to work on Linux 23 | # and probably Mac environments. 24 | EXPORT_FLAGS (CGO_INCLUDE_DIRS CGO_CPPFLAGS "-I") 25 | EXPORT_FLAGS (CGO_LIBRARY_DIRS CGO_LDFLAGS "-L") 26 | 27 | IF (CGO_LDFLAGS) 28 | SET (ENV{CGO_LDFLAGS} "$ENV{CGO_LDFLAGS} ${CGO_LDFLAGS}") 29 | ENDIF () 30 | 31 | IF (NOT WIN32 AND NOT APPLE) 32 | IF (CB_THREADSANITIZER OR CB_ADDRESSSANITIZER OR CB_UNDEFINEDSANITIZER) 33 | # Only use the CMAKE C compiler for cgo on non-Windows platforms; 34 | # on Windows we use a different compiler (gcc) for cgo than for 35 | # the main build MSVC). 36 | # On macOS, Golang fails with "_cgo_export.c:3:10: fatal error: 37 | # 'stdlib.h' file not found" if we override CC to be 38 | # CMAKE_C_COMPILER (which is 'cc' by default), using Golang's 39 | # default of 'clang' is fine hence also skip the override here. 40 | SET (ENV{CC} "${CMAKE_C_COMPILER}") 41 | ENDIF (CB_THREADSANITIZER OR CB_ADDRESSSANITIZER OR CB_UNDEFINEDSANITIZER) 42 | ENDIF() 43 | 44 | # QQQ TOTAL HACK to enable CGO binaries to find Couchbase-built shared 45 | # libraries. This will clearly only work on Linux ELF-based systems, 46 | # and only for those libraries which are installed in the correct path 47 | # relative to the installed location of the Go executable. I'm still 48 | # trying to figure out how to handle this correctly. 49 | SET (ENV{LD_RUN_PATH} "$ORIGIN/../lib") 50 | 51 | # Always use -x if CB_GO_DEBUG is set 52 | IF ($ENV{CB_GO_DEBUG}) 53 | SET (_go_debug -x) 54 | ENDIF ($ENV{CB_GO_DEBUG}) 55 | 56 | # check if race detector flag is set 57 | IF (CB_GO_RACE_DETECTOR) 58 | SET (_go_race -race) 59 | ENDIF (CB_GO_RACE_DETECTOR) 60 | 61 | # Set GOROOT environment 62 | SET (ENV{GOROOT} "${GOROOT}") 63 | SET (GO_EXECUTABLE "${GOROOT}/bin/go") 64 | 65 | # For Go 1.5 or better, use -pkgdir to separate the compiled bits out 66 | # of the source directories - separate directories per Go version, to 67 | # prevent conflicts. 68 | SET (_bits) 69 | IF ("${GOVERSION}" VERSION_GREATER 1.4.9) 70 | SET (_bits -pkgdir "${GO_BINARY_DIR}") 71 | STRING (REPLACE ";" " " _bits_str "${_bits}") 72 | ENDIF () 73 | 74 | # The test needs to know where to find the shared libraries created during the 75 | # build. So add them to LD_LIBRARY_PATH here and give them priority. 76 | SET(ENV{LD_LIBRARY_PATH} "${CGO_LIBRARY_DIRS}:$ENV{LD_LIBRARY_PATH}") 77 | 78 | # Execute "go test". 79 | MESSAGE (STATUS "Executing: ${GO_EXECUTABLE} test ${_bits_str} -tags=\"${GOTAGS}\" -gcflags=\"${GCFLAGS}\" -ldflags=\"${LDFLAGS}\" ${_go_debug} ${_go_race} ${PACKAGE}") 80 | EXECUTE_PROCESS (RESULT_VARIABLE _failure 81 | COMMAND "${GO_EXECUTABLE}" test ${_bits} "-tags=${GOTAGS}" "-gcflags=${GCFLAGS}" "-ldflags=${LDFLAGS}" ${_go_debug} ${_go_race} "${PACKAGE}") 82 | IF (CB_GO_CODE_COVERAGE) 83 | MESSAGE (STATUS "Executing: ${GO_EXECUTABLE} test -c -cover -covermode=count -coverpkg ${PACKAGE} -tags=${GOTAGS} -gcflags=${GCFLAGS} -ldflags=${LDFLAGS} ${_go_debug} ${PACKAGE}") 84 | EXECUTE_PROCESS (COMMAND "${GO_EXECUTABLE}" test -c -cover -covermode=count -coverpkg ${PACKAGE} "-tags=${GOTAGS}" "-gcflags=${GCFLAGS}" "-ldflags=${LDFLAGS}" ${_go_debug} "${PACKAGE}") 85 | ENDIF () 86 | IF (_failure) 87 | MESSAGE (FATAL_ERROR "Failed running go test") 88 | ENDIF (_failure) 89 | -------------------------------------------------------------------------------- /cmake/Modules/go-yacc.cmake: -------------------------------------------------------------------------------- 1 | # Execute "go yacc" 2 | IF (DEFINED ENV{VERBOSE}) 3 | MESSAGE (STATUS "Executing: ${GOYACC_EXECUTABLE} ${YFILE}") 4 | endif() 5 | EXECUTE_PROCESS (RESULT_VARIABLE _failure 6 | COMMAND "${GOYACC_EXECUTABLE}" "${YFILE}") 7 | IF (_failure) 8 | MESSAGE (FATAL_ERROR "Failed running go yacc") 9 | ENDIF (_failure) 10 | -------------------------------------------------------------------------------- /cmake/Modules/rebar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/tlm/e3c29ffe09399469e2c72bb6a44935505143a4e9/cmake/Modules/rebar -------------------------------------------------------------------------------- /cmake/Modules/rebar3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/couchbase/tlm/e3c29ffe09399469e2c72bb6a44935505143a4e9/cmake/Modules/rebar3 -------------------------------------------------------------------------------- /cmake/Modules/try_search_sanitizer_library.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020-Present Couchbase, Inc. 3 | 4 | Use of this software is governed by the Business Source License included in 5 | the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 6 | file, in accordance with the Business Source License, use of this software will 7 | be governed by the Apache License, Version 2.0, included in the file 8 | licenses/APL2.txt. 9 | */ 10 | 11 | // Minimal C file which is used by try_search_sanitizer_library(). 12 | int main() { return 0; } 13 | -------------------------------------------------------------------------------- /deps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Dependency downloads must be explicitly enabled 2 | IF (NOT CB_DOWNLOAD_DEPS) 3 | RETURN () 4 | ENDIF (NOT CB_DOWNLOAD_DEPS) 5 | 6 | INCLUDE (PlatformIntrospection) 7 | INCLUDE (CBDownloadDeps) 8 | 9 | MESSAGE (STATUS "*** Installing binary dependencies ***") 10 | _DETERMINE_PLATFORMS (cbcache_platform) 11 | _DETERMINE_ARCH (cbcache_arch) 12 | 13 | MESSAGE (STATUS "Set platform to ${cbcache_platform} for dependency downloads") 14 | MESSAGE (STATUS "Set arch to ${cbcache_arch} for dependency downloads") 15 | 16 | CB_GET_SUPPORTED_PLATFORM(_is_supported_platform) 17 | IF (NOT _is_supported_platform) 18 | IF (CB_PRODUCTION_BUILD) 19 | MESSAGE (FATAL_ERROR "Attempt to run production build on unsupported platform!") 20 | ENDIF () 21 | MESSAGE (STATUS "NOTE: The dependencies for unsupported platforms may not be available.") 22 | MESSAGE (STATUS " Downloads may fail.") 23 | MESSAGE (STATUS " You may try building dependencies by running \"make deps-all\" from the repo root.") 24 | MESSAGE (STATUS " Individual dependencies can be built by running \"make dep-\".") 25 | ENDIF () 26 | 27 | # Default personal override manifest is in user's home directory; may 28 | # be overridden by CB_DOWNLOAD_DEPS_MANIFEST environment variable or 29 | # by -DCB_DOWNLOAD_DEPS_MANIFEST on the CMake line. 30 | IF (DEFINED ENV{CB_DOWNLOAD_DEPS_MANIFEST}) 31 | SET (_manifest_default "$ENV{CB_DOWNLOAD_DEPS_MANIFEST}") 32 | ELSEIF (WIN32) 33 | SET (_manifest_default "$ENV{HOMEPATH}/cbdepsmanifest.cmake") 34 | ELSE (DEFINED ENV{CB_DOWNLOAD_DEPS_MANIFEST}) 35 | # Linux / Mac 36 | SET (_manifest_default "$ENV{HOME}/cbdepsmanifest.cmake") 37 | ENDIF (DEFINED ENV{CB_DOWNLOAD_DEPS_MANIFEST}) 38 | SET (CB_DOWNLOAD_DEPS_MANIFEST "${_manifest_default}" CACHE PATH 39 | "Path to user's override third-party dependencies manifest") 40 | IF (EXISTS "${CB_DOWNLOAD_DEPS_MANIFEST}") 41 | MESSAGE (STATUS "-----------------------------------------") 42 | MESSAGE (STATUS "Reading personal third-party dependencies manifest " 43 | "from ${CB_DOWNLOAD_DEPS_MANIFEST}...") 44 | INCLUDE ("${CB_DOWNLOAD_DEPS_MANIFEST}") 45 | MESSAGE (STATUS "Personal third-party dependencies manifest complete") 46 | MESSAGE (STATUS "-----------------------------------------") 47 | ENDIF (EXISTS "${CB_DOWNLOAD_DEPS_MANIFEST}") 48 | 49 | # Read stock manifest 50 | MESSAGE (STATUS "-----------------------------------------") 51 | IF (NOT DEFINED CB_DOWNLOAD_DEPS_DEFAULT_MANIFEST) 52 | SET (CB_DOWNLOAD_DEPS_DEFAULT_MANIFEST manifest.cmake) 53 | ENDIF () 54 | MESSAGE (STATUS "Reading global third-party dependencies manifest...") 55 | INCLUDE ("${CB_DOWNLOAD_DEPS_DEFAULT_MANIFEST}") 56 | MESSAGE (STATUS "Global third-party dependencies manifest complete") 57 | MESSAGE (STATUS "-----------------------------------------") 58 | 59 | # Update prefix path to include paths for all cbdeps for searching 60 | GET_PROPERTY(_cbdeps_prefix_path GLOBAL PROPERTY CBDEPS_PREFIX_PATH) 61 | SET(CMAKE_PREFIX_PATH "${_cbdeps_prefix_path};${CMAKE_PREFIX_PATH}" PARENT_SCOPE) 62 | -------------------------------------------------------------------------------- /deps/manifest.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Keep the list sorted alphabetically, and the platforms alphabetically. 3 | # The syntax is: 4 | # 5 | # DECLARE_DEP (name VERSION version-revision PLATFORMS platform1 platform2) 6 | # 7 | # This manifest contains entries for SUPPORTED platforms. These are 8 | # platforms on which Couchbase builds and delivers Server binaries 9 | # to customers. 10 | # 11 | # The list of supported platforms may change between releases, but 12 | # you may use the cmake macro CB_GET_SUPPORTED_PLATFORM to 13 | # check if this is a supported platform. 14 | # 15 | # IMPORTANT: If you add a new package here or update an existing package 16 | # version, you must also update couchbase-server-black-duck-manifest.yaml 17 | # in this same directory! 18 | # 19 | DECLARE_DEP (AWSSDK V2 VERSION 1.11.450 BUILD 2 PLATFORMS linux macosx) 20 | DECLARE_DEP (benchmark VERSION v1.9.1-cb1 PLATFORMS linux macosx windows) 21 | DECLARE_DEP (breakpad V2 VERSION 20200430 BUILD 4 PLATFORMS linux windows) 22 | DECLARE_DEP (boost VERSION 1.82.0-cb6 PLATFORMS linux macosx windows) 23 | DECLARE_DEP (cbpy V2 VERSION 3.11.10 BUILD 2 PLATFORMS linux macosx windows DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/python/interp") 24 | DECLARE_DEP (curl V2 VERSION 8.12.1 BUILD 1 PLATFORMS linux macosx windows) 25 | DECLARE_DEP (double-conversion VERSION 3.3.0-cb1 PLATFORMS linux macosx windows) 26 | DECLARE_DEP (erlang V2 VERSION 26.2 BUILD 4 PLATFORMS linux macosx windows) 27 | DECLARE_DEP (faiss V2 VERSION 1.11.0 BUILD 1_avx2 PLATFORMS linux macosx windows) 28 | DECLARE_DEP (fast_float V2 VERSION 7.0.0 BUILD 1 PLATFORMS linux macosx windows) 29 | DECLARE_DEP (flatbuffers VERSION v1.10.0-cb7 PLATFORMS linux macosx windows) 30 | DECLARE_DEP (fmt VERSION 11.0.0-cb2 PLATFORMS linux macosx windows) 31 | DECLARE_DEP (gflags V2 VERSION 2.2.2 BUILD 1 PLATFORMS linux macosx windows) 32 | DECLARE_DEP (folly VERSION v2022.05.23.00-couchbase-cb1_morpheus PLATFORMS linux macosx windows) 33 | DECLARE_DEP (glog VERSION v0.4.0-cb3 PLATFORMS linux macosx windows) 34 | DECLARE_DEP (googletest VERSION 1.15.2-cb1 PLATFORMS linux macosx windows) 35 | DECLARE_DEP (grpc V2 VERSION 1.72.0 BUILD 2 PLATFORMS linux macosx windows) 36 | # 37 | # IMPORTANT: If you add a new package here or update an existing package 38 | # version, you must also update couchbase-server-black-duck-manifest.yaml 39 | # in this same directory! 40 | # 41 | DECLARE_DEP (jemalloc V2 VERSION 5.3.0 BUILD 15 PLATFORMS linux macosx windows) 42 | DECLARE_DEP (jemalloc_noprefix V2 VERSION 5.2.1 BUILD 12 PLATFORMS linux windows) 43 | DECLARE_DEP (jemalloc_noprefix V2 VERSION 5.3.0 BUILD 11 PLATFORMS macosx) 44 | DECLARE_DEP (json VERSION 3.11.3-cb2 PLATFORMS linux macosx windows) 45 | DECLARE_DEP (libevent VERSION 2.1.11-cb12 PLATFORMS linux macosx windows) 46 | DECLARE_DEP (libsodium V2 VERSION 1.0.18 BUILD 5 PLATFORMS linux macosx windows) 47 | DECLARE_DEP (liburing V2 VERSION 0.6 BUILD 3 PLATFORMS linux) 48 | DECLARE_DEP (libuv V2 VERSION 1.20.3 BUILD 17 PLATFORMS windows) 49 | DECLARE_DEP (libuv V2 VERSION 1.20.3 BUILD 23 PLATFORMS linux macosx) 50 | DECLARE_DEP (lz4 V2 VERSION 1.10.0 BUILD 2 PLATFORMS linux macosx windows) 51 | DECLARE_DEP (maven VERSION 3.5.2-cb6 PLATFORMS all) 52 | DECLARE_DEP (pcre VERSION 8.44-cb4 PLATFORMS linux macosx windows) 53 | DECLARE_DEP (openssl V2 VERSION 3.1.4 BUILD 1 PLATFORMS linux macosx windows) 54 | DECLARE_DEP (numactl VERSION 2.0.11-cb4 PLATFORMS linux) 55 | DECLARE_DEP (prometheus V2 VERSION 2.45.0 BUILD 8 GO_DEP PLATFORMS linux macosx windows) 56 | DECLARE_DEP (prometheus-cpp VERSION v1.2.1-couchbase-cb1 PLATFORMS linux macosx windows) 57 | DECLARE_DEP (protoc-gen-go V2 VERSION 1.2.5 BUILD 7 PLATFORMS linux macosx windows) 58 | DECLARE_DEP (simdutf V2 VERSION 7.0.0 BUILD 2_generic PLATFORMS linux macosx windows) 59 | DECLARE_DEP (snappy VERSION 1.1.10-cb3 PLATFORMS linux macosx windows) 60 | DECLARE_DEP (spdlog VERSION v1.15.0-cb4 PLATFORMS linux macosx windows) 61 | DECLARE_DEP (v8 V2 VERSION 12.1.285.26 BUILD 1 PLATFORMS linux macosx windows) 62 | DECLARE_DEP (zlib V2 VERSION 1.2.13 BUILD 2 PLATFORMS linux macosx windows) 63 | DECLARE_DEP (zstd-cpp V2 VERSION 1.5.0 BUILD 4 PLATFORMS linux macosx windows) 64 | 65 | # 66 | # IMPORTANT: If you add a new package here or update an existing package 67 | # version, you must also update couchbase-server-black-duck-manifest.yaml 68 | # in this same directory! 69 | # 70 | -------------------------------------------------------------------------------- /deps/packages/benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | ExternalProject_Add(benchmark 4 | GIT_REPOSITORY ${_git_repo} 5 | GIT_TAG ${_git_rev} 6 | 7 | CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install 8 | -D CMAKE_BUILD_TYPE=RelWithDebInfo 9 | -D CMAKE_INSTALL_LIBDIR=lib 10 | -D CMAKE_CXX_STANDARD_REQUIRED=ON 11 | -D BUILD_SHARED_LIBS=OFF 12 | -D BENCHMARK_ENABLE_TESTING=OFF 13 | -D BENCHMARK_ENABLE_GTEST_TESTS=OFF 14 | -D BENCHMARK_ENABLE_INSTALL=ON 15 | -D BENCHMARK_DOWNLOAD_DEPENDENCIES=OFF 16 | 17 | CMAKE_CACHE_ARGS ${common_cmake_cache_args} 18 | 19 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 20 | INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install 21 | COMMAND ${CMAKE_COMMAND} -E remove_directory /lib/pkgconfig) 22 | 23 | # cbdeps boilerplate 24 | _ADD_PACKAGE_STEP() 25 | -------------------------------------------------------------------------------- /deps/packages/boost/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of boost source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | ### Download, configure and build boost #################################### 6 | 7 | if (WIN32) 8 | set(boost_bootstrap bootstrap.bat) 9 | set(boost_extra_flags "") 10 | set(boost_variant "debug,release") 11 | else (WIN32) 12 | set(boost_bootstrap bootstrap.sh) 13 | set(boost_extra_flags cxxflags=-std=c++17 cflags=-fno-omit-frame-pointer cxxflags=-fno-omit-frame-pointer cxxflags=-fPIC) 14 | set(boost_variant "release") 15 | endif (WIN32) 16 | 17 | ExternalProject_Add(boost 18 | GIT_REPOSITORY https://github.com/boostorg/boost 19 | GIT_TAG ${_git_rev} 20 | BUILD_IN_SOURCE 1 21 | CONFIGURE_COMMAND /${boost_bootstrap} --prefix= 22 | --with-libraries=container,context,chrono,date_time,filesystem,program_options,regex,system,thread 23 | BUILD_COMMAND /b2 24 | -j 4 25 | --prefix= 26 | address-model=64 27 | debug-symbols=on 28 | ${boost_extra_flags} 29 | link=static 30 | runtime-link=shared 31 | threading=multi 32 | variant=${boost_variant} 33 | install 34 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 35 | # CB Server and Folly (particulary) require most of Boost's submodules; 36 | # however there are few large modules we don't need - and hence don't want to 37 | # bloat the cbdeps with. Remove these before packaging up. 38 | INSTALL_COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost/geometry 39 | COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost/hana 40 | COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost/phoenix 41 | COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost/spirit 42 | COMMAND ${CMAKE_COMMAND} -E remove_directory /include/boost/typeof 43 | ) 44 | 45 | # cbdeps boilerplate 46 | _ADD_PACKAGE_STEP() 47 | -------------------------------------------------------------------------------- /deps/packages/double-conversion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | ExternalProject_Add(double-conversion 4 | GIT_REPOSITORY ${_git_repo} 5 | GIT_TAG ${_git_rev} 6 | 7 | CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install 8 | -D CMAKE_INSTALL_LIBDIR=lib 9 | -D BUILD_SHARED_LIBS=OFF 10 | -D BUILD_TESTING=OFF 11 | -D CMAKE_POSITION_INDEPENDENT_CODE=ON 12 | -D CMAKE_CXX_STANDARD=17 13 | -D CMAKE_BUILD_TYPE=RelWithDebInfo 14 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 15 | ) 16 | 17 | # cbdeps boilerplate 18 | _ADD_PACKAGE_STEP() 19 | -------------------------------------------------------------------------------- /deps/packages/flatbuffers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of flatbuffers source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | # set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy" 6 | 7 | if (CMAKE_COMPILER_IS_GNUCC AND (NOT(CMAKE_CXX_COMPILER_VERSION LESS 7.3.0))) 8 | SET(FLATBUFFERS_COMPILER_OPTIONS "-DCMAKE_CXX_FLAGS:STRING=-Wno-error=implicit-fallthrough") 9 | endif() 10 | 11 | ### Download, configure and build flatbuffers #################################### 12 | ExternalProject_Add(flatbuffers 13 | BUILD_IN_SOURCE 1 14 | GIT_REPOSITORY ${_git_repo} 15 | GIT_TAG ${_git_rev} 16 | PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/macos_disable_werror.patch 17 | CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:STRING=${CMAKE_CURRENT_BINARY_DIR}/install 18 | ${FLATBUFFERS_COMPILER_OPTIONS} 19 | CMAKE_ARGS -D FLATBUFFERS_BUILD_TESTS=OFF 20 | -D CMAKE_BUILD_TYPE=Release 21 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 22 | INSTALL_COMMAND $(MAKE) install 23 | COMMAND ${CMAKE_COMMAND} -E echo "" > /CMakeLists.txt 24 | ) 25 | 26 | # Additionally build a Debug variant on Windows, as for a debug build of 27 | # CB Server we need all dependancies _also_ linked against Debug CRT. 28 | if (WIN32) 29 | ExternalProject_Add(flatbuffers_WinDebugCRT 30 | GIT_REPOSITORY ${_git_repo} 31 | GIT_TAG ${_git_rev} 32 | BUILD_IN_SOURCE 1 33 | CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:STRING=${CMAKE_CURRENT_BINARY_DIR}/install 34 | ${FLATBUFFERS_COMPILER_OPTIONS} 35 | CMAKE_ARGS -D FLATBUFFERS_BUILD_TESTS=OFF 36 | -D CMAKE_BUILD_TYPE=Debug 37 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 38 | INSTALL_COMMAND ${CMAKE_COMMAND} -E copy flatbuffers.lib /lib/flatbuffersd.lib 39 | ) 40 | ExternalProject_Add_StepDependencies(flatbuffers download flatbuffers_WinDebugCRT) 41 | endif() 42 | 43 | 44 | # cbdeps boilerplate 45 | _ADD_PACKAGE_STEP() 46 | -------------------------------------------------------------------------------- /deps/packages/flatbuffers/macos_disable_werror.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index 76619dcb..ea7064ac 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -123,7 +123,7 @@ if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") 6 | # is being configured externally 7 | elseif(APPLE) 8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++") 9 | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter") 10 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Wno-unused-parameter") 11 | elseif(CMAKE_COMPILER_IS_GNUCXX) 12 | if(CYGWIN) 13 | set(CMAKE_CXX_FLAGS 14 | -------------------------------------------------------------------------------- /deps/packages/fmt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | _DETERMINE_CPU_COUNT(_parallelism) 4 | 5 | list(APPEND cache_args ${common_cmake_cache_args}) 6 | list(APPEND cache_args -DCMAKE_CXX_VISIBILITY_PRESET:STRING=hidden) 7 | list(APPEND cache_args -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON) 8 | 9 | ExternalProject_Add(fmt 10 | GIT_REPOSITORY ${_git_repo} 11 | GIT_TAG ${_git_rev} 12 | 13 | CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install 14 | -D CMAKE_BUILD_TYPE=RelWithDebInfo 15 | # Explicilty set LIBDIR to 'lib' so for single linux 16 | # builds (CentOS 7) we don't put the libraries under 17 | # `lib64` which is not a default search path for 18 | # find_package() when we later consume this cbdep. 19 | -D CMAKE_INSTALL_LIBDIR=lib 20 | 21 | CMAKE_CACHE_ARGS ${cache_args} 22 | BUILD_COMMAND ${CMAKE_COMMAND} --build . --parallel ${_parallelism} 23 | 24 | TEST_BEFORE_INSTALL 1 25 | 26 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 27 | ) 28 | 29 | # cbdeps boilerplate 30 | _ADD_PACKAGE_STEP() 31 | -------------------------------------------------------------------------------- /deps/packages/folly/CMakeLists_package.txt: -------------------------------------------------------------------------------- 1 | if (CMAKE_C_COMPILER_ID STREQUAL "Clang") 2 | # Folly checks for a gcc-specfic set of random number functions 3 | # ( at folly configure-time and if present defines 4 | # FOLLY_HAVE_EXTRANDOM_SFMT19937. This is used by folly/Random.h to 5 | # select the default random number generator to use, preferring 6 | # __gnu_cxx::sfmt19937 from if available. When using 7 | # Clang however, refers to GCC-specific typedefs 8 | # (__Uint32x4_t) which Clang doens't recognise and fails to 9 | # compile. 10 | # As such, modify folly-config.h under clang to not report 11 | # FOLLY_HAVE_EXTRANDOM_SFMT19937, so Random.h doesn't attempt to 12 | # use the problematic header. 13 | execute_process(COMMAND sed -i /FOLLY_HAVE_EXTRANDOM_SFMT19937/d ${CMAKE_CURRENT_SOURCE_DIR}/include/folly/folly-config.h) 14 | endif () 15 | -------------------------------------------------------------------------------- /deps/packages/glog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | ExternalProject_Add(glog 4 | GIT_REPOSITORY ${_git_repo} 5 | GIT_TAG ${_git_rev} 6 | BUILD_IN_SOURCE 1 7 | CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install 8 | -D CMAKE_BUILD_TYPE=RelWithDebInfo 9 | -D BUILD_SHARED_LIBS=OFF 10 | 11 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 12 | INSTALL_COMMAND $(MAKE) install 13 | ) 14 | 15 | # Additionally build a Debug variant on Windows, as for a debug build of 16 | # CB Server we need all dependancies _also_ linked against Debug CRT. 17 | if (WIN32) 18 | ExternalProject_Add(glog_WinDebugCRT 19 | GIT_REPOSITORY ${_git_repo} 20 | GIT_TAG ${_git_rev} 21 | BUILD_IN_SOURCE 1 22 | CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install 23 | -D CMAKE_BUILD_TYPE=Debug 24 | -D BUILD_SHARED_LIBS=OFF 25 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 26 | ) 27 | ExternalProject_Add_StepDependencies(glog download glog_WinDebugCRT) 28 | endif() 29 | 30 | # cbdeps boilerplate 31 | _ADD_PACKAGE_STEP() 32 | -------------------------------------------------------------------------------- /deps/packages/googletest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | list(APPEND cache_args ${common_cmake_cache_args}) 3 | list(APPEND cache_args -DCMAKE_CXX_VISIBILITY_PRESET:STRING=hidden) 4 | list(APPEND cache_args -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON) 5 | 6 | ExternalProject_Add(googletest 7 | GIT_REPOSITORY ${_git_repo} 8 | GIT_TAG v${_git_rev} 9 | 10 | CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install 11 | -D CMAKE_BUILD_TYPE=RelWithDebInfo 12 | -D CMAKE_INSTALL_LIBDIR=lib 13 | -D CMAKE_CXX_STANDARD_REQUIRED=ON 14 | -D BUILD_SHARED_LIBS=OFF 15 | -D gtest_force_shared_crt=ON 16 | 17 | CMAKE_CACHE_ARGS ${cache_args} 18 | 19 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 20 | INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install 21 | COMMAND ${CMAKE_COMMAND} -E remove_directory /lib/pkgconfig) 22 | 23 | # cbdeps boilerplate 24 | _ADD_PACKAGE_STEP() 25 | -------------------------------------------------------------------------------- /deps/packages/grpc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of grpc source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | # Expand grpc's deps to a separate install directory so we don't end up 6 | # packaging them up in the grpc cbdep itself. 7 | set(_orig_install_prefix "${CMAKE_INSTALL_PREFIX}") 8 | set(_deps_install "${CMAKE_CURRENT_BINARY_DIR}/dep-install") 9 | set(CMAKE_INSTALL_PREFIX "${_deps_install}") 10 | 11 | # Install grpc's prereqs that we already provide 12 | DECLARE_DEP (openssl V2 VERSION 3.1.4 BUILD 1 PLATFORMS linux macosx windows) 13 | DECLARE_DEP (zlib V2 VERSION 1.2.13 BUILD 2 PLATFORMS linux macosx windows) 14 | 15 | # Restore the INSTALL_PREFIX 16 | set(CMAKE_INSTALL_PREFIX ${_orig_install_prefix}) 17 | 18 | ### Download, configure and build grpc ################################## 19 | IF (WIN32) 20 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_windows.bat) 21 | ELSE () 22 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_unix.sh) 23 | ENDIF () 24 | SET (_install_dir "${CMAKE_BINARY_DIR}/install") 25 | FILE (TO_NATIVE_PATH "${_install_dir}" _install_dir) 26 | 27 | ExternalProject_Add (${_dep_package} 28 | GIT_REPOSITORY ${_git_repo} 29 | GIT_TAG ${_git_rev} 30 | CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E make_directory 31 | BUILD_COMMAND "${_build_script}" ${PLATFORM} "${_dep_version}" "${CMAKE_CURRENT_BINARY_DIR}" 32 | BUILD_IN_SOURCE 1 33 | INSTALL_DIR "${_install_dir}" 34 | INSTALL_COMMAND "" 35 | ) 36 | 37 | # cbdeps boilerplate 38 | _ADD_PACKAGE_STEP() 39 | -------------------------------------------------------------------------------- /deps/packages/grpc/grpc_unix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | # Copyright 2018-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | INSTALL_DIR=$1 12 | PLATFORM=$2 13 | VERSION=$3 14 | CBDEPS_DIR=$4 15 | 16 | # Build and install abseil, cares and protobuf from third_party 17 | cd third_party/abseil-cpp 18 | 19 | # Fix missing include - in a way that doesn't break on mac's sed 20 | sed '/#include /a\ 21 | #include 22 | ' ./absl/time/civil_time_test.cc > ./absl/time/civil_time_test.cc.fixed 23 | mv ./absl/time/civil_time_test.cc.fixed ./absl/time/civil_time_test.cc 24 | 25 | mkdir build 26 | cd build 27 | cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 28 | -DABSL_BUILD_TESTING=ON \ 29 | -DABSL_PROPAGATE_CXX_STD=ON \ 30 | -DABSL_USE_GOOGLETEST_HEAD=ON \ 31 | -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ 32 | -DCMAKE_INSTALL_LIBDIR=lib \ 33 | .. 34 | make -j8 install 35 | cd ../../.. 36 | 37 | cd third_party/protobuf/cmake 38 | mkdir build 39 | cd build 40 | cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 41 | -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ 42 | -DCMAKE_INSTALL_LIBDIR=lib \ 43 | -DABSL_PROPAGATE_CXX_STD=ON \ 44 | -Dprotobuf_BUILD_TESTS=OFF \ 45 | -D CMAKE_PREFIX_PATH="${CBDEPS_DIR}/zlib.exploded" \ 46 | ../.. 47 | make -j8 install 48 | cd ../../../.. 49 | 50 | cd third_party/cares/cares 51 | mkdir build 52 | cd build 53 | cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo \ 54 | -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ 55 | -DCMAKE_INSTALL_LIBDIR=lib \ 56 | -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_SHARED=OFF \ 57 | .. 58 | make -j8 install 59 | cd ../../../.. 60 | 61 | # Build grpc binaries and libraries 62 | mkdir .build 63 | cd .build 64 | cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo \ 65 | -D CMAKE_INSTALL_PREFIX=${INSTALL_DIR} \ 66 | -D CMAKE_INSTALL_LIBDIR=lib \ 67 | -D CMAKE_PREFIX_PATH="${CBDEPS_DIR}/zlib.exploded;${CBDEPS_DIR}/openssl.exploded;${INSTALL_DIR}" \ 68 | -D absl_DIR="${INSTALL_DIR}/../grpc/grpc-prefix/src/grpc/third_party/abseil-cpp" \ 69 | -DgRPC_INSTALL=ON \ 70 | -DgRPC_BUILD_TESTS=OFF \ 71 | -DgRPC_ABSL_PROVIDER=package \ 72 | -DgRPC_PROTOBUF_PROVIDER=package \ 73 | -DgRPC_ZLIB_PROVIDER=package \ 74 | -DgRPC_CARES_PROVIDER=package \ 75 | -DgRPC_SSL_PROVIDER=package \ 76 | .. 77 | make -j8 install 78 | 79 | exit 0 80 | -------------------------------------------------------------------------------- /deps/packages/grpc/grpc_windows.bat: -------------------------------------------------------------------------------- 1 | set INSTALL_DIR=%1 2 | set PLATFORM=%2 3 | set VERSION=%3 4 | set CBDEPS_DIR=%4 5 | 6 | rem Build and install abseil, cares and protobuf from third_party 7 | cd third_party/abseil-cpp 8 | 9 | rem Fix missing iomanip include 10 | setlocal enabledelayedexpansion 11 | set "inputfile=.\absl\time\civil_time_test.cc" 12 | set "outputfile=.\absl\time\civil_time_test.cc.fixed" 13 | set "missing_include=#include ^" 14 | findstr /m /c:"%missing_include%" "%inputfile%" 15 | if %errorlevel%==1 ( 16 | ( 17 | echo %missing_include% 18 | type "%inputfile%" 19 | ) > "%outputfile%" 20 | ) 21 | move /Y "%outputfile%" "%inputfile%" 22 | type "%inputfile%" 23 | endlocal 24 | 25 | mkdir build 26 | cd build 27 | cmake -G Ninja ^ 28 | -DCMAKE_CXX_STANDARD=17 ^ 29 | -DCMAKE_BUILD_TYPE=RelWithDebInfo ^ 30 | -DABSL_BUILD_TESTING=OFF ^ 31 | -DABSL_PROPAGATE_CXX_STD=ON ^ 32 | -DABSL_USE_GOOGLETEST_HEAD=ON ^ 33 | -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^ 34 | -DCMAKE_INSTALL_LIBDIR=lib ^ 35 | .. || goto error 36 | ninja install || goto error 37 | cd ../../.. 38 | 39 | cd third_party\protobuf\cmake 40 | mkdir build 41 | cd build 42 | cmake -G Ninja ^ 43 | -DCMAKE_CXX_STANDARD=17 ^ 44 | -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl ^ 45 | -DCMAKE_BUILD_TYPE=RelWithDebInfo ^ 46 | -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%" ^ 47 | -DCMAKE_INSTALL_LIBDIR=lib ^ 48 | -Dprotobuf_ABSL_PROVIDER=package ^ 49 | -Dprotobuf_BUILD_TESTS=OFF ^ 50 | -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ^ 51 | -DCMAKE_PREFIX_PATH="%CBDEPS_DIR%/zlib.exploded;%INSTALL_DIR%" ^ 52 | ../.. || goto error 53 | ninja install || goto error 54 | cd ..\..\..\.. 55 | 56 | cd third_party\cares\cares 57 | mkdir build 58 | cd build 59 | cmake -G Ninja ^ 60 | -DCMAKE_CXX_STANDARD=17 ^ 61 | -DCMAKE_C_COMPILER=cl ^ 62 | -DCMAKE_BUILD_TYPE=RelWithDebInfo ^ 63 | -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^ 64 | -DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_SHARED=OFF ^ 65 | .. || goto error 66 | ninja install || goto error 67 | cd ..\..\..\.. 68 | 69 | rem Build grpc binaries and libraries 70 | rem Protobuf_USE_STATIC_LIBS necessary due to bug in CMake: 71 | rem https://gitlab.kitware.com/paraview/paraview/issues/19527 72 | mkdir .build 73 | cd .build 74 | cmake -G Ninja ^ 75 | -DCMAKE_CXX_STANDARD=17 ^ 76 | -D CMAKE_C_COMPILER=cl -D CMAKE_CXX_COMPILER=cl ^ 77 | -D CMAKE_BUILD_TYPE=RelWithDebInfo ^ 78 | -D "CMAKE_INSTALL_PREFIX=%INSTALL_DIR%" ^ 79 | -D "CMAKE_PREFIX_PATH=%CBDEPS_DIR%/zlib.exploded;%CBDEPS_DIR%/openssl.exploded;%INSTALL_DIR%" ^ 80 | -DABSL_PROPAGATE_CXX_STD=ON ^ 81 | -DgRPC_INSTALL=ON ^ 82 | -DgRPC_BUILD_TESTS=OFF ^ 83 | -DgRPC_PROTOBUF_PROVIDER=package ^ 84 | -DgRPC_ZLIB_PROVIDER=package ^ 85 | -DgRPC_CARES_PROVIDER=package ^ 86 | -DgRPC_SSL_PROVIDER=package ^ 87 | -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF ^ 88 | -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF ^ 89 | -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF ^ 90 | -DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF ^ 91 | -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF ^ 92 | .. || goto error 93 | ninja install || goto error 94 | 95 | goto :eof 96 | 97 | :error 98 | echo Failed with error %ERRORLEVEL% 99 | exit /B %ERRORLEVEL% 100 | -------------------------------------------------------------------------------- /deps/packages/icu4c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF (WIN32) 2 | INCLUDE ("icu4c_windows.cmake") 3 | ELSE () 4 | INCLUDE ("icu4c_unix.cmake") 5 | ENDIF() 6 | 7 | # cbdeps boilerplate 8 | _ADD_PACKAGE_STEP() 9 | -------------------------------------------------------------------------------- /deps/packages/icu4c/check_xlocale_h.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | set -x 12 | 13 | if [ $(uname -s) = "Darwin" ]; then 14 | XLOCALE_FILE=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/xlocale.h 15 | else 16 | XLOCALE_FILE=/usr/include/xlocale.h 17 | fi 18 | 19 | LOCALE_FILE=/usr/include/locale.h 20 | 21 | if [ ! -e ${XLOCALE_FILE} ]; then 22 | echo "$XLOCALE_FILE does not exist!" 23 | echo "Creating symlink for $XLOCALE_FILE ..." 24 | ln -s ${LOCALE_FILE} ${XLOCALE_FILE} 25 | fi 26 | -------------------------------------------------------------------------------- /deps/packages/icu4c/icu4c_mac.patch: -------------------------------------------------------------------------------- 1 | diff --git a/source/config/mh-darwin b/source/config/mh-darwin 2 | index e4ad4623..7b15709c 100644 3 | --- a/source/config/mh-darwin 4 | +++ b/source/config/mh-darwin 5 | @@ -33,7 +33,7 @@ SHLIB.cc= $(CXX) -dynamiclib -dynamic $(CXXFLAGS) $(LDFLAGS) $(LD_SOOPTIONS) 6 | ifeq ($(ENABLE_RPATH),YES) 7 | LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(libdir)/$(notdir $(MIDDLE_SO_TARGET)) 8 | else 9 | -LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(notdir $(MIDDLE_SO_TARGET)) 10 | +LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR) -Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(notdir $(MIDDLE_SO_TARGET)) $(PKGDATA_TRAILING_SPACE) 11 | endif 12 | 13 | ## Compiler switch to embed a runtime search path 14 | diff --git a/source/config/pkgdataMakefile.in b/source/config/pkgdataMakefile.in 15 | index 7bf24cc6..66a63b6f 100644 16 | --- a/source/config/pkgdataMakefile.in 17 | +++ b/source/config/pkgdataMakefile.in 18 | @@ -16,6 +16,7 @@ include $(top_builddir)/icudefs.mk 19 | 20 | OUTPUTFILE=pkgdata.inc 21 | MIDDLE_SO_TARGET= 22 | +PKGDATA_TRAILING_SPACE=" " 23 | 24 | all : clean 25 | @echo GENCCODE_ASSEMBLY_TYPE=$(GENCCODE_ASSEMBLY) >> $(OUTPUTFILE) 26 | diff --git a/source/data/pkgdataMakefile.in b/source/data/pkgdataMakefile.in 27 | index 4e21d03c..cd543b0f 100644 28 | --- a/source/data/pkgdataMakefile.in 29 | +++ b/source/data/pkgdataMakefile.in 30 | @@ -16,6 +16,7 @@ include $(top_builddir)/icudefs.mk 31 | 32 | OUTPUTFILE=icupkg.inc 33 | MIDDLE_SO_TARGET= 34 | +PKGDATA_TRAILING_SPACE=" " 35 | 36 | all : clean 37 | @echo GENCCODE_ASSEMBLY_TYPE=$(GENCCODE_ASSEMBLY) >> $(OUTPUTFILE) 38 | diff --git a/source/extra/uconv/pkgdataMakefile.in b/source/extra/uconv/pkgdataMakefile.in 39 | index c5916f2a..f8a684fc 100644 40 | --- a/source/extra/uconv/pkgdataMakefile.in 41 | +++ b/source/extra/uconv/pkgdataMakefile.in 42 | @@ -14,9 +14,9 @@ top_builddir = ../.. 43 | ## All the flags and other definitions are included here. 44 | include $(top_builddir)/icudefs.mk 45 | 46 | -MIDDLE_SO_TARGET= 47 | - 48 | OUTPUTFILE=pkgdata.inc 49 | +MIDDLE_SO_TARGET= 50 | +PKGDATA_TRAILING_SPACE=" " 51 | 52 | all : clean 53 | @echo GENCCODE_ASSEMBLY_TYPE=$(GENCCODE_ASSEMBLY) >> $(OUTPUTFILE) 54 | diff --git a/source/test/testdata/pkgdataMakefile.in b/source/test/testdata/pkgdataMakefile.in 55 | index c5916f2a..f8a684fc 100644 56 | --- a/source/test/testdata/pkgdataMakefile.in 57 | +++ b/source/test/testdata/pkgdataMakefile.in 58 | @@ -14,9 +14,9 @@ top_builddir = ../.. 59 | ## All the flags and other definitions are included here. 60 | include $(top_builddir)/icudefs.mk 61 | 62 | -MIDDLE_SO_TARGET= 63 | - 64 | OUTPUTFILE=pkgdata.inc 65 | +MIDDLE_SO_TARGET= 66 | +PKGDATA_TRAILING_SPACE=" " 67 | 68 | all : clean 69 | @echo GENCCODE_ASSEMBLY_TYPE=$(GENCCODE_ASSEMBLY) >> $(OUTPUTFILE) 70 | diff --git a/source/tools/pkgdata/pkgdata.cpp b/source/tools/pkgdata/pkgdata.cpp 71 | index ffcf459c..53c401d9 100644 72 | --- a/source/tools/pkgdata/pkgdata.cpp 73 | +++ b/source/tools/pkgdata/pkgdata.cpp 74 | @@ -544,6 +544,7 @@ normal_command_mode: 75 | int result = system(cmd); 76 | if (result != 0) { 77 | fprintf(stderr, "-- return status = %d\n", result); 78 | + result = 1; // system() result code is platform specific. 79 | } 80 | 81 | if (cmd != cmdBuffer && cmd != command) { 82 | -------------------------------------------------------------------------------- /deps/packages/icu4c/icu4c_unix.cmake: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of icu4c source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | # For APPLE we anyway set rpaths using install_name_tool below 6 | 7 | # Apply mac patch for ICU-20526 "fix pkgdata where LD_SONAME has a trailing space" 8 | # https://github.com/unicode-org/icu/commit/1c553b9cf28d25c0aaf961c5f587f4ad3cee2679 9 | # https://github.com/unicode-org/icu/commit/83a0542b5b52a30b7af736f5ef6b0405f6582867 10 | 11 | if (APPLE) 12 | SET(_rpath_options "") 13 | SET(_rpath-link_options "") 14 | SET(patch_command PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/icu4c_mac.patch) 15 | else (APPLE) 16 | SET(_rpath_options "--enable-rpath") 17 | SET(_rpath-link_options "--enable-rpath-link") 18 | unset(patch_command) 19 | endif (APPLE) 20 | ### Download, configure and build icu4c #################################### 21 | _DETERMINE_CPU_COUNT(_parallelism) 22 | ExternalProject_Add(icu4c 23 | GIT_REPOSITORY ${_git_repo} 24 | GIT_TAG ${_git_rev} 25 | 26 | ${patch_command} 27 | 28 | CONFIGURE_COMMAND sudo "${CMAKE_CURRENT_SOURCE_DIR}/check_xlocale_h.sh" 29 | COMMAND /source/configure LDFLAGS=${ICU_LDFLAGS} 30 | --prefix= 31 | --disable-extras 32 | --disable-layout 33 | --disable-tests 34 | --disable-samples 35 | ${_rpath_options} 36 | ${_rpath-link_options} 37 | BUILD_COMMAND $(MAKE) -j${_parallelism} all 38 | 39 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 40 | INSTALL_COMMAND $(MAKE) install 41 | COMMAND ${CMAKE_COMMAND} -E remove_directory /bin 42 | COMMAND ${CMAKE_COMMAND} -E remove_directory /sbin 43 | COMMAND ${CMAKE_COMMAND} -E remove_directory /share 44 | 45 | COMMAND ${CMAKE_COMMAND} -E echo "FILE(COPY lib DESTINATION \${CMAKE_INSTALL_PREFIX})" >> /CMakeLists.txt 46 | ) 47 | 48 | # OS X-only: Custom post-build step to set the shared library install name. 49 | if (APPLE) 50 | ExternalProject_Add_Step(icu4c install_name 51 | # Fixup all libraries 52 | COMMAND install_name_tool -id @rpath/libicudata.59.1.dylib lib/libicudata.59.1.dylib 53 | COMMAND install_name_tool -id @rpath/libicui18n.59.1.dylib 54 | -change libicuuc.59.dylib @loader_path/libicuuc.59.dylib 55 | -change libicudata.59.dylib @loader_path/libicudata.59.dylib 56 | lib/libicui18n.59.1.dylib 57 | COMMAND install_name_tool -id @rpath/libicuio.59.1.dylib 58 | -change libicuuc.59.dylib @loader_path/libicuuc.59.dylib 59 | -change ../lib/libicudata.59.1.dylib @loader_path/libicudata.59.1.dylib 60 | -change libicui18n.59.dylib @loader_path/ibicui18n.59.dylib 61 | lib/libicuio.59.1.dylib 62 | COMMAND install_name_tool -id @rpath/libicutu.59.1.dylib 63 | -change libicui18n.59.dylib @loader_path/libicui18n.59.dylib 64 | -change libicuuc.59.dylib @loader_path/libicuuc.59.dylib 65 | -change libicudata.59.dylib @loader_path/libicudata.59.dylib 66 | lib/libicutu.59.1.dylib 67 | COMMAND install_name_tool -id @rpath/libicuuc.59.1.dylib 68 | -change libicudata.59.dylib @loader_path/libicudata.59.dylib 69 | lib/libicuuc.59.1.dylib 70 | DEPENDEES build 71 | DEPENDERS install 72 | WORKING_DIRECTORY 73 | ) 74 | endif(APPLE) 75 | -------------------------------------------------------------------------------- /deps/packages/icu4c/icu4c_windows.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | set INSTALL_DIR=%1 4 | 5 | cd win_binary 6 | mkdir tmp 7 | cd tmp 8 | cmake -E tar xf ..\icu4c-59_1-Win64-MSVC2015.zip 9 | 10 | xcopy /I bin64 %INSTALL_DIR%\bin 11 | xcopy /I lib64 %INSTALL_DIR%\lib 12 | xcopy /I /E include %INSTALL_DIR%\include 13 | -------------------------------------------------------------------------------- /deps/packages/icu4c/icu4c_windows.cmake: -------------------------------------------------------------------------------- 1 | # "Builds" icu4c for Windows (actually repackages binary) 2 | 3 | include(ExternalProject) 4 | 5 | SET (_install_dir "${CMAKE_BINARY_DIR}/install") 6 | FILE (TO_NATIVE_PATH "${_install_dir}" _install_dir) 7 | 8 | SET (_build_script "${CMAKE_CURRENT_SOURCE_DIR}/icu4c_windows.bat") 9 | ### Download, configure and build icu4c #################################### 10 | ExternalProject_Add(icu4c 11 | GIT_REPOSITORY ${_git_repo} 12 | GIT_TAG ${_git_rev} 13 | 14 | CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo do be do be 15 | BUILD_COMMAND ${CMAKE_COMMAND} -E echo dooooo 16 | BUILD_IN_SOURCE 1 17 | INSTALL_DIR "${_install_dir}" 18 | INSTALL_COMMAND ${_build_script} 19 | 20 | COMMAND ${CMAKE_COMMAND} -E echo FILE "(COPY bin lib include DESTINATION \"\${CMAKE_INSTALL_PREFIX}\")" > /CMakeLists.txt 21 | ) 22 | -------------------------------------------------------------------------------- /deps/packages/json/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of the JSON library and package it. 2 | # The JSON library is a "header only" library, so we don't need any 3 | # building 4 | 5 | include(ExternalProject) 6 | 7 | ExternalProject_Add(json 8 | GIT_REPOSITORY ${_git_repo} 9 | GIT_TAG ${_git_rev} 10 | 11 | CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install 12 | -D CMAKE_BUILD_TYPE=RelWithDebInfo 13 | -D JSON_BuildTests=OFF 14 | -D JSON_DisableEnumSerialization=ON 15 | -D JSON_Install=ON 16 | -D JSON_MultipleHeaders=ON 17 | -D JSON_SystemInclude=ON 18 | 19 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 20 | INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install 21 | COMMAND ${CMAKE_COMMAND} -E remove_directory /lib/pkgconfig) 22 | 23 | # cbdeps boilerplate 24 | _ADD_PACKAGE_STEP() 25 | -------------------------------------------------------------------------------- /deps/packages/libcxx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of libcxx and libcxxabi source code and builds it. 2 | # As a bit of a cheat, we assume we can check out the same branch of libcxxabi as 3 | # is specified for libcxx (so don't specify a particular commit SHA). 4 | 5 | # Note: These steps are pretty hard-coded to values for Ubuntu. 6 | 7 | include(ExternalProject) 8 | 9 | # Final output directory 10 | SET (INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/install") 11 | 12 | 13 | ### Download, configure and build libcxxabi #################################### 14 | ExternalProject_Add(libcxxabi 15 | GIT_REPOSITORY https://github.com/couchbasedeps/libcxxabi.git 16 | GIT_TAG ${_git_rev} 17 | 18 | PREFIX libcxxabi 19 | 20 | # "Update" command - libcxxabi depends on the libcxx source code 21 | # (includes), but we can't just build libcxx first because it 22 | # depends on libcxxabi.so. So, we download libcxx again. 23 | UPDATE_COMMAND echo ${CMAKE_CURRENT_BINARY_DIR} 24 | COMMAND git clone https://github.com/couchbasedeps/libcxx 25 | ${CMAKE_CURRENT_BINARY_DIR}/libcxx-copy --single-branch -b ${_git_rev} 26 | 27 | # Configure step 28 | CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release 29 | -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} 30 | -DLIBCXXABI_LIBCXX_INCLUDES=${CMAKE_CURRENT_BINARY_DIR}/libcxx-copy/include 31 | -DLIBCXXABI_ENABLE_STATIC=OFF 32 | 33 | BUILD_COMMAND $(MAKE) -j4 34 | 35 | # We install both the lib and include files - libcxxapi by itself 36 | # only installs the lib, but since libcxx needs the include too 37 | # it makes sense to install both. 38 | INSTALL_DIR ${INSTALL_DIR} 39 | INSTALL_COMMAND $(MAKE) install 40 | COMMAND ${CMAKE_COMMAND} -E copy_directory /include /include 41 | ) 42 | 43 | ### Download, configure and build libcxx #################################### 44 | ExternalProject_Add(libcxx 45 | GIT_REPOSITORY ${_git_repo} 46 | GIT_TAG ${_git_rev} 47 | DEPENDS libcxxabi 48 | 49 | PREFIX libcxx 50 | 51 | # Configure step 52 | CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release 53 | -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} 54 | -DLIBCXX_CXX_ABI=libcxxabi 55 | -DLIBCXX_CXX_ABI_INCLUDE_PATHS=${INSTALL_DIR}/include 56 | -DLIBCXX_CXX_ABI_LIBRARY_PATH=${INSTALL_DIR}/lib 57 | 58 | BUILD_COMMAND $(MAKE) -j4 59 | 60 | INSTALL_DIR ${INSTALL_DIR} 61 | INSTALL_COMMAND $(MAKE) install 62 | COMMAND ${CMAKE_COMMAND} -E echo FILE "(COPY lib DESTINATION \"\${CMAKE_INSTALL_PREFIX}\")" > /CMakeLists.txt 63 | ) 64 | 65 | # cbdeps boilerplate 66 | _ADD_PACKAGE_STEP() 67 | -------------------------------------------------------------------------------- /deps/packages/libevent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of libevent source code and builds it. 2 | 3 | # We bundle OpenSSL, and we want support for OpenSSL in libevent 4 | # so we need to install the OpenSSL Package 5 | 6 | set(_openssl_install "${CMAKE_CURRENT_BINARY_DIR}/unused") 7 | set(_orig_install_prefix "${CMAKE_INSTALL_PREFIX}") 8 | set(CMAKE_INSTALL_PREFIX "${_openssl_install}") 9 | 10 | declare_dep(openssl V2 VERSION 3.1.1 BUILD 1 PLATFORMS linux macosx windows) 11 | 12 | set(CMAKE_INSTALL_PREFIX "${_orig_install_prefix}") 13 | 14 | set(_libevent_extra_options -D "OPENSSL_ROOT_DIR=${CMAKE_BINARY_DIR}/libevent/openssl.exploded") 15 | 16 | if (APPLE) 17 | # CMake is supposed to fix this for us, but for some reason libevent 18 | # does this incorrect (it get replaced as part of make install, and is 19 | # why we don't use the ExternalProject_Add_Step as it happens _before_ 20 | # make install and the values get stripped again. 21 | set(_libevent_extra_install_options 22 | COMMAND install_name_tool -id @rpath/libevent-2.1.7.dylib /lib/libevent-2.1.7.dylib 23 | COMMAND install_name_tool -id @rpath/libevent_core-2.1.7.dylib /lib/libevent_core-2.1.7.dylib 24 | COMMAND install_name_tool -id @rpath/libevent_extra-2.1.7.dylib /lib/libevent_extra-2.1.7.dylib 25 | COMMAND install_name_tool -change /lib/libevent_core-2.1.7.dylib @rpath/libevent_core-2.1.7.dylib /lib/libevent_extra-2.1.7.dylib 26 | 27 | COMMAND install_name_tool -id @rpath/libevent_openssl-2.1.7.dylib /lib/libevent_openssl-2.1.7.dylib 28 | COMMAND install_name_tool -change /lib/libevent_core-2.1.7.dylib @rpath/libevent_core-2.1.7.dylib /lib/libevent_openssl-2.1.7.dylib 29 | COMMAND install_name_tool -id @rpath/libevent_pthreads-2.1.7.dylib /lib/libevent_pthreads-2.1.7.dylib 30 | COMMAND install_name_tool -change /lib/libevent_core-2.1.7.dylib @rpath/libevent_core-2.1.7.dylib /lib/libevent_pthreads-2.1.7.dylib 31 | ) 32 | elseif(UNIX) 33 | # We want to set the RUNPATH to ${ORIGIN} to make sure that it search 34 | # the current directory first for the dependencies (openssl etc) 35 | set(_libevent_extra_options 36 | ${_libevent_extra_options} 37 | -DCMAKE_INSTALL_RPATH=\$ORIGIN/../lib) 38 | 39 | # We don't want all of the archives to be present 40 | set(_libevent_extra_install_options 41 | COMMAND ${CMAKE_COMMAND} -E remove -f /lib/libevent.a 42 | COMMAND ${CMAKE_COMMAND} -E remove -f /lib/libevent_core.a 43 | COMMAND ${CMAKE_COMMAND} -E remove -f /lib/libevent_extra.a 44 | COMMAND ${CMAKE_COMMAND} -E remove -f /lib/libevent_openssl.a 45 | COMMAND ${CMAKE_COMMAND} -E remove -f /lib/libevent_pthreads.a) 46 | endif() 47 | 48 | set(_libevent_build_type RelWithDebInfo) 49 | 50 | include(ExternalProject) 51 | 52 | # Skip tests on Windows (some fail). 53 | if (WIN32) 54 | set (test_step) 55 | else() 56 | set(test_step "TEST_BEFORE_INSTALL 1") 57 | endif() 58 | 59 | ### Download, configure and build libevent #################################### 60 | ExternalProject_Add(libevent 61 | GIT_REPOSITORY ${_git_repo} 62 | GIT_TAG ${_git_rev} 63 | 64 | CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install 65 | -D CMAKE_BUILD_TYPE=${_libevent_build_type} 66 | -D EVENT__DISABLE_BENCHMARK=ON 67 | -D EVENT__DISABLE_REGRESS=ON 68 | -D EVENT__DISABLE_SAMPLES=ON 69 | ${_libevent_extra_options} 70 | 71 | ${test_step} 72 | 73 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 74 | INSTALL_COMMAND $(MAKE) install 75 | COMMAND ${CMAKE_COMMAND} -E remove -f /lib/cmake 76 | COMMAND ${CMAKE_COMMAND} -E remove_directory /lib/pkgconfig 77 | COMMAND ${CMAKE_COMMAND} -E remove_directory /lib/cmake 78 | COMMAND ${CMAKE_COMMAND} -E remove_directory /bin 79 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_package.txt /CMakeLists.txt 80 | ${_libevent_extra_install_options} 81 | ) 82 | 83 | # cbdeps boilerplate 84 | _ADD_PACKAGE_STEP() 85 | -------------------------------------------------------------------------------- /deps/packages/libevent/CMakeLists_package.txt: -------------------------------------------------------------------------------- 1 | # Install the libraries to the lib directory. On windows the dll's should 2 | # go in the bin directory (same directory as the executable or in the PATH) 3 | # to be found by the runtime linker during program startup 4 | if (WIN32) 5 | # The .lib files should go in the lib directory 6 | FILE(COPY lib/event_core.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) 7 | FILE(COPY lib/event_extra.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) 8 | FILE(COPY lib/event.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) 9 | FILE(COPY lib/event_openssl.lib DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) 10 | 11 | # The dll's should go in the bin directory 12 | if (NOT EXISTS ${CMAKE_INSTALL_PREFIX}/bin) 13 | FILE(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin) 14 | endif() 15 | 16 | FILE(COPY lib/event_core.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 17 | FILE(COPY lib/event.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 18 | FILE(COPY lib/event_extra.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 19 | FILE(COPY lib/event_openssl.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) 20 | else (WIN32) 21 | FILE (COPY lib DESTINATION ${CMAKE_INSTALL_PREFIX}) 22 | endif (WIN32) 23 | -------------------------------------------------------------------------------- /deps/packages/libsqlite3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of liblibsqlite3 source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | # Use OS-provided libsqlite3 on MacOS. 6 | IF (APPLE) 7 | ADD_CUSTOM_TARGET (libsqlite3 8 | COMMAND "${CMAKE_COMMAND}" -E echo "Skipping packaging - use MacOS-provided libsqlite" 9 | ) 10 | ELSE (APPLE) 11 | 12 | ### Download, configure and build libsqlite3 #################################### 13 | ExternalProject_Add(libsqlite3 14 | GIT_REPOSITORY ${_git_repo} 15 | GIT_TAG ${_git_rev} 16 | 17 | BUILD_IN_SOURCE 1 18 | CONFIGURE_COMMAND /configure --prefix= 19 | 20 | BUILD_COMMAND $(MAKE) 21 | 22 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 23 | INSTALL_COMMAND $(MAKE) install 24 | 25 | COMMAND ${CMAKE_COMMAND} -E echo FILE "(COPY bin lib include DESTINATION \"\${CMAKE_INSTALL_PREFIX}\")" > /CMakeLists.txt 26 | ) 27 | 28 | # OS X-only: Custom post-build step to set the shared library install name. 29 | if (APPLE) 30 | ExternalProject_Add_Step(libsqlite3 install_name 31 | COMMAND install_name_tool -id @rpath/liblibsqlite3.2.dylib lib/liblibsqlite3.2.dylib 32 | 33 | DEPENDEES build 34 | DEPENDERS install 35 | WORKING_DIRECTORY 36 | ) 37 | endif(APPLE) 38 | 39 | # cbdeps boilerplate 40 | _ADD_PACKAGE_STEP() 41 | 42 | ENDIF (APPLE) 43 | -------------------------------------------------------------------------------- /deps/packages/libuv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of libuv source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | IF (WIN32) 6 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/libuv_windows.bat) 7 | ELSE () 8 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/libuv_unix.sh) 9 | ENDIF () 10 | 11 | SET (_install_dir "${CMAKE_BINARY_DIR}/install") 12 | FILE (TO_NATIVE_PATH "${_install_dir}" _install_dir) 13 | 14 | ### Download, configure and build libuv #################################### 15 | ExternalProject_Add(libuv 16 | GIT_REPOSITORY ${_git_repo} 17 | GIT_TAG ${_git_rev} 18 | 19 | CONFIGURE_COMMAND "" 20 | BUILD_COMMAND "${_build_script}" 21 | BUILD_IN_SOURCE 1 22 | INSTALL_DIR "${_install_dir}" 23 | INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy 24 | "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_package.txt" 25 | /CMakeLists.txt 26 | ) 27 | 28 | # cbdeps boilerplate 29 | _ADD_PACKAGE_STEP() 30 | -------------------------------------------------------------------------------- /deps/packages/libuv/CMakeLists_package.txt: -------------------------------------------------------------------------------- 1 | FILE(COPY lib DESTINATION ${CMAKE_INSTALL_PREFIX}) 2 | IF (WIN32) 3 | FILE(COPY bin DESTINATION ${CMAKE_INSTALL_PREFIX}) 4 | ENDIF (WIN32) 5 | -------------------------------------------------------------------------------- /deps/packages/libuv/libuv_unix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | INSTALL_DIR=$1 12 | 13 | # Unix build without gyp 14 | ./autogen.sh || exit 1 15 | ./configure --disable-silent-rules --prefix=${INSTALL_DIR} || exit 1 16 | make && make install 17 | 18 | # For MacOS, tweak install_name 19 | if [ $(uname -s) = "Darwin" ]; then 20 | install_name_tool -id @rpath/libuv.1.dylib ${INSTALL_DIR}/lib/libuv.1.dylib 21 | fi 22 | -------------------------------------------------------------------------------- /deps/packages/libuv/libuv_windows.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | set INSTALL_DIR=%1 4 | 5 | set PYTHON=C:\Python27\python.exe 6 | set GYP_MSVS_VERSION=2015 7 | call .\vcbuild.bat release shared x64 8 | if errorlevel 1 exit /b 1 9 | 10 | @echo on 11 | mkdir %INSTALL_DIR%\lib 12 | mkdir %INSTALL_DIR%\bin 13 | copy .\Release\libuv.* %INSTALL_DIR%\lib 14 | move %INSTALL_DIR%\lib\libuv.dll %INSTALL_DIR%\bin 15 | mkdir %INSTALL_DIR%\include 16 | copy .\include\*.h %INSTALL_DIR%\include\*.h 17 | -------------------------------------------------------------------------------- /deps/packages/maven/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of Maven binary tarball and "build" 2 | 3 | include(ExternalProject) 4 | 5 | ### Download, configure and build Maven ################################## 6 | IF (WIN32) 7 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_windows.bat) 8 | ELSE () 9 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_unix.sh) 10 | ENDIF () 11 | SET (_install_dir "${CMAKE_BINARY_DIR}/install") 12 | FILE (TO_NATIVE_PATH "${_install_dir}" _install_dir) 13 | 14 | ExternalProject_Add (${_dep_package} 15 | GIT_REPOSITORY ${_git_repo} 16 | GIT_TAG ${_git_rev} 17 | CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E make_directory 18 | BUILD_COMMAND "${_build_script}" ${PLATFORM} "${_dep_version}" 19 | BUILD_IN_SOURCE 1 20 | INSTALL_DIR "${_install_dir}" 21 | INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy 22 | "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_package.txt" 23 | /CMakeLists.txt 24 | ) 25 | 26 | # cbdeps boilerplate 27 | _ADD_PACKAGE_STEP() 28 | -------------------------------------------------------------------------------- /deps/packages/maven/CMakeLists_package.txt: -------------------------------------------------------------------------------- 1 | # Nothing to do here, only exploded directory needed 2 | -------------------------------------------------------------------------------- /deps/packages/maven/maven_unix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | INSTALL_DIR=$1 12 | PLATFORM=$2 13 | VERSION=$3 14 | 15 | tar zxf apache-maven-${VERSION}-bin.tar.gz || exit 1 16 | cd apache-maven-${VERSION} || exit 1 17 | 18 | cp -pr bin ${INSTALL_DIR}/ || exit 1 19 | cp -pr boot ${INSTALL_DIR}/ || exit 1 20 | cp -pr conf ${INSTALL_DIR}/ || exit 1 21 | cp -pr lib ${INSTALL_DIR}/ || exit 1 22 | -------------------------------------------------------------------------------- /deps/packages/maven/maven_windows.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | set INSTALL_DIR=%1 4 | set PLATFORM=%2 5 | set VERSION=%3 6 | 7 | mkdir tmp 8 | cd tmp 9 | cmake -E tar xf ..\apache-maven-%VERSION%-bin.tar.gz 10 | cd apache-maven-%VERSION% 11 | 12 | xcopy /I /E bin %INSTALL_DIR%\bin 13 | xcopy /I /E boot %INSTALL_DIR%\boot 14 | xcopy /I /E conf %INSTALL_DIR%\conf 15 | xcopy /I /E lib %INSTALL_DIR%\lib 16 | -------------------------------------------------------------------------------- /deps/packages/numactl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of numactl source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | ### Download, configure and build numactl ################################## 6 | IF (WIN32) 7 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_windows.bat) 8 | ELSE () 9 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_unix.sh) 10 | ENDIF () 11 | SET (_install_dir "${CMAKE_BINARY_DIR}/install") 12 | FILE (TO_NATIVE_PATH "${_install_dir}" _install_dir) 13 | 14 | ExternalProject_Add (${_dep_package} 15 | GIT_REPOSITORY ${_git_repo} 16 | GIT_TAG ${_git_rev} 17 | CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E make_directory 18 | BUILD_COMMAND "${_build_script}" ${PLATFORM} "${_dep_version}" 19 | BUILD_IN_SOURCE 1 20 | INSTALL_DIR "${_install_dir}" 21 | INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy 22 | "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_package.txt" 23 | /CMakeLists.txt 24 | ) 25 | 26 | # cbdeps boilerplate 27 | _ADD_PACKAGE_STEP() 28 | -------------------------------------------------------------------------------- /deps/packages/numactl/CMakeLists_package.txt: -------------------------------------------------------------------------------- 1 | # No macOS/Windows to support, so no need for conditional 2 | FILE (COPY lib DESTINATION "${CMAKE_INSTALL_PREFIX}") 3 | 4 | SET_PROPERTY (GLOBAL APPEND PROPERTY CBDEPS_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") 5 | -------------------------------------------------------------------------------- /deps/packages/numactl/numactl_define.patch: -------------------------------------------------------------------------------- 1 | diff --git a/affinity.c b/affinity.c 2 | index 9fbd6af..5343df0 100644 3 | --- a/affinity.c 4 | +++ b/affinity.c 5 | @@ -39,6 +39,7 @@ 6 | #include 7 | #include 8 | #include 9 | #include 10 | +#include 11 | #include 12 | #include 13 | -------------------------------------------------------------------------------- /deps/packages/numactl/numactl_unix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | INSTALL_DIR=$1 12 | PLATFORM=$2 13 | VERSION=$3 14 | 15 | pushd `dirname $0` > /dev/null 16 | SCRIPTPATH=`pwd -P` 17 | popd > /dev/null 18 | 19 | ./autogen.sh || exit 1 20 | ./configure --prefix=${INSTALL_DIR} || exit 1 21 | git apply ${SCRIPTPATH}/numactl_define.patch 22 | make -j8 && make install 23 | rm -rf ${INSTALL_DIR}/bin ${INSTALL_DIR}/share 24 | -------------------------------------------------------------------------------- /deps/packages/numactl/numactl_windows.bat: -------------------------------------------------------------------------------- 1 | rem Windows not currently supported 2 | exit /B 1 3 | -------------------------------------------------------------------------------- /deps/packages/openjdk-rt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the OpenJDK rt.jar and packages it 2 | 3 | include(ExternalProject) 4 | 5 | ExternalProject_Add(openjdk-rt 6 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}" 7 | CONFIGURE_COMMAND "" 8 | BUILD_COMMAND ${CMAKE_COMMAND} -D OPENJDK_VER=${_dep_version} -D TARGET_DIR= -P "${CMAKE_CURRENT_SOURCE_DIR}/dl_rt_jar.cmake" 9 | INSTALL_COMMAND "" 10 | 11 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install) 12 | 13 | # cbdeps boilerplate 14 | _ADD_PACKAGE_STEP() 15 | -------------------------------------------------------------------------------- /deps/packages/openjdk-rt/dl_rt_jar.cmake: -------------------------------------------------------------------------------- 1 | SET (OPENJDK_RT_FILENAME "openjdk-${OPENJDK_VER}-rt.jar") 2 | SET (URL "http://nas-n.mgt.couchbase.com/builds/downloads/openjdk-rt/${OPENJDK_RT_FILENAME}") 3 | FILE (DOWNLOAD "${URL}" "${TARGET_DIR}/openjdk-rt.jar" STATUS _stat SHOW_PROGRESS) 4 | LIST (GET _stat 0 _retval) 5 | IF (_retval) 6 | # Don't leave corrupt/empty downloads 7 | IF (EXISTS "${file}") 8 | FILE (REMOVE "${file}") 9 | ENDIF (EXISTS "${file}") 10 | LIST (GET _stat 0 _errcode) 11 | LIST (GET _stat 1 _message) 12 | MESSAGE (FATAL_ERROR "Error downloading ${url}: ${_message} (${_errcode})") 13 | ENDIF (_retval) 14 | -------------------------------------------------------------------------------- /deps/packages/pcre/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of pcre source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | ### Download, configure and build pcre ################################## 6 | IF (WIN32) 7 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_windows.bat) 8 | ELSE () 9 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_unix.sh) 10 | ENDIF () 11 | SET (_install_dir "${CMAKE_BINARY_DIR}/install") 12 | FILE (TO_NATIVE_PATH "${_install_dir}" _install_dir) 13 | 14 | ExternalProject_Add (${_dep_package} 15 | GIT_REPOSITORY ${_git_repo} 16 | GIT_TAG ${_git_rev} 17 | CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E make_directory 18 | BUILD_COMMAND "${_build_script}" ${PLATFORM} "${_dep_version}" 19 | BUILD_IN_SOURCE 1 20 | INSTALL_DIR "${_install_dir}" 21 | INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy 22 | "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_package.txt" 23 | /CMakeLists.txt 24 | COMMAND ${CMAKE_COMMAND} -E remove_directory /lib/pkgconfig 25 | ) 26 | 27 | # cbdeps boilerplate 28 | _ADD_PACKAGE_STEP() 29 | -------------------------------------------------------------------------------- /deps/packages/pcre/CMakeLists_package.txt: -------------------------------------------------------------------------------- 1 | FILE (COPY bin lib DESTINATION "${CMAKE_INSTALL_PREFIX}") 2 | 3 | SET_PROPERTY (GLOBAL APPEND PROPERTY CBDEPS_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") 4 | -------------------------------------------------------------------------------- /deps/packages/pcre/pcre_unix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # Copyright 2019-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | INSTALL_DIR=$1 12 | PLATFORM=$2 13 | VERSION=$3 14 | 15 | export LDFLAGS="-Wl,-rpath,'\$\$ORIGIN/../lib'" 16 | 17 | ./autogen.sh || exit 1 18 | ./configure --prefix=${INSTALL_DIR} || exit 1 19 | make && make install 20 | 21 | # For MacOS, tweak install_name 22 | # There really MUST be a better way to do this 23 | if [ $(uname -s) = "Darwin" ]; then 24 | for libname in libpcre.1.dylib libpcrecpp.0.dylib libpcreposix.0.dylib; do 25 | install_name_tool -id @rpath/${libname} ${INSTALL_DIR}/lib/${libname} 26 | 27 | for deplib in libpcre.1.dylib libpcrecpp.0.dylib libpcreposix.0.dylib; do 28 | install_name_tool -change \ 29 | ${INSTALL_DIR}/lib/${deplib} \ 30 | @rpath/${deplib} \ 31 | ${INSTALL_DIR}/lib/${libname} 32 | done 33 | done 34 | fi 35 | -------------------------------------------------------------------------------- /deps/packages/pcre/pcre_windows.bat: -------------------------------------------------------------------------------- 1 | set INSTALL_DIR=%1 2 | 3 | rem Have to ensure we do NOT use MSVC 4 | 5 | rem Build pcre libraries 6 | md .build 7 | cd .build 8 | cmake .. -G "Ninja" ^ 9 | -D CMAKE_C_COMPILER=gcc ^ 10 | -D CMAKE_CXX_COMPILER=g++ ^ 11 | -D CMAKE_INSTALL_PREFIX=%INSTALL_DIR% ^ 12 | -D CMAKE_BUILD_TYPE=RelWithDebInfo ^ 13 | -D BUILD_SHARED_LIBS=ON || goto error 14 | ninja install || goto error 15 | 16 | rem Should be called libpcre.dll if built by MinGW 17 | if exist %INSTALL_DIR%\bin\pcre.dll ( 18 | echo "OH NO WE BUILT WITH MSVC" 19 | set ERRORLEVEL=5 20 | goto error 21 | ) 22 | goto :eof 23 | 24 | :error 25 | echo Failed with error %ERRORLEVEL% 26 | exit /B %ERRORLEVEL% 27 | -------------------------------------------------------------------------------- /deps/packages/prometheus-cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of prometheus-cpp source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | SET (_install_dir "${CMAKE_BINARY_DIR}/install") 6 | 7 | # Expand prometheus-cpp deps to a separate install directory so we don't end up 8 | # packaging them up in the cbdep itself. 9 | set(_orig_install_prefix "${CMAKE_INSTALL_PREFIX}") 10 | set(_deps_install "${CMAKE_CURRENT_BINARY_DIR}/dep-install") 11 | set(CMAKE_INSTALL_PREFIX "${_deps_install}") 12 | 13 | # Install prometheus-cpp prereqs that we already provide 14 | DECLARE_DEP (zlib V2 VERSION 1.2.13 BUILD 2 PLATFORMS linux macosx windows) 15 | 16 | # Restore the INSTALL_PREFIX 17 | set(CMAKE_INSTALL_PREFIX ${_orig_install_prefix}) 18 | 19 | ExternalProject_Add(${_dep_package} 20 | GIT_REPOSITORY ${_git_repo} 21 | GIT_TAG ${_git_rev} 22 | 23 | CMAKE_ARGS -DCMAKE_BUILD_TYPE=RelWithDebInfo 24 | -DCMAKE_INSTALL_PREFIX= 25 | -DBUILD_SHARED_LIBS=OFF 26 | -DGENERATE_PKGCONFIG=OFF 27 | -DENABLE_PUSH=OFF 28 | -DTHIRDPARTY_CIVETWEB_WITH_SSL=OFF 29 | -DRUN_IWYU=OFF 30 | -DENABLE_TESTING=OFF 31 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON 32 | -DZLIB_ROOT=${CMAKE_CURRENT_BINARY_DIR}/zlib.exploded 33 | 34 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 35 | ) 36 | 37 | # cbdeps boilerplate 38 | _ADD_PACKAGE_STEP() 39 | -------------------------------------------------------------------------------- /deps/packages/python-snappy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of python-snappy source code and builds it. 2 | 3 | # First, download the dependency: snappy itself. Set CMAKE_INSTALL_PREFIX 4 | # to a local directory to dump in there, and add that directory to CMAKE_PREFIX_PATH. 5 | SET (_snappy_install "${CMAKE_CURRENT_BINARY_DIR}/dep-install") 6 | SET (_orig_install_prefix "${CMAKE_INSTALL_PREFIX}") 7 | SET (CMAKE_INSTALL_PREFIX "${_snappy_install}") 8 | DECLARE_DEP (snappy VERSION 1.1.8-cb6 PLATFORMS linux macosx windows) 9 | SET (CMAKE_INSTALL_PREFIX "${_orig_install_prefix}") 10 | 11 | include(ExternalProject) 12 | 13 | ### Download, configure and build python-snappy #################################### 14 | ExternalProject_Add(python-snappy 15 | GIT_REPOSITORY ${_git_repo} 16 | GIT_TAG ${_git_rev} 17 | 18 | CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E echo Configuring python-snappy... 19 | 20 | BUILD_COMMAND python setup.py build build_ext 21 | -I "${_snappy_install}/include" -L "${_snappy_install}/lib" 22 | BUILD_IN_SOURCE 1 23 | 24 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 25 | INSTALL_COMMAND python setup.py install --install-lib /lib/python/pysnappy2 26 | 27 | COMMAND ${CMAKE_COMMAND} -E echo FILE "(COPY lib DESTINATION \"\${CMAKE_INSTALL_PREFIX}\")" > /CMakeLists.txt 28 | ) 29 | 30 | # cbdeps boilerplate 31 | _ADD_PACKAGE_STEP() 32 | -------------------------------------------------------------------------------- /deps/packages/snappy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of libsnappy source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | _DETERMINE_CPU_COUNT(_parallelism) 6 | 7 | ### Download, configure and build snappy #################################### 8 | ### snappy.patch is applied to address the following 9 | ### 1. Build failure for Clang 13.0+. 10 | ### https://groups.google.com/g/snappy-compression/c/zwzPUj_TKwY 11 | ### 2. RTTI is disabled by default in snappy 1.1.9. We need to comment this out. 12 | ### https://github.com/google/snappy/pull/147#issuecomment-1011335649 13 | 14 | ExternalProject_Add(snappy 15 | GIT_REPOSITORY ${_git_repo} 16 | GIT_TAG ${_git_rev} 17 | PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/snappy.patch 18 | CMAKE_ARGS -D CMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO} 19 | -D CMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO} 20 | -D CMAKE_INSTALL_LIBDIR=lib 21 | -D CMAKE_BUILD_TYPE=RelWithDebInfo 22 | -D BUILD_SHARED_LIBS=ON 23 | -D SNAPPY_HAVE_BMI2=NO 24 | -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install 25 | -D TEST_BEFORE_INSTALL=OFF 26 | -D SNAPPY_BUILD_BENCHMARKS=OFF 27 | -D SNAPPY_BUILD_TESTS=OFF 28 | -D CMAKE_INSTALL_RPATH='\$ORIGIN' 29 | 30 | BUILD_COMMAND ${CMAKE_COMMAND} --build . --parallel ${_parallelism} 31 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 32 | INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install 33 | COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_package.txt" /CMakeLists.txt 34 | ) 35 | 36 | # cbdeps boilerplate 37 | _ADD_PACKAGE_STEP() 38 | -------------------------------------------------------------------------------- /deps/packages/snappy/CMakeLists_package.txt: -------------------------------------------------------------------------------- 1 | IF (WIN32) 2 | # On Windows platforms, .dll copied to install/bin 3 | FILE (COPY bin/snappy.dll DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") 4 | ELSE() 5 | # On non-Windows platforms, .so copied to install/lib. 6 | # Glob to find all related .so files (libsnappy.so, libsnappy.so.X.Y etc) 7 | # but excluding CMake packaging files which also reside in lib/ 8 | file(GLOB snappy_libs lib/*snappy*) 9 | file(COPY ${snappy_libs} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") 10 | ENDIF() 11 | -------------------------------------------------------------------------------- /deps/packages/snappy/snappy.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index c3062e2..7dbbc49 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -53,8 +53,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 6 | add_definitions(-D_HAS_EXCEPTIONS=0) 7 | 8 | # Disable RTTI. 9 | - string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 10 | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-") 11 | + #string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 12 | + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-") 13 | else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 14 | # Use -Wall for clang and gcc. 15 | if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall") 16 | @@ -68,9 +68,13 @@ else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 17 | 18 | # Use -Werror for clang only. 19 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 20 | - if(NOT CMAKE_CXX_FLAGS MATCHES "-Werror") 21 | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") 22 | - endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror") 23 | + EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string ) 24 | + string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string}) 25 | + if(CLANG_VERSION_STRING GREATER_EQUAL 13.0) 26 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable") 27 | + else() 28 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-const-variable") 29 | + endif() 30 | endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 31 | 32 | # Disable C++ exceptions. 33 | @@ -78,8 +82,8 @@ else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 34 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") 35 | 36 | # Disable RTTI. 37 | - string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 38 | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") 39 | + #string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 40 | + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") 41 | endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 42 | 43 | # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make 44 | -------------------------------------------------------------------------------- /deps/packages/spdlog/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | _DETERMINE_CPU_COUNT(_parallelism) 4 | 5 | DECLARE_DEP (fmt VERSION 11.0.0-cb2 PLATFORMS linux macosx windows) 6 | list(APPEND cache_args ${common_cmake_cache_args}) 7 | 8 | # spdlog won't build with C++ 17 9 | LIST(REMOVE_AT cache_args 0) 10 | 11 | # Given we build spdlog twice on Windows, define the common cmake 12 | # arguments once. 13 | list(APPEND cache_args -DCMAKE_CXX_VISIBILITY_PRESET:STRING=hidden) 14 | list(APPEND cache_args -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON) 15 | list(APPEND cache_args -DSPDLOG_BUILD_EXAMPLE:BOOL=OFF) 16 | 17 | # Use the same (external) fmtlib library as the rest of the server build. 18 | list(APPEND cache_args -DSPDLOG_FMT_EXTERNAL:BOOL=ON) 19 | list(APPEND cache_args -DCMAKE_PREFIX_PATH:STRING=${CMAKE_CURRENT_BINARY_DIR}/fmt.exploded) 20 | 21 | # Spdlog v1.8.5 and older only allows the setting of custom levels via a 22 | # compile/pre-processor definition. Historically we accomplished this using 23 | # target_compile_definitions but I think add_compile_definitions works too. 24 | # Unfortunately, ExternalProject doesn't appear to have a method of doing this. 25 | # We should be able to accomplish this by adding the definition to CXX_FLAGS but 26 | # using double quotation marks in the definition makes this an escaping 27 | # nightmare that I don't particularly want to solve. We can tackle this in a 28 | # more creative way though. We could: 29 | # 1) Use a PATCH_COMMAND to modify "include/spdlog/tweakme.h" to add the 30 | # definition. 31 | # 2) Use a PATCH_COMMAND to modify CMakeLists.txt to add the definition (but 32 | # it feels much more reasonable to change the file made to be tweaked) 33 | # 3) Create a CMake wrapper which builds spdlog after adding the compile 34 | # definition 35 | # 36 | # 1 feels like the most reasonable solution here as we're using a command 37 | # intended for this and a file intended to be modified. 38 | # 39 | # In the future when we upgrade spdlog to the next version we should be able 40 | # to supply custom log levels via cmake cache variables (the code looks to have 41 | # been changed already but isn't in a released version). We can then remove the 42 | # PATCH_COMMAND and our version of tweakme.h. 43 | 44 | # Note - it would be nice to be able to build and run spdlog's unit tests 45 | # (SPDLOG_BUILD_TESTS=ON) to verify the build , however as we change the names 46 | # of the log levels, a number of tests fail as they expect the default level 47 | # names. 48 | ExternalProject_Add(spdlog 49 | GIT_REPOSITORY ${_git_repo} 50 | GIT_TAG ${_git_rev} 51 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install 52 | 53 | PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/custom_level_names.patch 54 | CMAKE_CACHE_ARGS ${cache_args} 55 | CMAKE_ARGS -D CMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX= 56 | 57 | BUILD_COMMAND ${CMAKE_COMMAND} --build . --parallel ${_parallelism}) 58 | 59 | # Only build the TSan package on linux and macos platforms to save 60 | # time. 61 | if (NOT WIN32) 62 | ExternalProject_Add(spdlog_tsan 63 | GIT_REPOSITORY ${_git_repo} 64 | GIT_TAG ${_git_rev} 65 | INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/install/tsan_root 66 | 67 | PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/custom_level_names.patch 68 | CMAKE_CACHE_ARGS ${cache_args} 69 | "-DCMAKE_CXX_FLAGS:STRING=-fsanitize=thread" 70 | CMAKE_ARGS -D CMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX= 71 | 72 | BUILD_COMMAND ${CMAKE_COMMAND} --build . --parallel ${_parallelism}) 73 | 74 | ExternalProject_Add_StepDependencies(spdlog download spdlog_tsan) 75 | endif() 76 | 77 | # cbdeps boilerplate 78 | _ADD_PACKAGE_STEP() 79 | -------------------------------------------------------------------------------- /deps/packages/spdlog/custom_level_names.patch: -------------------------------------------------------------------------------- 1 | diff --git a/include/spdlog/tweakme.h b/include/spdlog/tweakme.h 2 | index 31e417ab..543035cc 100644 3 | --- a/include/spdlog/tweakme.h 4 | +++ b/include/spdlog/tweakme.h 5 | @@ -97,7 +97,7 @@ 6 | // Uncomment to customize short level names (e.g. "MT") 7 | // These can be longer than one character. 8 | // 9 | -// #define SPDLOG_SHORT_LEVEL_NAMES { "T", "D", "I", "W", "E", "C", "O" } 10 | +#define SPDLOG_LEVEL_NAMES = {"TRACE","DEBUG","INFO","WARNING","ERROR","CRITICAL","OFF"} 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | /////////////////////////////////////////////////////////////////////////////// 14 | -------------------------------------------------------------------------------- /deps/packages/util/GenMD5.cmake: -------------------------------------------------------------------------------- 1 | # Generate the .md5 file for a given file 2 | # args: FILE = filename to compute md5 of, MD5FILE = md5 filename 3 | FILE (MD5 "${FILE}" _md5) 4 | FILE (WRITE "${MD5FILE}" ${_md5}) 5 | -------------------------------------------------------------------------------- /deps/packages/zlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Downloads the declared version of zlib source code and builds it. 2 | 3 | include(ExternalProject) 4 | 5 | ### Download, configure and build zlib ################################## 6 | IF (WIN32) 7 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_windows.bat) 8 | ELSE () 9 | SET (_build_script ${CMAKE_CURRENT_SOURCE_DIR}/${_dep_package}_unix.sh) 10 | ENDIF () 11 | SET (_install_dir "${CMAKE_BINARY_DIR}/install") 12 | FILE (TO_NATIVE_PATH "${_install_dir}" _install_dir) 13 | 14 | ExternalProject_Add (${_dep_package} 15 | GIT_REPOSITORY ${_git_repo} 16 | GIT_TAG ${_git_rev} 17 | CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E make_directory 18 | BUILD_COMMAND "${_build_script}" ${PLATFORM} "${_dep_version}" 19 | BUILD_IN_SOURCE 1 20 | INSTALL_DIR "${_install_dir}" 21 | INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy 22 | "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists_package.txt" 23 | /CMakeLists.txt 24 | ) 25 | 26 | # cbdeps boilerplate 27 | _ADD_PACKAGE_STEP() 28 | -------------------------------------------------------------------------------- /deps/packages/zlib/CMakeLists_package.txt: -------------------------------------------------------------------------------- 1 | IF (WIN32) 2 | FILE (MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/bin") 3 | FILE (COPY bin/zlib1.dll DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") 4 | ELSE (WIN32) 5 | FILE (COPY lib DESTINATION "${CMAKE_INSTALL_PREFIX}") 6 | ENDIF (WIN32) 7 | 8 | SET_PROPERTY (GLOBAL APPEND PROPERTY CBDEPS_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}") 9 | -------------------------------------------------------------------------------- /deps/packages/zlib/zlib_unix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | INSTALL_DIR=$1 12 | PLATFORM=$2 13 | VERSION=$3 14 | 15 | ./configure --prefix=${INSTALL_DIR} || exit 1 16 | make && make install 17 | 18 | # For MacOS, tweak install_name 19 | if [ $(uname -s) = "Darwin" ]; then 20 | install_name_tool -id @rpath/libz.1.dylib ${INSTALL_DIR}/lib/libz.1.dylib 21 | fi 22 | -------------------------------------------------------------------------------- /deps/packages/zlib/zlib_windows.bat: -------------------------------------------------------------------------------- 1 | set INSTALL_DIR=%1 2 | 3 | rem Build zlib libraries 4 | call nmake -f win32\Makefile.msc || goto error 5 | 6 | rem Copy right stuff to output directory. 7 | mkdir %INSTALL_DIR%\bin 8 | mkdir %INSTALL_DIR%\lib 9 | mkdir %INSTALL_DIR%\include 10 | 11 | copy *.lib %INSTALL_DIR%\lib || goto error 12 | copy zlib1.dll %INSTALL_DIR%\bin || goto error 13 | 14 | copy zconf.h %INSTALL_DIR%\include || goto error 15 | copy zlib.h %INSTALL_DIR%\include || goto error 16 | 17 | goto :eof 18 | 19 | :error 20 | echo Failed with error %ERRORLEVEL% 21 | exit /B %ERRORLEVEL% 22 | -------------------------------------------------------------------------------- /deps/scripts/build-one-cbdep: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | # Copyright 2015-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | cd deps/packages 12 | rm -rf build 13 | mkdir build 14 | cd build 15 | 16 | # Set macos deployment target 17 | if [ "$(uname -s)" == "Darwin" ]; then 18 | export MACOSX_DEPLOYMENT_TARGET=13 19 | fi 20 | 21 | # Work-around for generating generic "linux" deps 22 | if [ "${DISTRO}" == "linux" ]; then 23 | cmake .. -DPACKAGE=${PACKAGE} -DCB_DEP_TARGET_PLATFORM="linux" 24 | elif [ "${DISTRO}" == "all" ]; then 25 | cmake .. -DPACKAGE=${PACKAGE} -DCB_DEP_TARGET_PLATFORM="all" -DCB_DOWNLOAD_DEPS_ARCH="noarch" 26 | else 27 | cmake .. -DPACKAGE=${PACKAGE} 28 | fi 29 | cmake --build . --target ${PACKAGE} 30 | 31 | if [ x$1 = xinstall ] 32 | then 33 | cp deps/*/*/*.tgz deps/*/*/*.md5 ~/.cbdepscache 34 | fi 35 | -------------------------------------------------------------------------------- /deps/scripts/build-one-cbdep.bat: -------------------------------------------------------------------------------- 1 | cd deps\packages 2 | 3 | rmdir /s /q winbuild 4 | 5 | rem Make the output directory that the job expects 6 | rmdir /s /q build\deps 7 | mkdir build\deps 8 | 9 | rem When compiling V8, Gyp expects the TMP variable to be set 10 | set TMP=C:\Windows\Temp 11 | rem Default value for source_root (ignored but must be set) 12 | set source_root=%CD% 13 | 14 | if "%DISTRO%" == "windows_msvc2022" ( 15 | set tools_version=17.0 16 | goto do_build 17 | ) 18 | if "%DISTRO%" == "windows_msvc2017" ( 19 | set tools_version=15.0 20 | goto do_build 21 | ) 22 | if "%DISTRO%" == "windows_msvc2015" ( 23 | set tools_version=14.0 24 | goto do_build 25 | ) 26 | if "%DISTRO%" == "windows_msvc2013" ( 27 | set tools_version=12.0 28 | goto do_build 29 | ) 30 | rem Without year, VS version defaults to 2013 31 | if "%DISTRO%" == "windows_msvc" ( 32 | set tools_version=12.0 33 | goto do_build 34 | ) 35 | if "%DISTRO%" == "windows_msvc2012" ( 36 | set tools_version=11.0 37 | goto do_build 38 | ) 39 | 40 | :do_build 41 | set target_arch=amd64 42 | call ..\..\win32\environment.bat %tools_version% 43 | mkdir winbuild 44 | cd winbuild 45 | cmake .. -G "NMake Makefiles" -DPACKAGE=%PACKAGE% || goto error 46 | cmake --build . --target %PACKAGE% || goto error 47 | cd .. 48 | xcopy winbuild\deps build\deps /s /e /y 49 | 50 | if "%~1" == "install" ( 51 | pushd winbuild\deps\%PACKAGE% 52 | for /d %%d in (*) do ( 53 | copy "%%d\*" "%USERPROFILE%\cbdepscache" 54 | ) 55 | popd 56 | ) 57 | 58 | goto eof 59 | 60 | :error 61 | echo Failed with error %ERRORLEVEL%. 62 | exit /b %ERRORLEVEL% 63 | 64 | :eof 65 | -------------------------------------------------------------------------------- /dot-clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | AccessModifierOffset: -4 3 | AlignAfterOpenBracket: Align 4 | AlignConsecutiveAssignments: false 5 | AlignConsecutiveDeclarations: false 6 | AlignEscapedNewlines: Left 7 | AlignOperands: true 8 | AlignTrailingComments: false 9 | AllowAllParametersOfDeclarationOnNextLine: true 10 | AllowShortBlocksOnASingleLine: false 11 | AllowShortCaseLabelsOnASingleLine: false 12 | AllowShortFunctionsOnASingleLine: None 13 | AllowShortIfStatementsOnASingleLine: Never 14 | AllowShortLoopsOnASingleLine: false 15 | AlwaysBreakAfterDefinitionReturnType: None 16 | AlwaysBreakAfterReturnType: None 17 | AlwaysBreakBeforeMultilineStrings: true 18 | AlwaysBreakTemplateDeclarations: Yes 19 | BinPackArguments: false 20 | BinPackParameters: false 21 | BraceWrapping: 22 | AfterClass: false 23 | AfterControlStatement: false 24 | AfterEnum: false 25 | AfterFunction: false 26 | AfterNamespace: false 27 | AfterObjCDeclaration: false 28 | AfterStruct: false 29 | AfterUnion: false 30 | BeforeCatch: false 31 | BeforeElse: false 32 | IndentBraces: false 33 | BreakBeforeBinaryOperators: None 34 | BreakBeforeBraces: Attach 35 | BreakBeforeTernaryOperators: true 36 | BreakConstructorInitializersBeforeComma: false 37 | ColumnLimit: 80 38 | CommentPragmas: '^ IWYU pragma:' 39 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 40 | ConstructorInitializerIndentWidth: 4 41 | ContinuationIndentWidth: 8 42 | Cpp11BracedListStyle: true 43 | DerivePointerAlignment: false 44 | DisableFormat: false 45 | ExperimentalAutoDetectBinPacking: false 46 | ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] 47 | # Include ordering based on: 48 | # https://github.com/couchbase/kv_engine/blob/master/docs/CodingStandards.rst#include-style 49 | IncludeCategories: 50 | - Regex: '^"config.h"' 51 | Priority: -1 52 | # Main header for a source file automatically gets priority 0. 53 | - Regex: '^".*\.h"' 54 | Priority: 1 55 | - Regex: '^<.*\.(h|hpp)>' 56 | Priority: 2 57 | - Regex: '^<.*' 58 | Priority: 3 59 | - Regex: '.*' 60 | Priority: 4 61 | IndentCaseLabels: false 62 | IndentWidth: 4 63 | IndentWrappedFunctionNames: false 64 | KeepEmptyLinesAtTheStartOfBlocks: false 65 | MacroBlockBegin: '' 66 | MacroBlockEnd: '' 67 | MaxEmptyLinesToKeep: 1 68 | NamespaceIndentation: None 69 | ObjCBlockIndentWidth: 2 70 | ObjCSpaceAfterProperty: false 71 | ObjCSpaceBeforeProtocolList: false 72 | PenaltyBreakBeforeFirstCallParameter: 1 73 | PenaltyBreakComment: 300 74 | PenaltyBreakFirstLessLess: 120 75 | PenaltyBreakString: 1000 76 | PenaltyExcessCharacter: 1000000 77 | PenaltyReturnTypeOnItsOwnLine: 200 78 | PointerAlignment: Left 79 | ReflowComments: true 80 | SortIncludes: true 81 | SpaceAfterCStyleCast: false 82 | SpaceBeforeAssignmentOperators: true 83 | SpaceBeforeParens: ControlStatements 84 | SpaceInEmptyParentheses: false 85 | SpacesBeforeTrailingComments: 1 86 | SpacesInAngles: false 87 | SpacesInContainerLiterals: true 88 | SpacesInCStyleCastParentheses: false 89 | SpacesInParentheses: false 90 | SpacesInSquareBrackets: false 91 | Standard: Auto 92 | TabWidth: 8 93 | UseTab: Never 94 | 95 | --- 96 | 97 | Language: Proto 98 | BasedOnStyle: Google 99 | 100 | --- 101 | 102 | Language: Json 103 | DisableFormat: true 104 | -------------------------------------------------------------------------------- /dot-clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: '-*,modernize-*,-modernize-use-nodiscard,-modernize-use-trailing-return-type,bugprone-sizeof-expression,bugprone-use-after-move,bugprone-unhandled-self-assignment,-google-explicit-constructor,readability-avoid-nested-conditional-operator,readability-avoid-return-with-void-value,readability-avoid-unconditional-preprocessor-if,readability-delete-null-pointer,readability-duplicate-include,readability-else-after-return,readability-enum-initial-value,readability-identifier-naming,readability-math-missing-parentheses,readability-misleading-indentation,readability-misplaced-array-index,readability-operators-representation,readability-redundant-access-specifiers,readability-redundant-casting,readability-redundant-control-flow,readability-redundant-function-ptr-dereference,readability-redundant-inline-specifier,readability-redundant-preprocessor,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-reference-to-constructed-temporary,readability-simplify-subscript-expr,readability-static-definition-in-anonymous-namespace,readability-string-compare,readability-uniqueptr-delete-release,readability-use-std-min-max' 2 | WarningsAsErrors: '' 3 | HeaderFilterRegex: '' 4 | FormatStyle: none 5 | CheckOptions: 6 | - key: modernize-use-auto.RemoveStars 7 | value: '0' 8 | - key: modernize-use-auto.MinTypeNameLength 9 | value: '5' 10 | - key: modernize-use-nullptr.NullMacros 11 | value: 'NULL' 12 | - key: modernize-use-transparent-functors.SafeMode 13 | value: '1' 14 | -------------------------------------------------------------------------------- /install_hook.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2017-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | usage () { 12 | cat << EOF 13 | Usage: install_hook.sh project [project ...] 14 | 15 | Installs a pre-commit hook for the given projects to run 16 | 17 | git clang-format 18 | 19 | before each commit. 20 | 21 | Once installed, the behaviour of the hook can be customised with 22 | 23 | git config couchbase.clangformat 24 | 25 | Where the valid options are: 26 | 27 | "warn" : Block the commit if there are style issues but do not make 28 | changes to files (default) 29 | "fix" : Block the commit, Fix style issues but do not stage the 30 | resulting changes. Changes can be reviewed with \`git diff\`. 31 | "stage" : Block, fix issues and immediately stage the changes 32 | ready to commit. 33 | "commit" : Transparently fix style issues and allow the commit. 34 | 35 | In all cases except "warn", if clang-format refuses to run 36 | (e.g., if it would modify files with unstaged changes) files 37 | will not be changed and the commit will be refused. Stash any 38 | unstaged changes you do not wish to commit in this case. 39 | 40 | EOF 41 | } 42 | 43 | install_gcf_hook () { 44 | proj=$1 45 | base_dir=$2 46 | if [ -e $base_dir/.git/hooks/pre-commit ] ; then 47 | echo "Project $proj already has a pre-commit hook, not overwriting it!" 48 | return 1 49 | else 50 | echo "Installing pre-commit hook in $base_dir/.git/hooks/pre-commit" 51 | cp $(repo list -fpr tlm)/clang-format-pre-commit-hook $base_dir/.git/hooks/pre-commit 52 | fi 53 | } 54 | 55 | 56 | # Show usage if "-h" or no projects given 57 | if [[ ! "${@#-h}" = "$@" ]] || [[ $# = 0 ]] ; then 58 | usage 59 | exit 60 | fi 61 | 62 | # Very basic check whether prereqs are present 63 | for tool in clang-format git-clang-format ; do 64 | if [ -z $(which $tool) ] ; then 65 | echo "$tool not found, please install it, e.g. \`brew install $tool\` and try again." 66 | fi 67 | done 68 | 69 | any_failed=0 70 | 71 | for project in $@ ; do 72 | # Attempt to find the project dir from repo 73 | project_dir=`repo list -fpr $project` 74 | if [ -z $project_dir ] ; then 75 | echo "Project '$project' not found" 76 | continue 77 | else 78 | install_gcf_hook $project $project_dir 79 | if [ ! $? = 0 ] ; then 80 | any_failed=1 81 | fi 82 | fi 83 | done 84 | 85 | exit $any_failed 86 | -------------------------------------------------------------------------------- /lsan.suppressions: -------------------------------------------------------------------------------- 1 | # The file must contain one suppression rule per line, each rule being of the 2 | # form leak:. The pattern will be substring-matched against the 3 | # symbolized stack trace of the leak. If either function name, source file name 4 | # or binary file name matches, the leak report will be suppressed. 5 | # Upstream documentation for the file: 6 | # https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions 7 | 8 | # MB-41894: v8 8.3 with pointer compression disabled has some read-only memory 9 | # Supressing isolate leaks until we enable pointer compression 10 | leak:v8::Isolate::New 11 | -------------------------------------------------------------------------------- /python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019 Couchbase, Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # The version of cbpy, as extracted from tlm/deps/manifest.cmake. 17 | SET (CBPY_VERSION "${CBDEP_cbpy_VERSION}") 18 | 19 | # Set up various paths and locations for Python-related things: 20 | 21 | # Base directory for cbpy install - used by out-of-build programs such 22 | # as the non-installed wrapper scripts created by PyWrapper(). This must 23 | # match the DESTINATION in tlm/deps/manifest.cmake for cbpy. 24 | SET (CBPY_PATH lib/python/interp) 25 | SET (CBPY_INSTALL "${CMAKE_INSTALL_PREFIX}/${CBPY_PATH}" CACHE INTERNAL "") 26 | 27 | # Path to python interpreter in the install directory. Any build steps 28 | # that want to run python scripts should use ${PYTHON_EXE}. We also set 29 | # PYTHON_EXECUTABLE for a few places that expect that older variable. 30 | IF (WIN32) 31 | SET (_localpy "${CBPY_INSTALL}/python.exe") 32 | ELSE () 33 | SET (_localpy "${CBPY_INSTALL}/bin/python3") 34 | ENDIF () 35 | SET (PYTHON_EXE "${_localpy}" CACHE INTERNAL "Path to python interpreter") 36 | SET (PYTHON_EXECUTABLE "${_localpy}" CACHE INTERNAL "Path to python interpreter") 37 | 38 | # Add the PyWrapper-related CMake functions. 39 | INCLUDE (PyWrapperFunctions.cmake) 40 | 41 | # Leaving this for historical purposes until other code 42 | # can be updated. 43 | ADD_CUSTOM_TARGET (local-cbpy ALL) 44 | -------------------------------------------------------------------------------- /python/py-wrapper.sh.tmpl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2019-Present Couchbase, Inc. 4 | # 5 | # Use of this software is governed by the Business Source License included in 6 | # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 7 | # file, in accordance with the Business Source License, use of this software 8 | # will be governed by the Apache License, Version 2.0, included in the file 9 | # licenses/APL2.txt. 10 | 11 | D0=$(cd "$(dirname "$0")" && pwd) 12 | codedir=$(cd "$D0/@CODE_REL@" && pwd) 13 | libdir=$(cd "$D0/@LIB_REL@" && pwd) 14 | pydir=$(cd "$D0/@PY_REL@" && pwd) 15 | 16 | PYTHONPATH="$codedir" 17 | export PYTHONPATH 18 | @LIB_PATH_VAR@="$pydir/lib:$libdir" 19 | export @LIB_PATH_VAR@ 20 | 21 | exec "$pydir"/bin/python3 -s "$codedir"/$(basename "$0") "$@" 22 | -------------------------------------------------------------------------------- /scripts/create-builder: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | _old=`docker ps -a --filter name=builder --format "{{.ID}}"` 4 | if [ x"$_old" != "x" ] 5 | then 6 | echo "Deleting old builder" 7 | docker rm -f $_old > /dev/zero 8 | fi 9 | 10 | # You might want to limit the resources in your docker container. 11 | # ex: 12 | # --cpus 6 \ 13 | # --memory 12g \ 14 | 15 | docker run -d \ 16 | -v ~/:${HOME} \ 17 | -v /var/run/docker.sock:/var/run/docker.sock \ 18 | -p 8091-8095:8091-8095 \ 19 | -p 11200-11220:11200-11220 \ 20 | --dns 8.8.8.8 \ 21 | --dns 4.4.4.4 \ 22 | --name builder \ 23 | --restart unless-stopped \ 24 | --entrypoint '' \ 25 | couchbasebuild/server-linux-cv:latest \ 26 | tail -f /dev/null 27 | -------------------------------------------------------------------------------- /scripts/enter-builder: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat < ~/.docker-bashentry 4 | export HOME=${HOME} 5 | cd $(pwd) 6 | stty rows $(stty size | sed -e 's/ / columns /') 7 | 8 | if [ -e ~/.docker-bashrc ]; then 9 | . ~/.docker-bashrc 10 | fi 11 | EOF 12 | 13 | docker exec -it -e TERM=${TERM} -u couchbase builder bash --init-file ${HOME}/.docker-bashentry 14 | -------------------------------------------------------------------------------- /scripts/get_manifest_annot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Copyright 2017-Present Couchbase, Inc. 5 | 6 | Use of this software is governed by the Business Source License included in 7 | the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 8 | file, in accordance with the Business Source License, use of this software will 9 | be governed by the Apache License, Version 2.0, included in the file 10 | licenses/APL2.txt. 11 | """ 12 | 13 | # This script should work with python2 or python3. It also tries to 14 | # never throw an error depsite what manifest nonsense it might come 15 | # across. If it can't find the annotation for whatever reason, it 16 | # outputs nothing. 17 | 18 | import os 19 | import subprocess 20 | import sys 21 | import xml.etree.ElementTree as ET 22 | 23 | # Annotation name 24 | if len(sys.argv) < 2: 25 | sys.exit(0) 26 | 27 | # Find appropriate manifest - either in .repo directory, or in file named 28 | # 'manifest.xml' in cwd. If neither available, exit without complaint. 29 | manifest = '' 30 | if os.path.isdir(".repo"): 31 | with open(os.devnull, "w") as devnull: 32 | try: 33 | proc = subprocess.Popen( 34 | 'repo manifest', 35 | stdout=subprocess.PIPE, 36 | stderr=devnull, 37 | shell=True 38 | ) 39 | manifest_bytes, _ = proc.communicate() 40 | manifest = manifest_bytes.decode('utf-8') 41 | except: 42 | # Ignore it 43 | pass 44 | elif os.path.exists("manifest.xml"): 45 | with open("manifest.xml") as m: 46 | manifest = m.read() 47 | 48 | if manifest == '': 49 | # Failed to get manifest for some reason 50 | sys.exit(0) 51 | 52 | root = ET.fromstring(manifest) 53 | 54 | # Return the first requested annotation that's found 55 | for annot in sys.argv[1:]: 56 | attr = root.find(f'project[@name="build"]/annotation[@name="{annot}"]') 57 | if attr is not None: 58 | value = attr.get('value') 59 | if value is not None: 60 | print (value) 61 | sys.exit(0) 62 | -------------------------------------------------------------------------------- /scripts/show_ninja_build_stats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gawk -f 2 | 3 | # show_ninja_build_times: Script to summarise the per-target build 4 | # times from the Ninja build log. 5 | # 6 | # Usage: show_ninja_build_stats < .ninja_log 7 | 8 | !/^#/ { 9 | TIMES[$4] += ($2 - $1)/1000 10 | COUNT[$4] += 1 11 | } 12 | 13 | END { 14 | for (TGT in TIMES) 15 | AVG[TGT]=TIMES[TGT]/COUNT[TGT] 16 | asorti(AVG, SORTED, "@val_num_desc") 17 | for (num in SORTED) 18 | print AVG[SORTED[num]] " " SORTED[num] 19 | } 20 | -------------------------------------------------------------------------------- /tag_release.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Copyright 2015-Present Couchbase, Inc. 5 | 6 | Use of this software is governed by the Business Source License included in 7 | the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that 8 | file, in accordance with the Business Source License, use of this software will 9 | be governed by the Apache License, Version 2.0, included in the file 10 | licenses/APL2.txt. 11 | """ 12 | 13 | """Script to tag projects with the release from the manifest. 14 | 15 | Requires: Permission to push tags to Gerrit 16 | 17 | Usage: Run from the top of a repo checkout: 18 | tag_release.py 19 | 20 | e.g. 21 | 22 | tag_release.py 4.0.0 memcached platform 23 | 24 | This will print the commands needed to tag the release. 25 | Review, then copy/paste. 26 | """ 27 | 28 | import os 29 | import sys 30 | import xml.etree.ElementTree 31 | 32 | if len(sys.argv) < 3: 33 | print("Usage: {} ".format( 34 | sys.argv[0]), file=sys.stderr) 35 | exit(1) 36 | 37 | release = sys.argv[1] 38 | manifest_path = None 39 | manifest_subdirs = ["released/", "released/couchbase-server/"] 40 | for subdir in manifest_subdirs: 41 | path = ".repo/manifests/" + subdir + release + ".xml" 42 | if os.path.exists(path): 43 | manifest_path = path 44 | break 45 | 46 | if not manifest_path: 47 | print("Unable to locate manifest '" + release + ".xml' - searched in:", file=sys.stderr) 48 | for subdir in manifest_subdirs: 49 | print("\t" + subdir, file=sys.stderr) 50 | print("Check specified release and current working " \ 51 | "directory (should be run from top-level of repo checkout).", file=sys.stderr) 52 | exit(2) 53 | 54 | projects_to_tag = sys.argv[2:] 55 | 56 | e = xml.etree.ElementTree.parse(manifest_path).getroot() 57 | for p in e.findall('project'): 58 | if p.attrib['name'] in projects_to_tag: 59 | name = p.attrib['name'] 60 | sha = p.attrib['revision'] 61 | print("pushd " + name) 62 | print("""git tag -a -m "{0} release ({1})" v{0} {2}""".format( 63 | release, name, sha)) 64 | print("git push review v{0}".format(release)) 65 | print("popd") 66 | -------------------------------------------------------------------------------- /third-party-CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Note: This file lives in git at 'tlm/third-party-CMakeLists.txt'. 2 | # It is copied by repo into third_party/CMakeLists.txt, so should be 3 | # considered read-only in that location. 4 | 5 | # Ensure the third party code is position independent because our 6 | # code is always built as position-independent. 7 | # This setting is specifically required for HdrHistogram_c. 8 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 9 | 10 | add_subdirectory(gsl-lite EXCLUDE_FROM_ALL) 11 | 12 | # Disable building examples and tests for HdrHistogram. 13 | set(HDR_HISTOGRAM_BUILD_PROGRAMS OFF CACHE BOOL "Build hdr_histogram tests and examples") 14 | add_subdirectory(HdrHistogram_c) 15 | -------------------------------------------------------------------------------- /tsan.suppressions: -------------------------------------------------------------------------------- 1 | # ThreadSanitizer suppressions file for Couchbase 2 | # https://github.com/google/sanitizers/wiki/ThreadSanitizerSuppressions 3 | 4 | # The auditd unit tests trigger a heap-use-after-free error, however Valgrind doesn't 5 | # detect anything wrong and ThreadSanitizer is known to have issues with exceptions 6 | # so I'm pretty sure this a false positive. 7 | race:TestCrashRecoveryGarbeledDate 8 | 9 | # memcached ISOTime::generatetimestamp is using libc mktime which updates 10 | # the TZ env-variable through tzset (_internal). This shows up as a data-race. 11 | race:tzset_internal 12 | race:tzset 13 | 14 | # ThreadSanitizer appears to report a false positive data race in 15 | # operator delete via std::string::assign for std::string when using 16 | # libstdc++ - see discussion at 17 | # https://groups.google.com/forum/#!msg/thread-sanitizer/dZ3QiQE49ns/j7rKGHg08foJ 18 | # Running with LLVM's own C++ library (libc++) makes the warning go 19 | # away, so would seem to be either a bug in libstdc++, or a bug in 20 | # ThreadSanitizer. 21 | race:^std::string::assign(std::string const&) 22 | 23 | # ThreadSanitizer appears to report a data race in GCC's basic_string 24 | # implementation on _M_refcount: specifically on operator delete via 25 | # std::string::_Rep::_M_dispose for std::string when using libstdc++ - 26 | # report at: https://gcc.gnu.org/ml/libstdc++/2015-09/msg00000.html 27 | # Suppressing this for now. 28 | race:^std::string::_Rep::_M_dispose(std::allocator const&) 29 | 30 | # In forestdb plock_lock is invoked from a lock structure that is sure to not 31 | # overlap with that of another thread by use of is_overlapped() test. 32 | # However since this function is not trusted by ThreadSanitizer it reports 33 | # a lock inversion since the locks in the race are from the same struct definition 34 | # but different memory addresses. This is hence a false positive. 35 | deadlock:plock_lock 36 | 37 | # The memcached unit test 'memcached_logger_emfile_test' deliberately 38 | # consumes all file descriptors during it's run. This has the 39 | # consequence of preventing thread sanitizer's external symbol lookup 40 | # from failing. In turn this means that it cannot check for 41 | # symbol-based suppressions (e.g. the tzset_internal one above). 42 | # Therefore just suppress anything for this unit test. 43 | race:memcached_logger_emfile_test -------------------------------------------------------------------------------- /ubsan.suppressions: -------------------------------------------------------------------------------- 1 | # UndefinedBehavourSanitizer suppressions file for Couchbase 2 | # https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#runtime-suppressions 3 | 4 | # MB-49880: "runtime error: member call on address 0x60d000000380 which does not point to an object of type 'v8::Platform'" 5 | # Suppress this issue while being investigated, as to not cause CV to fail 6 | # for other jobs. 7 | vptr:std::default_delete::operator()(v8::Platform*) 8 | 9 | # Similar to previous suppression - V8 v10.7.21 uses shared_ptr for 10 | # v8::internal::Isolate* objects and we do not have necessary RTTI 11 | # type info in our libv8 for UBSan to be able to check vptr matches. 12 | # This results in warnings of the following when running couchstore 13 | # views unit tests: 14 | # shared_ptr_base.h:155:46: runtime error: member access within address 0x60c000000a00 which does not point to an object of type 'std::_Sp_counted_base<__gnu_cxx::_S_atomic>' 15 | # 0x60c000000a00: note: object has invalid vptr 16 | # 05 00 00 3a f0 f3 44 08 51 7f 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 | # ^~~~~~~~~~~~~~~~~~~~~~~ 18 | # invalid vptr 19 | # #0 0x7f510a75f231 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() include/c++/10.2.0/bits/shared_ptr_base.h:155:46 20 | # #1 0x7f51079eb84b in v8::internal::wasm::WasmEngine::RemoveIsolate(v8::internal::Isolate*) (install-asan-ubsan/lib/libv8.so+0x102884b) 21 | # #2 0x7f51072dccc8 in v8::internal::Isolate::Deinit() (install-asan-ubsan/lib/libv8.so+0x919cc8) 22 | # #3 0x7f51072df5ff in v8::internal::Isolate::Delete(v8::internal::Isolate*) (install-asan-ubsan/lib/libv8.so+0x91c5ff) 23 | # #4 0x4e66fe in destroyContext(mapreduce_ctx_t*) build-asan-ubsan/../couchstore/src/views/mapreduce/mapreduce.cc:177:19 24 | # #5 0x4f3cc2 in mapreduce_free_context(void*) build-asan-ubsan/../couchstore/src/views/mapreduce/mapreduce_c.cc:232:9 25 | # #6 0x4fd0c7 in test_sum_function() build-asan-ubsan/../couchstore/tests/mapreduce/builtin.cc:71:5 26 | # #7 0x4fcd14 in main build-asan-ubsan/../couchstore/tests/mapreduce/builtin.cc:153:5 27 | # #8 0x7f510459ac86 in __libc_start_main /build/glibc-uZu3wS/glibc-2.27/csu/../csu/libc-start.c:310 28 | # #9 0x43aab9 in _start (build-asan-ubsan/couchstore/couchstore_mapreduce-builtin-test+0x43aab9) 29 | vptr:std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() 30 | -------------------------------------------------------------------------------- /win32/environment.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if not defined tools_version ( 4 | set tools_version=14.0 5 | ) 6 | 7 | if exist "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build" ( 8 | set "tools_dir=C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build" 9 | ) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build" ( 10 | set "tools_dir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build" 11 | ) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build" ( 12 | set "tools_dir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build" 13 | ) else if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build" ( 14 | set "tools_dir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build" 15 | ) else ( 16 | set "tools_dir=C:\Program Files (x86)\Microsoft Visual Studio %tools_version%\VC" 17 | ) 18 | echo Using tools from %tools_dir% 19 | if not defined source_root goto default_source_root 20 | 21 | :target_arch 22 | if not defined target_arch goto default_target_arch 23 | 24 | :setup_arch 25 | if /i "%target_arch%" == "amd64" goto setup_amd64 26 | if /i "%target_arch%" == "x86" goto setup_x86 27 | 28 | echo Unknown architecture: %target_arch%. Must be amd64 or x86 29 | set ERRORLEVEL=1 30 | goto eof 31 | 32 | :default_source_root 33 | set source_root=%CD% 34 | echo source_root not set. It was automatically set to the current directory %source_root%. 35 | goto target_arch 36 | 37 | :default_target_arch 38 | set target_arch=amd64 39 | echo target_arch is not set. It was automatically set to %target_arch%. 40 | goto setup_arch 41 | 42 | :setup_x86 43 | echo Setting up Visual Studio environment for x86 44 | call "%tools_dir%\vcvarsall.bat" x86 45 | goto setup_environment 46 | 47 | :setup_amd64 48 | echo Setting up Visual Studio environment for amd64 49 | call "%tools_dir%\vcvarsall.bat" amd64 50 | goto setup_environment 51 | 52 | :setup_environment 53 | rem Unfortunately we need to have all of the directories 54 | rem we build dll's in in the path in order to run make 55 | rem test in a module.. 56 | 57 | echo Setting compile environment for building Couchbase server 58 | set OBJDIR=\build 59 | set MODULEPATH=%SOURCE_ROOT%%OBJDIR%\platform 60 | set MODULEPATH=%MODULEPATH%;%SOURCE_ROOT%%OBJDIR%\platform\extmeta 61 | set MODULEPATH=%MODULEPATH%;%SOURCE_ROOT%%OBJDIR%\platform\cbcompress 62 | set MODULEPATH=%MODULEPATH%;%SOURCE_ROOT%%OBJDIR%\platform\cbsocket 63 | set MODULEPATH=%MODULEPATH%;%SOURCE_ROOT%%OBJDIR%\phosphor 64 | 65 | set MODULEPATH=%MODULEPATH%;%SOURCE_ROOT%%OBJDIR%\memcached 66 | set MODULEPATH=%MODULEPATH%;%SOURCE_ROOT%%OBJDIR%\couchstore 67 | set MODULEPATH=%MODULEPATH%;%SOURCE_ROOT%%OBJDIR%\magma 68 | set MODULEPATH=%MODULEPATH%;%SOURCE_ROOT%%OBJDIR%\sigar\src 69 | set PATH=%MODULEPATH%;%PATH%;%SOURCE_ROOT%\install\bin 70 | set OBJDIR= 71 | SET MODULEPATH= 72 | cd %SOURCE_ROOT% 73 | if "%target_arch%" == "amd64" set PATH=%PATH%;%SOURCE_ROOT%\install\x86\bin 74 | goto eof 75 | 76 | :missing_root 77 | echo source_root should be set in the source root 78 | set ERRORLEVEL=1 79 | goto eof 80 | 81 | :missing_target_arch 82 | echo target_arch must be set in environment to x86 or amd64 83 | set ERRORLEVEL=1 84 | goto eof 85 | 86 | :eof 87 | --------------------------------------------------------------------------------