From 98d9f99624775129e850bed93d04a52e79c051da Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Wed, 18 Apr 2018 11:49:42 +0200 Subject: Make CURL Wrapping functions optional Search CURL package in your system and add it if found. This will add a libcurl to be linked with the target. Change-Id: Ie4a720fd11de97abead7a92a7fb18b5c8af21ec5 Signed-off-by: Romain Forlot --- CMakeLists.txt | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e1eb90..94a4cae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,10 @@ PROJECT_TARGET_ADD(afb-helpers) set(CMAKE_AUTOMOC ON) - set(AFB_HELPERS_SRCS curl-wrap.c escape.c wrap-json.c filescan-utils.c) + set(AFB_HELPERS_SRCS wrap-json.c filescan-utils.c escape.c) option(AFB_HELPERS_QTWSCLIENT "Enable the Qt's websocket client to Application Framework Binders" OFF) + find_package(CURL) if (AFB_HELPERS_QTWSCLIENT) message(STATUS "Qt's WebSocket AFB Client: Enabled!") @@ -35,7 +36,14 @@ set(CMAKE_AUTOMOC ON) message(STATUS "Qt's WebSocket AFB Client: Disabled!") endif() - # Define targets + if (CURL_FOUND) + message(STATUS "CURL wrapping helpers: Enabled!") + set(AFB_HELPERS_SRCS ${AFB_HELPERS_SRCS} curl-wrap.c) + else() + message(STATUS "CURL wrapping helpers: Disabled!") + endif() + + # Define targets ADD_LIBRARY(${TARGET_NAME} STATIC ${AFB_HELPERS_SRCS}) if (AFB_HELPERS_QTWSCLIENT) @@ -43,13 +51,17 @@ set(CMAKE_AUTOMOC ON) qt5_use_modules(${TARGET_NAME} WebSockets) endif() - # Library properties - SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES - OUTPUT_NAME ${TARGET_NAME} - ) + if (CURL_FOUND) + target_link_libraries(${TARGET_NAME} curl) + endif() + + # Library properties + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + OUTPUT_NAME ${TARGET_NAME} + ) - # Define target includes - TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - ) + # Define target includes + TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + ) -- cgit 1.2.3-korg