From 5db592bcc2f643c87bbeee87719fe6f687119d74 Mon Sep 17 00:00:00 2001 From: 0x4D616E75 <0x4d616e75@elektronische-nachricht.de> Date: Thu, 17 May 2018 18:55:15 +0200 Subject: [PATCH] fix loading of CURL and Backtracing library with CMake (#215) to build on FreeBSD with default compiler (Clang 4.0) --- .circleci/config.yml | 2 +- CMakeLists.txt | 3 ++- README.md | 2 +- src/cpp-utils/CMakeLists.txt | 16 +++++++++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6d52cf7f..26e70bf6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,7 +49,7 @@ references: sudo chmod o-w /etc/apt/sources.list.d/clang.list DEBIAN_FRONTEND=noninteractive sudo apt-get update -qq - DEBIAN_FRONTEND=noninteractive sudo apt-get install -y git ccache $APT_COMPILER_PACKAGE cmake make libcurl4-openssl-dev libcrypto++-dev libssl-dev libfuse-dev python + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y git ccache $APT_COMPILER_PACKAGE cmake3 make libcurl4-openssl-dev libcrypto++-dev libssl-dev libfuse-dev python # Use /dev/urandom when /dev/random is accessed to use less entropy sudo cp -a /dev/urandom /dev/random diff --git a/CMakeLists.txt b/CMakeLists.txt index dbd2b5d7..9962ec91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +cmake_minimum_required(VERSION 3.0 FATAL_ERROR) +cmake_policy(VERSION 2.8) # note: for clang-tidy, we need cmake 3.6, or (if the return code should be handled correctly, e.g. on CI), we need 3.8. diff --git a/README.md b/README.md index b27087be..6c39ad18 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Requirements ------------ - Git (for getting the source code) - GCC version >= 4.8 or Clang >= 3.7 - - CMake version >= 2.8 + - CMake version >= 3.0 - libcurl4 (including development headers) - Boost libraries version >= 1.56 (including development headers) - filesystem diff --git a/src/cpp-utils/CMakeLists.txt b/src/cpp-utils/CMakeLists.txt index 089c201f..8b3a4fcd 100644 --- a/src/cpp-utils/CMakeLists.txt +++ b/src/cpp-utils/CMakeLists.txt @@ -50,7 +50,21 @@ set(SOURCES add_library(${PROJECT_NAME} STATIC ${SOURCES}) -target_link_libraries(${PROJECT_NAME} PUBLIC pthread curl) +find_package(CURL) +if(NOT ${CURL_FOUND}) + message(FATAL_ERROR "CURL library not found") +endif() +include_directories(${CURL_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${CURL_LIBRARIES}) + +find_package(Backtrace) +if(NOT ${Backtrace_FOUND}) + message(FATAL_ERROR "Backtrace library not found") +endif() +include_directories(${Backtrace_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${Backtrace_LIBRARIES}) + +target_link_libraries(${PROJECT_NAME} PUBLIC pthread) # TODO From Crypto++ 5.7 on, it should support cmake with find_package() instead of find_library(). find_library_with_path(CryptoPP cryptopp CRYPTOPP_LIB_PATH)