diff --git a/CMakeLists.txt b/CMakeLists.txt index 256b5d6679..be4a1822ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,13 +217,6 @@ option(ENABLE_ARES "Enable c-ares support" OFF) option(CURL_DISABLE_INSTALL "Disable installation targets" OFF) if(WIN32) - option(CURL_STATIC_CRT "Build libcurl with static CRT with MSVC (/MT)" OFF) - if(CURL_STATIC_CRT AND MSVC) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - string(APPEND CMAKE_C_FLAGS_RELEASE " -MT") - string(APPEND CMAKE_C_FLAGS_DEBUG " -MTd") - endif() - option(ENABLE_UNICODE "Use the Unicode version of the Windows API functions" OFF) if(WINDOWS_STORE OR WINCE) set(ENABLE_UNICODE ON) @@ -356,6 +349,20 @@ else() set(LIB_SELECTED ${LIB_STATIC}) endif() +if(WIN32) + option(CURL_STATIC_CRT "Build libcurl with static CRT with MSVC (/MT)" OFF) + if(CURL_STATIC_CRT AND MSVC) + if(BUILD_STATIC_CURL) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + string(APPEND CMAKE_C_FLAGS_RELEASE " -MT") + string(APPEND CMAKE_C_FLAGS_DEBUG " -MTd") + else() + message(WARNING "Static CRT requires curl executable built with static libcurl " + "(BUILD_STATIC_LIBS=ON and BUILD_STATIC_CURL=ON).") + endif() + endif() +endif() + # Override to force-disable or force-enable the use of pkg-config. if((UNIX AND NOT ANDROID AND (NOT APPLE OR CMAKE_SYSTEM_NAME MATCHES "Darwin")) OR VCPKG_TOOLCHAIN OR diff --git a/appveyor.sh b/appveyor.sh index d1363e72e6..9388a6d33b 100644 --- a/appveyor.sh +++ b/appveyor.sh @@ -58,6 +58,7 @@ if [ "${BUILD_SYSTEM}" = 'CMake' ]; then -DCMAKE_UNITY_BUILD="${UNITY}" -DCURL_TEST_BUNDLES=ON \ -DCURL_WERROR=ON \ -DBUILD_SHARED_LIBS="${SHARED}" \ + -DCURL_STATIC_CRT=ON \ -DENABLE_DEBUG="${DEBUG}" \ -DENABLE_UNICODE="${ENABLE_UNICODE}" \ -DHTTP_ONLY="${HTTP_ONLY}" \ diff --git a/docs/INSTALL-CMAKE.md b/docs/INSTALL-CMAKE.md index e55d951496..4479d4a365 100644 --- a/docs/INSTALL-CMAKE.md +++ b/docs/INSTALL-CMAKE.md @@ -160,7 +160,7 @@ assumes that CMake generates `Makefile`: - `CURL_LIBCURL_VERSIONED_SYMBOLS`: Enable libcurl versioned symbols. Default: `OFF` - `CURL_LIBCURL_VERSIONED_SYMBOLS_PREFIX`: Override default versioned symbol prefix. Default: `_` or `MULTISSL_` - `CURL_LTO`: Enable compiler Link Time Optimizations. Default: `OFF` -- `CURL_STATIC_CRT`: Build libcurl with static CRT with MSVC (`/MT`). Default: `OFF` +- `CURL_STATIC_CRT`: Build libcurl with static CRT with MSVC (`/MT`) (requires static curl executable). Default: `OFF` - `CURL_TARGET_WINDOWS_VERSION`: Minimum target Windows version as hex string. - `CURL_TEST_BUNDLES`: Bundle `libtest` and `unittest` tests into single binaries. Default: `OFF` - `CURL_WERROR`: Turn compiler warnings into errors. Default: `OFF`