-
Notifications
You must be signed in to change notification settings - Fork 87
Pass CFLAGS and CPPFLAGS to build process #134
Conversation
When overrideing cmpiler options in cmake CMake does not by default honour enviornment set compiler options, this has to be manually considered. In Debian, CFLAGS and CPPFLAGS are injected by the enviornmnent to set some archive-wide defaults, for example enabling hardening features. (If the environment variables are not set, this patch has no effect.) Patch origin: https://salsa.debian.org/games-team/minetest/-/blob/master/debian/patches/enable_hardening.patch (minus some extra blank lines, which I missed when creating the patch for Debian))
Does any CMake-based project does that? |
Actually, this PR made me realize there is a problem. See #164 for details. |
This is a known issue with CMake. Background: https://gitlab.kitware.com/cmake/cmake/-/issues/20631 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=653916 |
Can’t you simply |
|
They are, but not
No, CMake does that itself.
If you really want to use that, add a cache variable (e.g. |
set(CMAKE_CXX_FLAGS_RELEASE "-O3 $ENV{CPPFLAGS}") | ||
set(CMAKE_CXX_FLAGS_DEBUG "-g $ENV{CPPFLAGS}") |
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.
Fragile. Each time CMake runs, it rereads these environment variables.
When overriding compiler options in cmake CMake does not by default honor environment set compiler options, this has to be manually considered. In Debian, CFLAGS and CPPFLAGS are injected by the environment to set some archive-wide defaults, for example enabling hardening features.
(If the environment variables are not set, this patch has no effect.)
Patch origin:
https://salsa.debian.org/games-team/minetest/-/blob/master/debian/patches/enable_hardening.patch (minus some extra blank lines, which I missed when creating the patch for Debian))