Caideyipi commented on code in PR #17856:
URL: https://github.com/apache/iotdb/pull/17856#discussion_r3370672440


##########
iotdb-client/client-cpp/src/main/CMakeLists.txt:
##########
@@ -22,8 +22,18 @@ SET(CMAKE_CXX_STANDARD 11)
 SET(CMAKE_CXX_STANDARD_REQUIRED ON)
 SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
 IF(NOT MSVC)
+    # Single-config generators (e.g. "Unix Makefiles") leave CMAKE_BUILD_TYPE 
empty
+    # unless told otherwise; default to Release to preserve the historical 
behavior.
+    IF(NOT CMAKE_BUILD_TYPE)
+        SET(CMAKE_BUILD_TYPE Release)
+    ENDIF()
     # Keep GCC/Clang style flags off on MSVC to avoid invalid-option build 
errors.
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -O2")
+    # -g is kept for all build types so Release still ships debug symbols 
(unchanged).
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g")
+    # Release keeps the previous flags exactly (-O2, no -DNDEBUG); Debug is 
unoptimized
+    # (-O0) so the packaged library can be stepped through in a debugger.
+    SET(CMAKE_CXX_FLAGS_RELEASE "-O2")

Review Comment:
   This should preserve existing per-config flags instead of replacing them 
completely. Once the POM passes `-DCMAKE_BUILD_TYPE`, `CMAKE_CXX_FLAGS_RELEASE` 
/ `CMAKE_CXX_FLAGS_DEBUG` are actually used, so these unconditional assignments 
can discard flags provided by a toolchain file or by the caller, e.g. 
hardening, sanitizer, ABI, or architecture flags. Could we keep the 
caller/toolchain-provided value and only adjust the optimization level needed 
here (`-O2` for Release, `-O0` for Debug)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to