Add cmake build system #290
|
@ -1,56 +0,0 @@
|
|||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
project(lbrycrd_clion) # Do not use for full compile. This is for CLion syntax checking only.
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
if(EXISTS "build/boost")
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
set(BOOST_ROOT "build/boost" CACHE PATH "Boost library path")
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
set(Boost_NO_SYSTEM_PATHS on CACHE BOOL "Do not search system for Boost")
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
endif()
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
find_package(Boost REQUIRED COMPONENTS filesystem thread chrono locale)
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
file(GLOB sources
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/*.h src/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/wallet/*.h src/wallet/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/support/*.h src/support/*.cpp src/support/allocators/*.h
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/script/*.h src/script/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/index/*.h src/index/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/interfaces/*.h src/interfaces/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/primitives/*.h src/primitives/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/policy/*.h src/policy/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/crypto/*.h src/crypto/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/consensus/*.h src/consensus/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/compat/*.h src/compat/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/rpc/*.h src/rpc/*.cpp
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
)
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
list(FILTER sources EXCLUDE REGEX "src/bitcoin*.cpp$")
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
include_directories(${Boost_INCLUDE_DIRS}
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
build/bdb/include
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
build/libevent/include
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
build/openssl/include
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/support/allocators
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/support
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/rpc
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/policy
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/wallet src/script
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/leveldb/helpers/memenv
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/leveldb/include
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/config
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/crypto
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/compat
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/obj
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/univalue/include
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/secp256k1/include
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
src/
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
)
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
add_compile_definitions(HAVE_CONFIG_H)
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
add_executable(lbrycrd-cli src/bitcoin-cli.cpp ${sources})
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
add_executable(lbrycrd-tx src/bitcoin-tx.cpp ${sources})
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
add_executable(lbrycrdd src/bitcoind.cpp ${sources})
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
file(GLOB tests src/test/*.cpp src/wallet/test/*.cpp)
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
add_executable(test_lbrycrd ${tests} ${sources})
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
||||
target_include_directories(test_lbrycrd PRIVATE src/test)
|
||||
The "depends" system uses The "depends" system uses `sed` instead of `patch` to achieve this. It doesn't need the extra file. The `sed` approach seems superior to me.
|
|
@ -143,6 +143,15 @@ cd lbrycrd
|
|||
|
||||
If you encounter any errors, please check `doc/build-*.md` for further instructions. If you're still stuck, [create an issue](https://github.com/lbryio/lbrycrd/issues/new) with the output of that command, your system info, and any other information you think might be helpful. The scripts in the packaging folder are simple and will grant extra light on the build process as needed.
|
||||
|
||||
#### Use with CLion:
|
||||
CLion has not traditionally supported Autotools projects, although some progress on that is now in the works. We do include a cmake build file for compiling lbrycrd. See contrib/cmake. Alas, CLion doesn't support external projects in cmake, so that particular approach is also insufficient. CLion does support "compile_commands.json" projects. Fortunately, this can be easily generated for lbrycrd like so:
|
||||
```
|
||||
pip install --user compiledb
|
||||
./autogen.sh && ./configure --enable-static=no --enable-shared --with-pic --without-gui CXXFLAGS="-O0 -g" CFLAGS="-O0 -g" # or whatever normal lbrycrd config
|
||||
compiledb make -j10
|
||||
```
|
||||
Then open the newly generated compile_commands.json file as a project in CLion. Debugging is supported if you compiled with `-g`. To enable that you will need to create a target in CLion by going to File -> Settings -> Build -> Custom Build Targets. Add an empty target with your choice of name. From there you can go to "Edit Configurations", typically found in a drop-down at the top of the editor. Add a Custom Build Application, select your new target, select the compiled file (i.e. test_lbrycrd or lbrycrdd, etc), and then add any necessary command line parameters. Ensure that there is nothing in the "Before launch" section.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions to this project are welcome, encouraged, and compensated. For more details, see [https://lbry.tech/contribute](https://lbry.tech/contribute)
|
||||
|
|
185
contrib/cmake/CMakeLists.txt
Normal file
|
@ -0,0 +1,185 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(lbrycrd)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
include(cmake/CPM.cmake)
|
||||
include(ExternalProject)
|
||||
|
||||
set(OPTIONS "" CACHE STRING "lbrycrdd configure options")
|
||||
set(CPPFLAGS "" CACHE STRING "lbrycrdd compiler options")
|
||||
set(LDFLAGS "" CACHE STRING "lbrycrdd linker options")
|
||||
set(DISABLE_TESTS OFF CACHE BOOL "compilation without tests")
|
||||
set(DISABLE_WALLET OFF CACHE BOOL "compilation without wallet support")
|
||||
set(DISABLE_BENCH OFF CACHE BOOL "compilation without bench support")
|
||||
|
||||
if(NOT ${CPM_USE_LOCAL_PACKAGES})
|
||||
set(OPTIONS "${OPTIONS} --enable-static --disable-shared")
|
||||
else()
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
endif()
|
||||
|
||||
set(OPTIONS "--without-gui ${OPTIONS} --with-pic")
|
||||
|
||||
if (${DISABLE_TESTS})
|
||||
set(OPTIONS "${OPTIONS} --disable-tests")
|
||||
endif()
|
||||
|
||||
if (${DISABLE_WALLET})
|
||||
set(OPTIONS "${OPTIONS} --disable-wallet")
|
||||
endif()
|
||||
|
||||
if (${DISABLE_BENCH})
|
||||
set(OPTIONS "${OPTIONS} --disable-bench")
|
||||
endif()
|
||||
|
||||
string(TOLOWER ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR} ARCH)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME OpenSSL
|
||||
GITHUB_REPOSITORY openssl/openssl
|
||||
VERSION 1.0.2
|
||||
GIT_TAG OpenSSL_1_0_2r
|
||||
DOWNLOAD_ONLY TRUE
|
||||
)
|
||||
|
||||
if(OpenSSL_ADDED)
|
||||
ExternalProject_Add(OpenSSL
|
||||
PREFIX openssl
|
||||
SOURCE_DIR ${OpenSSL_SOURCE_DIR}
|
||||
CONFIGURE_COMMAND ${OpenSSL_SOURCE_DIR}/Configure ${ARCH} no-shared no-dso no-engines -fPIC --prefix=<INSTALL_DIR>
|
||||
BUILD_IN_SOURCE 1
|
||||
)
|
||||
set(DEPENDS ${DEPENDS} OpenSSL)
|
||||
ExternalProject_Get_Property(OpenSSL INSTALL_DIR)
|
||||
set(LDFLAGS "${LDFLAGS} -L${INSTALL_DIR}/lib")
|
||||
set(CPPFLAGS "${CPPFLAGS} -I${INSTALL_DIR}/include")
|
||||
set(OPENSSL_CPPFLAGS "CPPFLAGS=-I${INSTALL_DIR}/include")
|
||||
set(OPENSSL_LDFLAGS "LDFLAGS=-L${INSTALL_DIR}/lib")
|
||||
endif(OpenSSL_ADDED)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME Libevent
|
||||
GITHUB_REPOSITORY libevent/libevent
|
||||
VERSION 2.1.8
|
||||
GIT_TAG release-2.1.8-stable
|
||||
DOWNLOAD_ONLY TRUE
|
||||
)
|
||||
|
||||
if(Libevent_ADDED)
|
||||
ExternalProject_Add(Libevent
|
||||
PREFIX libevent
|
||||
DEPENDS ${DEPENDS}
|
||||
SOURCE_DIR ${Libevent_SOURCE_DIR}
|
||||
CONFIGURE_COMMAND ${Libevent_SOURCE_DIR}/autogen.sh
|
||||
&& ${Libevent_SOURCE_DIR}/configure ${OPENSSL_CPPFLAGS} --enable-cxx --disable-shared --with-pic ${OPENSSL_LDFLAGS} --prefix=<INSTALL_DIR>
|
||||
BUILD_IN_SOURCE 1
|
||||
)
|
||||
set(DEPENDS ${DEPENDS} Libevent)
|
||||
ExternalProject_Get_Property(Libevent INSTALL_DIR)
|
||||
set(LDFLAGS "${LDFLAGS} -L${INSTALL_DIR}/lib")
|
||||
set(CPPFLAGS "${CPPFLAGS} -I${INSTALL_DIR}/include")
|
||||
endif(Libevent_ADDED)
|
||||
|
||||
if(NOT ${DISABLE_WALLET})
|
||||
CPMAddPackage(
|
||||
NAME BerkeleyDB
|
||||
VERSION 4.8.30
|
||||
URL https://download.oracle.com/berkeley-db/db-4.8.30.NC.zip
|
||||
URL_HASH SHA256=43ecd76886992ea416fdadc54b7f2b83ef249d9a6964bd07708ccae42d0226ce
|
||||
DOWNLOAD_ONLY TRUE
|
||||
)
|
||||
|
||||
if(NOT ${BerkeleyDB_VERSION} VERSION_LESS "5.0")
|
||||
set(OPTIONS "${OPTIONS} --with-incompatible-bdb")
|
||||
endif()
|
||||
|
||||
if(BerkeleyDB_ADDED)
|
||||
ExternalProject_Add(BerkeleyDB
|
||||
PREFIX bdb
|
||||
SOURCE_DIR ${BerkeleyDB_SOURCE_DIR}
|
||||
PATCH_COMMAND sed -i "s/__atomic_compare_exchange/__atomic_compare_exchange_db/" ${BerkeleyDB_SOURCE_DIR}/dbinc/atomic.h
|
||||
CONFIGURE_COMMAND ${BerkeleyDB_SOURCE_DIR}/dist/configure --enable-cxx --disable-shared --with-pic --prefix=<INSTALL_DIR>
|
||||
)
|
||||
set(DEPENDS ${DEPENDS} BerkeleyDB)
|
||||
ExternalProject_Get_Property(BerkeleyDB INSTALL_DIR)
|
||||
set(LDFLAGS "${LDFLAGS} -L${INSTALL_DIR}/lib")
|
||||
set(CPPFLAGS "${CPPFLAGS} -I${INSTALL_DIR}/include")
|
||||
endif(BerkeleyDB_ADDED)
|
||||
endif()
|
||||
|
||||
set(BOOST_LIBS chrono,filesystem,system,locale,thread)
|
||||
|
||||
string(REPLACE "," ";" BOOST_COMPONENTS ${BOOST_LIBS})
|
||||
|
||||
if(NOT ${DISABLE_TESTS})
|
||||
set(BOOST_LIBS ${BOOST_LIBS},test)
|
||||
set(BOOST_COMPONENTS ${BOOST_COMPONENTS};unit_test_framework)
|
||||
endif()
|
||||
|
||||
CPMAddPackage(
|
||||
NAME Boost
|
||||
GITHUB_REPOSITORY boostorg/boost
|
||||
VERSION 1.64.0
|
||||
COMPONENTS ${BOOST_COMPONENTS}
|
||||
GIT_TAG boost-1.69.0
|
||||
GIT_SUBMODULES libs/* tools/*
|
||||
DOWNLOAD_ONLY TRUE
|
||||
)
|
||||
|
||||
# if boost is found system wide we expect to be compiled against icu, so we can skip it
|
||||
if(Boost_ADDED)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME ICU
|
||||
GITHUB_REPOSITORY unicode-org/icu
|
||||
VERSION 63.2
|
||||
GIT_TAG release-63-2
|
||||
DOWNLOAD_ONLY TRUE
|
||||
)
|
||||
|
||||
if(ICU_ADDED)
|
||||
ExternalProject_Add(ICU
|
||||
PREFIX icu
|
||||
SOURCE_DIR ${ICU_SOURCE_DIR}
|
||||
CONFIGURE_COMMAND ${ICU_SOURCE_DIR}/icu4c/source/configure --disable-extras --disable-strict --enable-static
|
||||
--disable-shared --disable-tests --disable-samples --disable-dyload --disable-layoutex CFLAGS=-fPIC CPPFLAGS=-fPIC --prefix=<INSTALL_DIR>
|
||||
)
|
||||
set(DEPENDS ${DEPENDS} ICU)
|
||||
ExternalProject_Get_Property(ICU INSTALL_DIR)
|
||||
set(ICU_PATH ${INSTALL_DIR})
|
||||
set(OPTIONS "${OPTIONS} --with-icu=${ICU_PATH}")
|
||||
set(LDFLAGS "${LDFLAGS} -L${ICU_PATH}/lib")
|
||||
set(CPPFLAGS "${CPPFLAGS} -I${ICU_PATH}/include")
|
||||
endif(ICU_ADDED)
|
||||
|
||||
ExternalProject_Add(Boost
|
||||
PREFIX boost
|
||||
DEPENDS ${DEPENDS}
|
||||
SOURCE_DIR ${Boost_SOURCE_DIR}
|
||||
CONFIGURE_COMMAND ${Boost_SOURCE_DIR}/bootstrap.sh --with-icu=${ICU_PATH} --with-libraries=${BOOST_LIBS} && ${Boost_SOURCE_DIR}/b2 headers
|
||||
BUILD_COMMAND ${Boost_SOURCE_DIR}/b2 install threading=multi -sNO_BZIP2=1 -sNO_ZLIB=1 link=static linkflags="-L${ICU_PATH}/lib -licuio -licuuc -licudata -licui18n" cxxflags=-fPIC boost.locale.iconv=off boost.locale.posix=off boost.locale.icu=on boost.locale.std=off -sICU_PATH=${ICU_PATH} --prefix=<INSTALL_DIR>
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_IN_SOURCE 1
|
||||
)
|
||||
set(DEPENDS ${DEPENDS} Boost)
|
||||
ExternalProject_Get_Property(Boost INSTALL_DIR)
|
||||
set(OPTIONS "${OPTIONS} --with-boost=${INSTALL_DIR}")
|
||||
set(LDFLAGS "${LDFLAGS} -L${INSTALL_DIR}/lib")
|
||||
set(CPPFLAGS "${CPPFLAGS} -I${INSTALL_DIR}/include")
|
||||
set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${Boost_SOURCE_DIR}/bin.v2)
|
||||
endif(Boost_ADDED)
|
||||
|
||||
set(CPPFLAGS "${CPPFLAGS} -Wno-parentheses -Wno-unused-local-typedefs -Wno-deprecated -Wno-implicit-fallthrough -Wno-unused-parameter")
|
||||
|
||||
separate_arguments(OPTIONS)
|
||||
|
||||
ExternalProject_Add(lbrycrdd
|
||||
PREFIX lbrycrdd
|
||||
DEPENDS ${DEPENDS}
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..
|
||||
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../../autogen.sh
|
||||
&& ${CMAKE_CURRENT_SOURCE_DIR}/../../configure ${OPTIONS} CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS} --prefix=<INSTALL_DIR>
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_ALWAYS 1
|
||||
)
|
210
contrib/cmake/cmake/CPM.cmake
Normal file
|
@ -0,0 +1,210 @@
|
|||
# TheLartians/CPM - A simple Git dependency manager
|
||||
# =================================================
|
||||
# See https://github.com/TheLartians/CPM for usage and update instructions.
|
||||
#
|
||||
# MIT License
|
||||
# -----------
|
||||
#[[
|
||||
Copyright (c) 2019 Lars Melchior
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
]]
|
||||
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
||||
|
||||
set(CURRENT_CPM_VERSION 0.11.1)
|
||||
|
||||
if(CPM_DIRECTORY)
|
||||
if(NOT ${CPM_DIRECTORY} MATCHES ${CMAKE_CURRENT_LIST_DIR})
|
||||
if (${CPM_VERSION} VERSION_LESS ${CURRENT_CPM_VERSION})
|
||||
CPM_HANDLE_OLD_VERSION(${CURRENT_CPM_VERSION})
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CPM_VERSION ${CURRENT_CPM_VERSION} CACHE INTERNAL "")
|
||||
set(CPM_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "")
|
||||
set(CPM_PACKAGES "" CACHE INTERNAL "")
|
||||
|
||||
option(CPM_USE_LOCAL_PACKAGES "Use locally installed packages (find_package)" ON)
|
||||
option(CPM_LOCAL_PACKAGES_ONLY "Use only locally installed packages" OFF)
|
||||
|
||||
include(FetchContent)
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# Initialize logging prefix
|
||||
if(NOT CPM_INDENT)
|
||||
set(CPM_INDENT "CPM:")
|
||||
endif()
|
||||
|
||||
# The main workhorse of CPM
|
||||
function(CPMAddPackage)
|
||||
|
||||
set(oneValueArgs
|
||||
NAME
|
||||
VERSION
|
||||
GIT_TAG
|
||||
DOWNLOAD_ONLY
|
||||
GITHUB_REPOSITORY
|
||||
GITLAB_REPOSITORY
|
||||
)
|
||||
|
||||
set(multiValueArgs
|
||||
OPTIONS
|
||||
COMPONENTS
|
||||
)
|
||||
|
||||
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(${CPM_USE_LOCAL_PACKAGES} OR ${CPM_LOCAL_PACKAGES_ONLY})
|
||||
find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION} OPTIONAL_COMPONENTS ${CPM_ARGS_COMPONENTS} QUIET)
|
||||
|
||||
if(${CPM_ARGS_NAME}_FOUND)
|
||||
message(STATUS "CPM: adding local package ${CPM_ARGS_NAME}@${${CPM_ARGS_NAME}_VERSION}")
|
||||
set(${CPM_ARGS_NAME}_VERSION "${${CPM_ARGS_NAME}_VERSION}" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(${CPM_LOCAL_PACKAGES_ONLY})
|
||||
message(SEND_ERROR "CPM: ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT CPM_ARGS_VERSION)
|
||||
set(CPM_ARGS_VERSION 0)
|
||||
endif()
|
||||
|
||||
if (NOT CPM_ARGS_GIT_TAG)
|
||||
set(CPM_ARGS_GIT_TAG v${CPM_ARGS_VERSION})
|
||||
endif()
|
||||
|
||||
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_TAG ${CPM_ARGS_GIT_TAG})
|
||||
|
||||
if(CPM_ARGS_DOWNLOAD_ONLY)
|
||||
set(DOWNLOAD_ONLY ${CPM_ARGS_DOWNLOAD_ONLY})
|
||||
else()
|
||||
set(DOWNLOAD_ONLY NO)
|
||||
endif()
|
||||
|
||||
if (CPM_ARGS_GITHUB_REPOSITORY)
|
||||
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_REPOSITORY "https://github.com/${CPM_ARGS_GITHUB_REPOSITORY}.git")
|
||||
endif()
|
||||
|
||||
if (CPM_ARGS_GITLAB_REPOSITORY)
|
||||
list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_REPOSITORY "https://gitlab.com/${CPM_ARGS_GITLAB_REPOSITORY}.git")
|
||||
endif()
|
||||
|
||||
if (${CPM_ARGS_NAME} IN_LIST CPM_PACKAGES)
|
||||
CPM_GET_PACKAGE_VERSION(${CPM_ARGS_NAME})
|
||||
if(${CPM_PACKAGE_VERSION} VERSION_LESS ${CPM_ARGS_VERSION})
|
||||
message(WARNING "${CPM_INDENT} requires a newer version of ${CPM_ARGS_NAME} (${CPM_ARGS_VERSION}) than currently included (${CPM_PACKAGE_VERSION}).")
|
||||
endif()
|
||||
if (CPM_ARGS_OPTIONS)
|
||||
foreach(OPTION ${CPM_ARGS_OPTIONS})
|
||||
CPM_PARSE_OPTION(${OPTION})
|
||||
if(NOT "${${OPTION_KEY}}" STREQUAL ${OPTION_VALUE})
|
||||
message(WARNING "${CPM_INDENT} ignoring package option for ${CPM_ARGS_NAME}: ${OPTION_KEY} = ${OPTION_VALUE} (${${OPTION_KEY}})")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
CPM_FETCH_PACKAGE(${CPM_ARGS_NAME} ${DOWNLOAD_ONLY})
|
||||
CPMGetProperties(${CPM_ARGS_NAME})
|
||||
set(${CPM_ARGS_NAME}_VERSION ${CPM_ARGS_VERSION} PARENT_SCOPE)
|
||||
set(${CPM_ARGS_NAME}_SOURCE_DIR "${${CPM_ARGS_NAME}_SOURCE_DIR}" PARENT_SCOPE)
|
||||
set(${CPM_ARGS_NAME}_BINARY_DIR "${${CPM_ARGS_NAME}_BINARY_DIR}" PARENT_SCOPE)
|
||||
set(${CPM_ARGS_NAME}_ADDED NO PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
CPMRegisterPackage(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})
|
||||
|
||||
if (CPM_ARGS_OPTIONS)
|
||||
foreach(OPTION ${CPM_ARGS_OPTIONS})
|
||||
CPM_PARSE_OPTION(${OPTION})
|
||||
set(${OPTION_KEY} ${OPTION_VALUE} CACHE INTERNAL "")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
CPM_DECLARE_PACKAGE(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION} ${CPM_ARGS_GIT_TAG} "${CPM_ARGS_UNPARSED_ARGUMENTS}")
|
||||
CPM_FETCH_PACKAGE(${CPM_ARGS_NAME} ${DOWNLOAD_ONLY})
|
||||
CPMGetProperties(${CPM_ARGS_NAME})
|
||||
set(${CPM_ARGS_NAME}_VERSION ${CPM_ARGS_VERSION} PARENT_SCOPE)
|
||||
set(${CPM_ARGS_NAME}_SOURCE_DIR "${${CPM_ARGS_NAME}_SOURCE_DIR}" PARENT_SCOPE)
|
||||
set(${CPM_ARGS_NAME}_BINARY_DIR "${${CPM_ARGS_NAME}_BINARY_DIR}" PARENT_SCOPE)
|
||||
set(${CPM_ARGS_NAME}_ADDED YES PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function (CPM_DECLARE_PACKAGE PACKAGE VERSION GIT_TAG)
|
||||
message(STATUS "${CPM_INDENT} adding package ${PACKAGE}@${VERSION} (${GIT_TAG})")
|
||||
|
||||
FetchContent_Declare(
|
||||
${PACKAGE}
|
||||
${ARGN}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function (CPM_FETCH_PACKAGE PACKAGE DOWNLOAD_ONLY)
|
||||
set(CPM_OLD_INDENT "${CPM_INDENT}")
|
||||
set(CPM_INDENT "${CPM_INDENT} ${PACKAGE}:")
|
||||
if(${DOWNLOAD_ONLY})
|
||||
if(NOT "${PACKAGE}_POPULATED")
|
||||
FetchContent_Populate(${PACKAGE})
|
||||
endif()
|
||||
else()
|
||||
FetchContent_MakeAvailable(${PACKAGE})
|
||||
endif()
|
||||
set(CPM_INDENT "${CPM_OLD_INDENT}")
|
||||
endfunction()
|
||||
|
||||
function (CPMGetProperties PACKAGE)
|
||||
FetchContent_GetProperties(${PACKAGE})
|
||||
string(TOLOWER ${PACKAGE} lpackage)
|
||||
set(${PACKAGE}_SOURCE_DIR "${${lpackage}_SOURCE_DIR}" PARENT_SCOPE)
|
||||
set(${PACKAGE}_BINARY_DIR "${${lpackage}_BINARY_DIR}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(CPMRegisterPackage PACKAGE VERSION)
|
||||
list(APPEND CPM_PACKAGES ${PACKAGE})
|
||||
set(CPM_PACKAGES ${CPM_PACKAGES} CACHE INTERNAL "")
|
||||
set("CPM_PACKAGE_${PACKAGE}_VERSION" ${VERSION} CACHE INTERNAL "")
|
||||
endfunction()
|
||||
|
||||
function(CPM_GET_PACKAGE_VERSION PACKAGE)
|
||||
set(CPM_PACKAGE_VERSION "${CPM_PACKAGE_${PACKAGE}_VERSION}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(CPM_PARSE_OPTION OPTION)
|
||||
string(REGEX MATCH "^[^ ]+" OPTION_KEY ${OPTION})
|
||||
string(LENGTH ${OPTION_KEY} OPTION_KEY_LENGTH)
|
||||
math(EXPR OPTION_KEY_LENGTH "${OPTION_KEY_LENGTH}+1")
|
||||
string(SUBSTRING ${OPTION} "${OPTION_KEY_LENGTH}" "-1" OPTION_VALUE)
|
||||
set(OPTION_KEY "${OPTION_KEY}" PARENT_SCOPE)
|
||||
set(OPTION_VALUE "${OPTION_VALUE}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function (CPM_HANDLE_OLD_VERSION NEW_CPM_VERSION)
|
||||
|
||||
message(AUTHOR_WARNING "${CPM_INDENT} \
|
||||
A dependency is using a more recent CPM (${NEW_CPM_VERSION}) than the current project (${CPM_VERSION}). \
|
||||
It is recommended to upgrade CPM to the most recent version. \
|
||||
See https://github.com/TheLartians/CPM for more information."
|
||||
)
|
||||
|
||||
endfunction()
|
171
contrib/cmake/cmake/FindBerkeleyDB.cmake
Normal file
|
@ -0,0 +1,171 @@
|
|||
# Author: sum01 <sum01@protonmail.com>
|
||||
# Git: https://github.com/sum01/FindBerkeleyDB
|
||||
# Read the README.md for the full info.
|
||||
|
||||
# NOTE: If Berkeley DB ever gets a Pkg-config ".pc" file, add pkg_check_modules() here
|
||||
|
||||
# Checks if environment paths are empty, set them if they aren't
|
||||
if(NOT "$ENV{BERKELEYDB_ROOT}" STREQUAL "")
|
||||
set(_BERKELEYDB_HINTS "$ENV{BERKELEYDB_ROOT}")
|
||||
elseif(NOT "$ENV{Berkeleydb_ROOT}" STREQUAL "")
|
||||
set(_BERKELEYDB_HINTS "$ENV{Berkeleydb_ROOT}")
|
||||
elseif(NOT "$ENV{BERKELEYDBROOT}" STREQUAL "")
|
||||
set(_BERKELEYDB_HINTS "$ENV{BERKELEYDBROOT}")
|
||||
else()
|
||||
# Set just in case, as it's used regardless if it's empty or not
|
||||
set(_BERKELEYDB_HINTS "")
|
||||
endif()
|
||||
|
||||
# Allow user to pass a path instead of guessing
|
||||
if(BerkeleyDB_ROOT_DIR)
|
||||
set(_BERKELEYDB_PATHS "${BerkeleyDB_ROOT_DIR}")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*[wW]indows.*")
|
||||
# MATCHES is used to work on any devies with windows in the name
|
||||
# Shameless copy-paste from FindOpenSSL.cmake v3.8
|
||||
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
||||
list(APPEND _BERKELEYDB_HINTS "${_programfiles}")
|
||||
|
||||
# There's actually production release and version numbers in the file path.
|
||||
# For example, if they're on v6.2.32: C:/Program Files/Oracle/Berkeley DB 12cR1 6.2.32/
|
||||
# But this still works to find it, so I'm guessing it can accept partial path matches.
|
||||
|
||||
foreach(_TARGET_BERKELEYDB_PATH "Oracle/Berkeley DB" "Berkeley DB")
|
||||
list(APPEND _BERKELEYDB_PATHS
|
||||
"${_programfiles}/${_TARGET_BERKELEYDB_PATH}"
|
||||
"C:/Program Files (x86)/${_TARGET_BERKELEYDB_PATH}"
|
||||
"C:/Program Files/${_TARGET_BERKELEYDB_PATH}"
|
||||
"C:/${_TARGET_BERKELEYDB_PATH}"
|
||||
)
|
||||
endforeach()
|
||||
else()
|
||||
# Paths for anything other than Windows
|
||||
# Cellar/berkeley-db is for macOS from homebrew installation
|
||||
list(APPEND _BERKELEYDB_PATHS
|
||||
"/usr"
|
||||
"/usr/local"
|
||||
"/usr/local/Cellar/berkeley-db"
|
||||
"/opt"
|
||||
"/opt/local"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Find includes path
|
||||
find_path(BerkeleyDB_INCLUDE_DIRS
|
||||
NAMES "db.h"
|
||||
HINTS ${_BERKELEYDB_HINTS}
|
||||
PATH_SUFFIXES "include" "includes"
|
||||
PATHS ${_BERKELEYDB_PATHS}
|
||||
)
|
||||
|
||||
# Checks if the version file exists, save the version file to a var, and fail if there's no version file
|
||||
if(BerkeleyDB_INCLUDE_DIRS)
|
||||
# Read the version file db.h into a variable
|
||||
file(READ "${BerkeleyDB_INCLUDE_DIRS}/db.h" _BERKELEYDB_DB_HEADER)
|
||||
# Parse the DB version into variables to be used in the lib names
|
||||
string(REGEX REPLACE ".*DB_VERSION_MAJOR ([0-9]+).*" "\\1" BerkeleyDB_VERSION_MAJOR "${_BERKELEYDB_DB_HEADER}")
|
||||
string(REGEX REPLACE ".*DB_VERSION_MINOR ([0-9]+).*" "\\1" BerkeleyDB_VERSION_MINOR "${_BERKELEYDB_DB_HEADER}")
|
||||
# Patch version example on non-crypto installs: x.x.xNC
|
||||
string(REGEX REPLACE ".*DB_VERSION_PATCH ([0-9]+(NC)?).*" "\\1" BerkeleyDB_VERSION_PATCH "${_BERKELEYDB_DB_HEADER}")
|
||||
else()
|
||||
if(BerkeleyDB_FIND_REQUIRED)
|
||||
# If the find_package(BerkeleyDB REQUIRED) was used, fail since we couldn't find the header
|
||||
message(FATAL_ERROR "Failed to find Berkeley DB's header file \"db.h\"! Try setting \"BerkeleyDB_ROOT_DIR\" when initiating Cmake.")
|
||||
elseif(NOT BerkeleyDB_FIND_QUIETLY)
|
||||
message(WARNING "Failed to find Berkeley DB's header file \"db.h\"! Try setting \"BerkeleyDB_ROOT_DIR\" when initiating Cmake.")
|
||||
endif()
|
||||
# Set some garbage values to the versions since we didn't find a file to read
|
||||
set(BerkeleyDB_VERSION_MAJOR "0")
|
||||
set(BerkeleyDB_VERSION_MINOR "0")
|
||||
set(BerkeleyDB_VERSION_PATCH "0")
|
||||
endif()
|
||||
|
||||
# The actual returned/output version variable (the others can be used if needed)
|
||||
set(BerkeleyDB_VERSION "${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}.${BerkeleyDB_VERSION_PATCH}")
|
||||
|
||||
# Finds the target library for berkeley db, since they all follow the same naming conventions
|
||||
macro(_berkeleydb_get_lib _BERKELEYDB_OUTPUT_VARNAME _TARGET_BERKELEYDB_LIB)
|
||||
# Different systems sometimes have a version in the lib name...
|
||||
# and some have a dash or underscore before the versions.
|
||||
# CMake recommends to put unversioned names before versioned names
|
||||
find_library(${_BERKELEYDB_OUTPUT_VARNAME}
|
||||
NAMES
|
||||
"${_TARGET_BERKELEYDB_LIB}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}-${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}_${BerkeleyDB_VERSION_MAJOR}.${BerkeleyDB_VERSION_MINOR}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}${BerkeleyDB_VERSION_MAJOR}${BerkeleyDB_VERSION_MINOR}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}-${BerkeleyDB_VERSION_MAJOR}${BerkeleyDB_VERSION_MINOR}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}_${BerkeleyDB_VERSION_MAJOR}${BerkeleyDB_VERSION_MINOR}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}${BerkeleyDB_VERSION_MAJOR}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}-${BerkeleyDB_VERSION_MAJOR}"
|
||||
"lib${_TARGET_BERKELEYDB_LIB}_${BerkeleyDB_VERSION_MAJOR}"
|
||||
HINTS ${_BERKELEYDB_HINTS}
|
||||
PATH_SUFFIXES
|
||||
"lib"
|
||||
"lib64"
|
||||
"libs"
|
||||
"libs64"
|
||||
PATHS ${_BERKELEYDB_PATHS}
|
||||
)
|
||||
# If the library was found, add it to our list of libraries
|
||||
if(${_BERKELEYDB_OUTPUT_VARNAME})
|
||||
# If found, append to our libraries variable
|
||||
# The ${{}} is because the first expands to target the real variable, the second expands the variable's contents...
|
||||
# and the real variable's contents is the path to the lib. Thus, it appends the path of the lib to BerkeleyDB_LIBRARIES.
|
||||
list(APPEND BerkeleyDB_LIBRARIES "${${_BERKELEYDB_OUTPUT_VARNAME}}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Find and set the paths of the specific library to the variable
|
||||
_berkeleydb_get_lib(BerkeleyDB_LIBRARY "db")
|
||||
# NOTE: Windows doesn't have a db_cxx lib, but instead compiles the cxx code into the "db" lib
|
||||
_berkeleydb_get_lib(BerkeleyDB_Cxx_LIBRARY "db_cxx")
|
||||
# NOTE: I don't think Linux/Unix gets an SQL lib
|
||||
_berkeleydb_get_lib(BerkeleyDB_Sql_LIBRARY "db_sql")
|
||||
_berkeleydb_get_lib(BerkeleyDB_Stl_LIBRARY "db_stl")
|
||||
|
||||
# Needed for find_package_handle_standard_args()
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# Fails if required vars aren't found, or if the version doesn't meet specifications.
|
||||
find_package_handle_standard_args(BerkeleyDB
|
||||
FOUND_VAR BerkeleyDB_FOUND
|
||||
REQUIRED_VARS
|
||||
BerkeleyDB_INCLUDE_DIRS
|
||||
BerkeleyDB_LIBRARY
|
||||
BerkeleyDB_LIBRARIES
|
||||
VERSION_VAR BerkeleyDB_VERSION
|
||||
)
|
||||
|
||||
# Only show the variables in the GUI if they click "advanced".
|
||||
# Does nothing when using the CLI
|
||||
mark_as_advanced(FORCE
|
||||
BerkeleyDB_FOUND
|
||||
BerkeleyDB_INCLUDE_DIRS
|
||||
BerkeleyDB_LIBRARIES
|
||||
BerkeleyDB_VERSION
|
||||
BerkeleyDB_VERSION_MAJOR
|
||||
BerkeleyDB_VERSION_MINOR
|
||||
BerkeleyDB_VERSION_PATCH
|
||||
BerkeleyDB_LIBRARY
|
||||
BerkeleyDB_Cxx_LIBRARY
|
||||
BerkeleyDB_Stl_LIBRARY
|
||||
BerkeleyDB_Sql_LIBRARY
|
||||
)
|
||||
|
||||
# Create an imported lib for easy linking by external projects
|
||||
if(BerkeleyDB_FOUND AND BerkeleyDB_LIBRARIES AND NOT TARGET Oracle::BerkeleyDB)
|
||||
add_library(Oracle::BerkeleyDB UNKNOWN IMPORTED)
|
||||
set_target_properties(Oracle::BerkeleyDB PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${BerkeleyDB_INCLUDE_DIRS}"
|
||||
IMPORTED_LOCATION "${BerkeleyDB_LIBRARY}"
|
||||
INTERFACE_LINK_LIBRARIES "${BerkeleyDB_LIBRARIES}"
|
||||
)
|
||||
endif()
|
||||
|
||||
include(FindPackageMessage)
|
||||
# A message that tells the user what includes/libs were found, and obeys the QUIET command.
|
||||
find_package_message(BerkeleyDB
|
||||
"Found BerkeleyDB libraries: ${BerkeleyDB_LIBRARIES}"
|
||||
"[${BerkeleyDB_LIBRARIES}[${BerkeleyDB_INCLUDE_DIRS}]]"
|
||||
)
|
97
contrib/cmake/cmake/FindLibevent.cmake
Normal file
|
@ -0,0 +1,97 @@
|
|||
# - Try to find libevent
|
||||
#.rst
|
||||
# FindLibevent
|
||||
# ------------
|
||||
#
|
||||
# Find Libevent include directories and libraries. Invoke as::
|
||||
#
|
||||
# find_package(Libevent
|
||||
# [version] [EXACT] # Minimum or exact version
|
||||
# [REQUIRED] # Fail if Libevent is not found
|
||||
# [COMPONENT <C>...]) # Libraries to look for
|
||||
#
|
||||
# Valid components are one or more of:: libevent core extra pthreads openssl.
|
||||
# Note that 'libevent' contains both core and extra. You must specify one of
|
||||
# them for the other components.
|
||||
#
|
||||
# This module will define the following variables::
|
||||
#
|
||||
# LIBEVENT_FOUND - True if headers and requested libraries were found
|
||||
# LIBEVENT_INCLUDE_DIRS - Libevent include directories
|
||||
# LIBEVENT_LIBRARIES - Libevent libraries to be linked
|
||||
# LIBEVENT_<C>_FOUND - Component <C> was found (<C> is uppercase)
|
||||
# LIBEVENT_<C>_LIBRARY - Library to be linked for Libevent component <C>.
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_LIBEVENT QUIET libevent)
|
||||
|
||||
# Look for the Libevent 2.0 or 1.4 headers
|
||||
find_path(LIBEVENT_INCLUDE_DIR
|
||||
NAMES
|
||||
event2/event-config.h
|
||||
event-config.h
|
||||
HINTS
|
||||
${PC_LIBEVENT_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
if(LIBEVENT_INCLUDE_DIR)
|
||||
set(_version_regex "^#define[ \t]+_EVENT_VERSION[ \t]+\"([^\"]+)\".*")
|
||||
if(EXISTS "${LIBEVENT_INCLUDE_DIR}/event2/event-config.h")
|
||||
# Libevent 2.0
|
||||
file(STRINGS "${LIBEVENT_INCLUDE_DIR}/event2/event-config.h"
|
||||
LIBEVENT_VERSION REGEX "${_version_regex}")
|
||||
if("${LIBEVENT_VERSION}" STREQUAL "")
|
||||
set(LIBEVENT_VERSION ${PC_LIBEVENT_VERSION})
|
||||
endif()
|
||||
else()
|
||||
# Libevent 1.4
|
||||
file(STRINGS "${LIBEVENT_INCLUDE_DIR}/event-config.h"
|
||||
LIBEVENT_VERSION REGEX "${_version_regex}")
|
||||
endif()
|
||||
string(REGEX REPLACE "${_version_regex}" "\\1"
|
||||
LIBEVENT_VERSION "${LIBEVENT_VERSION}")
|
||||
unset(_version_regex)
|
||||
endif()
|
||||
|
||||
set(_LIBEVENT_REQUIRED_VARS)
|
||||
foreach(COMPONENT ${Libevent_FIND_COMPONENTS})
|
||||
set(_LIBEVENT_LIBNAME libevent)
|
||||
# Note: compare two variables to avoid a CMP0054 policy warning
|
||||
if(COMPONENT STREQUAL _LIBEVENT_LIBNAME)
|
||||
set(_LIBEVENT_LIBNAME event)
|
||||
else()
|
||||
set(_LIBEVENT_LIBNAME "event_${COMPONENT}")
|
||||
endif()
|
||||
string(TOUPPER "${COMPONENT}" COMPONENT_UPPER)
|
||||
find_library(LIBEVENT_${COMPONENT_UPPER}_LIBRARY
|
||||
NAMES ${_LIBEVENT_LIBNAME}
|
||||
HINTS ${PC_LIBEVENT_LIBRARY_DIRS}
|
||||
)
|
||||
if(LIBEVENT_${COMPONENT_UPPER}_LIBRARY)
|
||||
set(Libevent_${COMPONENT}_FOUND 1)
|
||||
endif()
|
||||
list(APPEND _LIBEVENT_REQUIRED_VARS LIBEVENT_${COMPONENT_UPPER}_LIBRARY)
|
||||
endforeach()
|
||||
unset(_LIBEVENT_LIBNAME)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LIBEVENT_FOUND to TRUE
|
||||
# if all listed variables are TRUE and the requested version matches.
|
||||
find_package_handle_standard_args(Libevent REQUIRED_VARS
|
||||
${_LIBEVENT_REQUIRED_VARS}
|
||||
LIBEVENT_INCLUDE_DIR
|
||||
VERSION_VAR LIBEVENT_VERSION
|
||||
HANDLE_COMPONENTS)
|
||||
|
||||
if(LIBEVENT_FOUND)
|
||||
set(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR})
|
||||
set(LIBEVENT_LIBRARIES)
|
||||
foreach(COMPONENT ${Libevent_FIND_COMPONENTS})
|
||||
string(TOUPPER "${COMPONENT}" COMPONENT_UPPER)
|
||||
list(APPEND LIBEVENT_LIBRARIES ${LIBEVENT_${COMPONENT_UPPER}_LIBRARY})
|
||||
set(LIBEVENT_${COMPONENT_UPPER}_FOUND ${Libevent_${COMPONENT}_FOUND})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(LIBEVENT_INCLUDE_DIR ${_LIBEVENT_REQUIRED_VARS})
|
||||
unset(_LIBEVENT_REQUIRED_VARS)
|
The "depends" system uses
sed
instead ofpatch
to achieve this. It doesn't need the extra file. Thesed
approach seems superior to me.