-
Notifications
You must be signed in to change notification settings - Fork 0
Add optional nrvo warning flag #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -160,11 +160,39 @@ if(UNIX AND NOT APPLE AND NOT WIN32) | |||||||||||||||
| endif() | ||||||||||||||||
| # Windows (MSVC and MinGW) use Threads::Threads which is already linked above | ||||||||||||||||
|
|
||||||||||||||||
| # Check support for optional warning flags (e.g. -Wnrvo) | ||||||||||||||||
| include(CheckCXXCompilerFlag) | ||||||||||||||||
|
|
||||||||||||||||
| function(ts_add_warning_if_supported flag out_var) | ||||||||||||||||
| string(REPLACE "-" "_" _flag_var "${flag}") | ||||||||||||||||
|
||||||||||||||||
| string(REPLACE "-" "_" _flag_var "${flag}") | |
| string(MAKE_C_IDENTIFIER "CXX_FLAG_${flag}" _flag_var) |
Copilot
AI
Oct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The manual string concatenation with semicolons can be replaced with CMake's list(APPEND ...) command for better maintainability and clarity. Replace lines 170-174 with: list(APPEND ${out_var} \"${flag}\") followed by set(${out_var} \"${${out_var}}\" PARENT_SCOPE).
| if(DEFINED ${out_var} AND NOT "${${out_var}}" STREQUAL "") | |
| set(${out_var} "${${out_var}};${flag}" PARENT_SCOPE) | |
| else() | |
| set(${out_var} "${flag}" PARENT_SCOPE) | |
| endif() | |
| list(APPEND ${out_var} "${flag}") | |
| set(${out_var} "${${out_var}}" PARENT_SCOPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
_flag_varvariable name may conflict across multiple calls to this function with different flags. The variable should include a unique suffix or use a more specific naming pattern. Consider usingCXX_SUPPORTS${_flag_var}or similar to ensure uniqueness when checking multiple flags.