Tweak CMake files for cURL
authorsfan5 <sfan5@live.de>
Mon, 17 Dec 2012 19:57:30 +0000 (20:57 +0100)
committerIlya Zhuravlev <zhuravlevilya@ya.ru>
Tue, 18 Dec 2012 17:52:56 +0000 (21:52 +0400)
cmake/Modules/FindCURL.cmake
src/CMakeLists.txt

index ec0503fd901579704985d2a8e0781e853a39ccc9..03ca4e0fab9b5e419ce97ec2ae94c966f3656de2 100644 (file)
@@ -5,13 +5,38 @@
 #  CURL_LIBRARY    - List of libraries when using curl.
 #  CURL_FOUND        - True if curl found.
 
-# Look for the header file.
-FIND_PATH(CURL_INCLUDE_DIR NAMES curl/curl.h)
+if( UNIX )
+  FIND_PATH(CURL_INCLUDE_DIR NAMES curl.h
+    PATHS
+    /usr/local/include/curl
+    /usr/include/curl
+  )
 
-# Look for the library.
-FIND_LIBRARY(CURL_LIBRARY NAMES curl)
+  FIND_LIBRARY(CURL_LIBRARY NAMES libcurl.a curl
+    PATHS
+    /usr/local/lib
+    /usr/lib
+  )
+else( UNIX )
+  FIND_PATH(CURL_INCLUDE_DIR NAMES curl/curl.h) # Look for the header file.
+  FIND_LIBRARY(CURL_LIBRARY NAMES curl) # Look for the library.
+  INCLUDE(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if
+  FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL DEFAULT_MSG CURL_LIBRARY CURL_INCLUDE_DIR) # all listed variables are TRUE
+endif( UNIX )
 
-# handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if
-# all listed variables are TRUE
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL DEFAULT_MSG CURL_LIBRARY CURL_INCLUDE_DIR)
+if( WIN32 )
+  if( CURL_LIBRARY AND CURL_INCLUDE_DIR AND CURL_DLL ) # libcurl.dll is required on Windows
+    SET(CURL_FOUND TRUE)
+  else( CURL_LIBRARY AND CURL_INCLUDE_DIR AND CURL_DLL )
+    SET(CURL_FOUND FALSE)
+  endif( CURL_LIBRARY AND CURL_INCLUDE_DIR AND CURL_DLL )
+else ( WIN32 )
+  if( CURL_LIBRARY AND CURL_INCLUDE_DIR )
+    SET(CURL_FOUND TRUE)
+  else( CURL_LIBRARY AND CURL_INCLUDE_DIR )
+    SET(CURL_FOUND FALSE)
+  endif( CURL_LIBRARY AND CURL_INCLUDE_DIR )
+endif ( WIN32 )
+
+MESSAGE(STATUS "CURL_INCLUDE_DIR = ${CURL_INCLUDE_DIR}")
+MESSAGE(STATUS "CURL_LIBRARY = ${CURL_LIBRARY}")
index 38410f7d2d3b50fc94b1663023a80c996673c0f2..107f580cef7dff96adf1203a2bb04e7306d3187f 100644 (file)
@@ -12,7 +12,9 @@ if (NOT ENABLE_CURL)
        mark_as_advanced(CLEAR CURL_LIBRARY CURL_INCLUDE_DIR)
 endif(NOT ENABLE_CURL)
 
-find_package(CURL)
+if( ENABLE_CURL )
+       find_package(CURL)
+endif( ENABLE_CURL )
 set(USE_CURL 0)
 if (CURL_FOUND AND ENABLE_CURL)
        message(STATUS "cURL support enabled")
@@ -436,6 +438,9 @@ if(WIN32)
                if(VORBISFILE_DLL)
                        install(FILES ${VORBISFILE_DLL} DESTINATION ${BINDIR})
                endif()
+               if(CURL_DLL)
+                       install(FILES ${CURL_DLL} DESTINATION ${BINDIR})
+               endif()
        endif()
 endif()