mirror of
https://github.com/BlackMATov/curly.hpp.git
synced 2025-12-16 14:11:17 +07:00
add static CRT option. add option descriptions to README.
This commit is contained in:
@@ -7,11 +7,49 @@ endif()
|
||||
|
||||
project(curly.hpp)
|
||||
|
||||
option(CURLY_USE_SYSTEM_CURL "Build with cURL from system paths" OFF)
|
||||
option(CURLY_USE_EMBEDDED_CURL "Build with embedded cURL library" ON)
|
||||
option(USE_STATIC_CRT "Use static C runtime library" OFF)
|
||||
option(USE_SYSTEM_CURL "Build with cURL from system paths" OFF)
|
||||
option(USE_EMBEDDED_CURL "Build with embedded cURL library" ON)
|
||||
|
||||
# set(CURLY_USE_SYSTEM_CURL ON CACHE BOOL "" FORCE)
|
||||
# set(CURLY_USE_EMBEDDED_CURL ON CACHE BOOL "" FORCE)
|
||||
#
|
||||
# linking
|
||||
#
|
||||
|
||||
if(MSVC AND USE_STATIC_CRT)
|
||||
foreach(flag CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||
endif()
|
||||
if(${flag} MATCHES "/MDd")
|
||||
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
#
|
||||
# coverage
|
||||
#
|
||||
|
||||
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
|
||||
if(BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"))
|
||||
set(COVERAGE_FLAGS "--coverage")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
endif()
|
||||
|
||||
#
|
||||
# library
|
||||
#
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC
|
||||
headers/curly.hpp/curly.hpp
|
||||
@@ -31,16 +69,20 @@ target_compile_options(${PROJECT_NAME}
|
||||
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||
-Wall -Wextra -Wpedantic>)
|
||||
|
||||
#
|
||||
# dependencies
|
||||
#
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads)
|
||||
|
||||
if(CURLY_USE_SYSTEM_CURL)
|
||||
if(USE_SYSTEM_CURL)
|
||||
find_package(CURL REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC ${CURL_LIBRARIES})
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CURL_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(CURLY_USE_EMBEDDED_CURL)
|
||||
if(USE_EMBEDDED_CURL)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
embedded_curl
|
||||
@@ -57,6 +99,10 @@ if(CURLY_USE_EMBEDDED_CURL)
|
||||
set(BUILD_CURL_EXE OFF CACHE BOOL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||
|
||||
if(MSVC AND USE_STATIC_CRT)
|
||||
set(CURL_STATIC_CRT ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_USE_WINSSL ON CACHE BOOL "" FORCE)
|
||||
set(CURL_CA_PATH "none" CACHE STRING "" FORCE)
|
||||
@@ -80,6 +126,10 @@ if(CURLY_USE_EMBEDDED_CURL)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CURL_SOURCE_DIR}/include)
|
||||
endif()
|
||||
|
||||
#
|
||||
# unit tests
|
||||
#
|
||||
|
||||
if(BUILD_AS_STANDALONE)
|
||||
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
|
||||
if(BUILD_WITH_UNTESTS)
|
||||
|
||||
18
README.md
18
README.md
@@ -25,6 +25,14 @@
|
||||
|
||||
[curly]: https://github.com/BlackMATov/curly.hpp
|
||||
|
||||
## Features
|
||||
|
||||
- Custom headers
|
||||
- Asynchronous requests
|
||||
- PUT, GET, HEAD, POST methods
|
||||
- Custom uploading and downloading streams
|
||||
- Connection and last server response timeouts
|
||||
|
||||
## Installation
|
||||
|
||||
Just add the root repository directory to your cmake project:
|
||||
@@ -34,13 +42,11 @@ add_subdirectory(external/curly.hpp)
|
||||
target_link_libraries(your_project_target curly.hpp)
|
||||
```
|
||||
|
||||
## Features
|
||||
### CMake options
|
||||
|
||||
- Custom headers
|
||||
- Asynchronous requests
|
||||
- PUT, GET, HEAD, POST methods
|
||||
- Custom uploading and downloading streams
|
||||
- Connection and last server response timeouts
|
||||
* `USE_STATIC_CRT` Use static C runtime library. Default: OFF
|
||||
* `USE_SYSTEM_CURL` Build with cURL from system paths. Default: OFF
|
||||
* `USE_EMBEDDED_CURL` Build with embedded cURL library. Default: ON
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
Reference in New Issue
Block a user