From a6796cb44452dac31d287373a6898ac10cf98b26 Mon Sep 17 00:00:00 2001 From: dhewg Date: Sat, 14 Jan 2012 14:24:28 +0100 Subject: [PATCH] CMake: Detect libcurl and use it when found Move ID_ENABLE_CURL to config.h --- CMakeLists.txt | 10 +++++----- config.h.in | 2 ++ framework/BuildDefines.h | 4 ---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9731860..b163c83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ option(GAME "Build the base game code" ON) option(D3XP "Build the d3xp game code" OFF) option(DEDICATED "Build the dedicated server" OFF) option(X86 "Cross compile for x86 (only applicable on x86_64)" OFF) -option(CURL "Enable usage of libcurl for http/ftp downloads" OFF) option(ONATIVE "Optimize for the host CPU" OFF) if (NOT CMAKE_SYSTEM_PROCESSOR) @@ -108,12 +107,13 @@ include_directories(${OPENGL_INCLUDE_DIR}) find_package(SDL REQUIRED) include_directories(${SDL_INCLUDE_DIR}) -if (CURL) - find_package(CURL REQUIRED) - add_definitions(-DID_ENABLE_CURL=1) +find_package(CURL QUIET) +if (CURL_FOUND) + set(ID_ENABLE_CURL ON) include_directories(${CURL_INCLUDE_DIR}) else() - add_definitions(-DID_ENABLE_CURL=0) + message(STATUS "libcurl not found, server downloads won't be available") + set(ID_ENABLE_CURL OFF) endif() # compiler specific flags diff --git a/config.h.in b/config.h.in index a6cc325..35b77af 100644 --- a/config.h.in +++ b/config.h.in @@ -3,4 +3,6 @@ #cmakedefine HAVE_JPEG_MEM_SRC +#cmakedefine ID_ENABLE_CURL + #endif diff --git a/framework/BuildDefines.h b/framework/BuildDefines.h index 0944810..309ef6b 100644 --- a/framework/BuildDefines.h +++ b/framework/BuildDefines.h @@ -60,10 +60,6 @@ If you have questions concerning this license or the applicable additional terms #define ID_ALLOW_CHEATS 0 #endif -#ifndef ID_ENABLE_CURL - #define ID_ENABLE_CURL 1 -#endif - // fake a pure client. useful to connect an all-debug client to a server #ifndef ID_FAKE_PURE #define ID_FAKE_PURE 0