]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: move mingw UWP workaround from GHA to `CMakeLists.txt`
authorViktor Szakats <commit@vsz.me>
Wed, 15 Jan 2025 13:28:19 +0000 (14:28 +0100)
committerViktor Szakats <commit@vsz.me>
Thu, 16 Jan 2025 15:44:53 +0000 (16:44 +0100)
CMake (as of 3.31.2) doesn't fully recognize mingw-w64 with
`CMAKE_SYSTEM_NAME=WindowsStore`.
The manual logic works around it.

Also move existing DJGPP workaround to the same block.

Closes #16019

.github/workflows/windows.yml
CMakeLists.txt

index 940bfb10066238dc4916223f48d8758984bca461..38ca50158030d69d67a764883228a39366cf0764 100644 (file)
@@ -242,17 +242,11 @@ jobs:
                 gcc -dumpspecs | sed -e 's/-lmingwex/-lwindowsapp -lmingwex -lwindowsapp/' -e 's/-lmsvcrt/-lucrtapp/' > "${specs}"
                 cflags+=" -specs=$(cygpath -w "${specs}")"
               fi
-              # CMake (as of v3.31.0) gets confused and applies the MSVC rc.exe command-line
-              # template to windres. Reset it to the windres template manually:
-              rcopts='<CMAKE_RC_COMPILER> -O coff <DEFINES> <INCLUDES> <FLAGS> <SOURCE> <OBJECT>'
-            else
-              rcopts=''
             fi
             [ '${{ matrix.type }}' = 'Debug' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG='
             [ '${{ matrix.type }}' = 'Release' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE='
             cmake -B bld -G Ninja ${options} \
               "-DCMAKE_C_FLAGS=${{ matrix.cflags }} ${cflags}" \
-              "-DCMAKE_RC_COMPILE_OBJECT=${rcopts}" \
               '-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \
               -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \
               -DCURL_WERROR=ON \
index 527e6c815735f45ed13a05b487932f4d177414e9..e21e7347686a9f9e232c63d2bf3857c1073e6254 100644 (file)
@@ -86,6 +86,18 @@ project(CURL
   VERSION "${_curl_version_sem}"
   LANGUAGES C)
 
+# CMake does not recognize some targets accurately. Touch up configuration manually as a workaround.
+if(WINDOWS_STORE AND MINGW)  # mingw UWP build
+  # CMake (as of v3.31.2) gets confused and applies the MSVC rc.exe command-line
+  # template to windres. Reset it to the windres template via 'Modules/Platform/Windows-windres.cmake':
+  set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <DEFINES> <INCLUDES> <FLAGS> <SOURCE> <OBJECT>")
+elseif(DOS AND CMAKE_COMPILER_IS_GNUCC)  # DJGPP
+  set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
+  set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
+  set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
+  set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
+endif()
+
 set(_target_flags "")
 if(APPLE)
   set(_target_flags "${_target_flags} APPLE")
@@ -210,12 +222,6 @@ if(WIN32)
 elseif(DOS OR AMIGA)
   set(BUILD_SHARED_LIBS OFF)
   set(BUILD_STATIC_LIBS ON)
-  if(DOS AND CMAKE_COMPILER_IS_GNUCC)
-    set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
-    set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
-    set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
-    set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
-  endif()
 endif()
 option(CURL_LTO "Enable compiler Link Time Optimizations" OFF)