From 4838863d27d2c6e9610a9caec2806292375d1767 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 6 Apr 2023 10:06:30 +0200 Subject: [PATCH] lib/cmake: add HAVE_WRITABLE_ARGV check Assisted-by: Jakub Zakrzewski Closes #10896 --- lib/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8f207588dd..51512045d2 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -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 -- 2.47.3