]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: improve OS string in CMake and `config-win32.h`
authorViktor Szakats <commit@vsz.me>
Mon, 11 Jul 2022 19:41:31 +0000 (19:41 +0000)
committerViktor Szakats <commit@vsz.me>
Mon, 11 Jul 2022 19:41:31 +0000 (19:41 +0000)
This patch makes CMake fill the "OS string" with the value of
`CMAKE_C_COMPILER_TARGET`, if passed. This typically contains a triplet,
the same we can pass to `./configure` via `--host=`.

For non-CMake, non-autotools, Windows builds, this patch adds the ability
to override the default `OS` value in `lib/config-win32.h`.

With these its possible to get the same OS string across the three build
systems.

This patch supersedes the earlier, partial, CMake-only solution:
435f395f3f8c11eebfcc243ca55ebcc11a19b8b8, thus retiring the
`CURL_OS_SUFFIX` CMake option.

Reviewed-by: Jay Satiro
Closes #9117

CMakeLists.txt
lib/config-win32.h

index 5ecb944c7b15c590a9ef42affd7dcded30044752..758e7fefa893277f57cc28f92a7a1a7ead81cc40 100644 (file)
@@ -67,7 +67,11 @@ message(STATUS "curl version=[${CURL_VERSION}]")
 # SET(PACKAGE_STRING "curl-")
 # SET(PACKAGE_BUGREPORT "a suitable curl mailing list => https://curl.se/mail/")
 set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
-set(OS "\"${CMAKE_SYSTEM_NAME}${CURL_OS_SUFFIX}\"")
+if(CMAKE_C_COMPILER_TARGET)
+  set(OS "\"${CMAKE_C_COMPILER_TARGET}\"")
+else()
+  set(OS "\"${CMAKE_SYSTEM_NAME}\"")
+endif()
 
 include_directories(${CURL_SOURCE_DIR}/include)
 
index 932515667f9164478697aca1344b678537e0eef8..25e81cf190061a82a1d5950ecd92121d10c39766 100644 (file)
@@ -663,7 +663,7 @@ Vista
 /* ---------------------------------------------------------------- */
 
 /* Define cpu-machine-OS */
-#undef OS
+#if !defined(OS)
 #if defined(_M_IX86) || defined(__i386__) /* x86 (MSVC or gcc) */
 #define OS "i386-pc-win32"
 #elif defined(_M_X64) || defined(__x86_64__) /* x86_64 (MSVC >=2005 or gcc) */
@@ -677,6 +677,7 @@ Vista
 #else
 #define OS "unknown-pc-win32"
 #endif
+#endif
 
 /* Name of package */
 #define PACKAGE "curl"