]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: fix stderr initialization in unity builds
authorViktor Szakats <commit@vsz.me>
Mon, 25 Sep 2023 01:08:02 +0000 (01:08 +0000)
committerViktor Szakats <commit@vsz.me>
Mon, 25 Sep 2023 22:08:22 +0000 (22:08 +0000)
Before this patch, in certain build configurations the curl tool may
not have displayed anything (debug, macOS), or crashed at startup
(debug, Windows).

Follow-up to 3f8fc25720900b14b7432f4bd93407ca15311719
Necessary after 2f17a9b654121dd1ecf4fc043c6d08a9da3522db

Closes #11929

src/CMakeLists.txt

index 3d6334b2cfa3bccbd97127777bdee52dabde4a5d..08a3e5c4746118d57d89b8b947ad5912f526ed9b 100644 (file)
@@ -67,6 +67,11 @@ if(BUILD_STATIC_CURL)
   set(CURLX_CFILES ${CURLTOOL_LIBCURL_CFILES})
 endif()
 
+# Compile this source separately to avoid having `stderr` overridden in this
+# file. Necessary for successfully initializing stderr in unity builds.
+# (Not necessary for the libcurltool target.)
+set_source_files_properties(tool_stderr.c PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+
 add_executable(
   ${EXE_NAME}
   ${CURL_CFILES} ${CURLX_CFILES} ${CURL_HFILES}