Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ add_subdirectory(extras)
# Seems simple.

message(STATUS "Looking for CURL")
find_package(CURL REQUIRED)
find_package(CURL)

if(CURL_FOUND)
message(STATUS "Found CURL version: ${CURL_VERSION_STRING}")
Expand All @@ -79,7 +79,24 @@ else()
message(STATUS "Fetching CURL")
include(FetchContent)
FetchContent_Declare(CURL GIT_REPOSITORY https://github.com/curl/curl.git)
FetchContent_MakeAvailable(CURL)
FetchContent_GetProperties(CURL)
if(NOT CURL_POPULATED)
FetchContent_Populate(CURL)
set(BUILD_CURL_EXE OFF CACHE BOOL "Disable building CURL executable")
set(BUILD_STATIC_CURL ON CACHE BOOL "Build CURL staticly")

set(BUILD_SHARED_LIBS_PREV ${BUILD_SHARED_LIBS})
set(BUILD_STATIC_LIBS_PREV ${BUILD_STATIC_LIBS})
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Disable building shared libs")
set(BUILD_STATIC_LIBS ON CACHE BOOL "Enable building static libs")
add_subdirectory(${curl_SOURCE_DIR} ${curl_BINARY_DIR})
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_PREV} CACHE BOOL "Restore BUILD_SHARED_LIBS" FORCE)
set(BUILD_STATIC_LIBS ${BUILD_STATIC_LIBS_PREV} CACHE BOOL "Restore BUILD_STATIC_LIBS" FORCE)
unset(BUILD_SHARED_LIBS_PREV)
unset(BUILD_STATIC_LIBS_PREV)
endif()
set(CURL_INCLUDE_DIRS "${curl_SOURCE_DIR}/include")
set(CURL_LIBRARIES "libcurl")
endif()

# All following targets should search these directories for headers
Expand Down