Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions iotdb-client/client-cpp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@
<options>
<option>-DBOOST_INCLUDEDIR=${boost.include.dir}</option>
<option>-DWITH_SSL=${with.ssl}</option>
<option>-DCMAKE_BUILD_TYPE=${cmake.build.type}</option>
</options>
</configuration>
</execution>
Expand Down
12 changes: 11 additions & 1 deletion iotdb-client/client-cpp/src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

SET(CMAKE_CXX_FLAGS_DEBUG "-O0")
ENDIF()

# Add Thrift include directory
Expand Down
Loading