aboutsummaryrefslogtreecommitdiff
path: root/cmake/FindLibcurl.cmake
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2021-05-18 11:42:27 +0200
committerJan200101 <sentrycraft123@gmail.com>2021-05-18 11:44:22 +0200
commit8e7d62f14bd401e4cc8737c06f16e6978b0b9e57 (patch)
tree94a3352969e287e5ac6040d2d2829e9656f4d492 /cmake/FindLibcurl.cmake
parent52f8abc09b0d97608ba9d5b57ea96c48a1390384 (diff)
downloadpolecat-8e7d62f14bd401e4cc8737c06f16e6978b0b9e57.tar.gz
polecat-8e7d62f14bd401e4cc8737c06f16e6978b0b9e57.zip
improve cmake files, add simple curl mock, clean up on download error
Diffstat (limited to 'cmake/FindLibcurl.cmake')
-rw-r--r--cmake/FindLibcurl.cmake74
1 files changed, 43 insertions, 31 deletions
diff --git a/cmake/FindLibcurl.cmake b/cmake/FindLibcurl.cmake
index fbe6505..aa89105 100644
--- a/cmake/FindLibcurl.cmake
+++ b/cmake/FindLibcurl.cmake
@@ -1,46 +1,58 @@
#
# LIBCURL_INCLUDE_DIRS
# LIBCURL_LIBRARIES
+# LIBCURL_CFLAGS
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
- pkg_check_modules(_CURL REQUIRED QUIET libcurl)
+ pkg_check_modules(_CURL libcurl)
+
+ if (BUILD_STATIC AND NOT _CURL_FOUND)
+ message(FATAL_ERROR "Cannot find static build information")
+ endif()
endif()
-if(CMAKE_SIZEOF_VOID_P EQUAL 8)
- set(_lib_suffix 64)
+if (_CURL_FOUND) # we can rely on pkg-config
+ if (NOT BUILD_STATIC)
+ set(LIBCURL_LIBRARIES ${_CURL_LIBRARIES})
+ set(LIBCURL_INCLUDE_DIRS ${_CURL_INCLUDE_DIRS})
+ set(LIBCURL_CFLAGS ${_CURL_CFLAGS_OTHER})
+ else()
+ set(LIBCURL_LIBRARIES ${_CURL_STATIC_LIBRARIES})
+ set(LIBCURL_INCLUDE_DIRS ${_CURL_STATIC_INCLUDE_DIRS})
+ set(LIBCURL_CFLAGS ${_CURL_STATIC_CFLAGS_OTHER})
+ endif()
else()
- set(_lib_suffix 32)
-endif()
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_lib_suffix 64)
+ else()
+ set(_lib_suffix 32)
+ endif()
-find_path(CURL_INC
- NAMES curl/curl.h
- HINTS
- ENV curlPath${_lib_suffix}
- ENV curlPath
- ${_CURL_INCLUDE_DIRS}
- PATHS
- /usr/include /usr/local/include)
+ find_path(CURL_INC
+ NAMES curl/curl.h
+ HINTS
+ ENV curlPath${_lib_suffix}
+ ENV curlPath
+ PATHS
+ /usr/include /usr/local/include)
-find_library(CURL_LIB
- NAMES ${_CURL_LIBRARIES} curl libcurl
- HINTS
- ENV curlPath${_lib_suffix}
- ENV curlPath
- ${_CURL_LIBRARY_DIRS}
- ${_CURL_STATIC_LIBRARY_DIRS}
- PATHS
- /usr/lib /usr/local/lib)
+ find_library(CURL_LIB
+ NAMES curl
+ HINTS
+ ENV curlPath${_lib_suffix}
+ ENV curlPath
+ PATHS
+ /usr/lib{_lib_suffix} /usr/local/lib{_lib_suffix}
+ /usr/lib /usr/local/lib)
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Libcurl DEFAULT_MSG CURL_LIB CURL_INC)
-mark_as_advanced(CURL_INC CURL_LIB)
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Libcurl DEFAULT_MSG CURL_LIB CURL_INC)
+ mark_as_advanced(CURL_INC CURL_LIB)
-if(LIBCURL_FOUND)
- set(LIBCURL_INCLUDE_DIRS ${CURL_INC})
- set(LIBCURL_LIBRARIES ${CURL_LIB})
- if (BUILD_STATIC)
- set(LIBCURL_LIBRARIES ${LIBCURL_LIBRARIES} ${_CURL_STATIC_LIBRARIES})
- add_compile_definitions(CURL_STATICLIB)
+ if(LIBCURL_FOUND)
+ set(LIBCURL_INCLUDE_DIRS ${CURL_INC})
+ set(LIBCURL_LIBRARIES ${CURL_LIB})
+ set(LIBCURL_CFLAGS "")
endif()
endif() \ No newline at end of file