-
Notifications
You must be signed in to change notification settings - Fork 112
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
Update CMakeLists.txt #734
Conversation
Handle platforms that have `_GLIBCXX_ASSERTIONS`, which require the stdlib++ to be included.
@jcelerier does this fix one of the two Arch Linux errors you reported? |
CMakeLists.txt
Outdated
@@ -95,6 +95,15 @@ if (NOT MSVC AND NOT (SNMALLOC_CLEANUP STREQUAL CXX11_DESTRUCTORS)) | |||
endif() | |||
endif() | |||
|
|||
# FORTIFY_SOURCE prevents overriding memcpy, disable memcpy if detected. | |||
if("${CMAKE_CXX_FLAGS}" MATCHES ".*_FORTIFY_SOURCE.*") |
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.
I think a safer way to try this would be to use a cmake try_compile test, as there are other ways for flags to end up in -DCMAKE_CXX_FLAGS than this:
- CMAKE_CXX_FLAGS_
- a host project adding the flag via
add_compile_options
oradd_compile_definitions
and then doing add_subdirectory(snmalloc)
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.
example:
cmake_minimum_required(VERSION 3.31)
project(foo LANGUAGES CXX)
try_compile(no_macro
SOURCE_FROM_CONTENT main.cpp
[=[
#if defined(_FORTIFY_SOURCE)
#error
#endif
int main() { }
]=]
)
message("Result: ${no_macro}")
``̀`
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.
That's a great suggestion, I have done something similar to your suggestion.
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.
LGTM!
Handle platforms that have
_GLIBCXX_ASSERTIONS
, which require the stdlib++ to be included.