]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
CMake: add option to enable Unicode on Windows
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Sat, 22 Aug 2020 08:04:29 +0000 (10:04 +0200)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Sat, 29 Aug 2020 08:01:10 +0000 (10:01 +0200)
As already existing for winbuild.

Closes https://github.com/curl/curl/pull/5843

CMakeLists.txt
src/CMakeLists.txt

index 68842ee3eb16bf8d6c6adc4e8931f55e059ad580..6388015d4face689fba17d736ae771c3f42678f6 100644 (file)
@@ -79,6 +79,7 @@ option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
 if(WIN32)
   option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF)
   option(ENABLE_INET_PTON "Set to OFF to prevent usage of inet_pton when building against modern SDKs while still requiring compatibility with older Windows versions, such as Windows XP, Windows Server 2003 etc." ON)
+  option(ENABLE_UNICODE "Set to ON to use the Unicode version of the Windows API functions" OFF)
   set(CURL_TARGET_WINDOWS_VERSION "" CACHE STRING "Minimum target Windows version as hex string")
   if(CURL_TARGET_WINDOWS_VERSION)
     add_definitions(-D_WIN32_WINNT=${CURL_TARGET_WINDOWS_VERSION})
@@ -92,6 +93,12 @@ if(WIN32)
     add_definitions(-D_WIN32_WINNT=0x0501)
     set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WIN32_WINNT=0x0501")
   endif()
+  if(ENABLE_UNICODE)
+    add_definitions(-DUNICODE -D_UNICODE)
+    if(MINGW)
+      add_compile_options(-municode)
+    endif()
+  endif()
 endif()
 option(CURL_LTO "Turn on compiler Link Time Optimizations" OFF)
 
index 26e3cfe1ebfb70c76dd98a8eacf20a2d0e25ab5b..b994ae961a1182bbe21d6e953c7f6b0f1ae9907e 100644 (file)
@@ -78,6 +78,12 @@ if(CURL_HAS_LTO)
     INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE)
 endif()
 
+if(ENABLE_UNICODE AND MINGW)
+  target_link_libraries(${EXE_NAME} -municode)
+  # GCC doesn't know about wmain
+  set_source_files_properties(tool_main.c PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes -Wno-missing-declarations")
+endif()
+
 source_group("curlX source files" FILES ${CURLX_CFILES})
 source_group("curl source files" FILES ${CURL_CFILES})
 source_group("curl header files" FILES ${CURL_HFILES})