]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib/cmake: add HAVE_WRITABLE_ARGV check
authorDaniel Stenberg <daniel@haxx.se>
Thu, 6 Apr 2023 08:06:30 +0000 (10:06 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 6 Apr 2023 21:52:31 +0000 (23:52 +0200)
Assisted-by: Jakub Zakrzewski
Closes #10896

lib/CMakeLists.txt

index 8f207588dd7b991695cc9ecb31461d823c7ce972..51512045d2620112ec5848414963969ee95f1f74 100644 (file)
@@ -131,6 +131,17 @@ if(WIN32)
       set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
     endif()
   endif()
+else()
+  # on not-Windows, check for writable argv[]
+    include(CheckCSourceRuns)
+    check_c_source_runs("
+int main(int argc, char **argv)
+{
+  (void)argc;
+  argv[0][0] = ' ';
+  return (argv[0][0] == ' ')?0:1;
+}"
+      HAVE_WRITABLE_ARGV)
 endif()
 
 target_include_directories(${LIB_NAME} INTERFACE