Fix environment handling
AMDmi3 opened this issue · 5 comments
configure-cmake seem to parse CC
/CXX
/CFLAGS
/CXXFLAGS
from arguments, while they should be parsed from environment instead (see real configure help). You should also support CPPFLAGS
(may either append to CFLAGS
/CXXFLAGS
or parse into CMAKE_INCLUDE_PATH
) and LDFLAGS
(may parse into CMAKE_EXE_LINKER_FLAGS
+ CMAKE_SHARED_LINKER_FLAGS
).
Also:
- Another array is used in parse_var_decl
function foo()
should be replaced withfoo()
configure-cmake seem to parse CC/CXX/CFLAGS/CXXFLAGS from arguments, while they should be parsed from environment instead (see real configure help).
Actually, it works when you pass them as arguments with real configure, too. When they are passed as environment variables CMake will handle them, so I don't think we need to do so.
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html contains information on the ordering (as well as an example of CPPFLAGS being passed as an argument).
You should also support CPPFLAGS (may either append to CFLAGS/CXXFLAGS or parse into CMAKE_INCLUDE_PATH) and LDFLAGS (may parse into CMAKE_EXE_LINKER_FLAGS + CMAKE_SHARED_LINKER_FLAGS).
Yep, you're right.
function foo() should be replaced with foo()
Is the latter more portable? I like the 'function' syntax much better…
Actually, it works when you pass them as arguments with real configure, too. When they are passed as environment variables CMake will handle them, so I don't think we need to do so.
Oh, ok then. Quick test shows that CC/CXX/CFLAGS/CXXFLAGS/LDFLAGS work fine, however CPPFLAGS do not. These should probably still be handled explicitly.
Is the latter more portable? I like the 'function' syntax much better…
It is, function is a bashism. See http://mywiki.wooledge.org/Bashism
I'm not sure how to handle CPPFLAGS. CMake really doesn't have anything analogous. The closest thing is probably putting them in both the C and C++ flags, but that's not really equivalent. And, of course the CPP variable is even worse…
The closest thing is probably putting them in both the C and C++ flags, but that's not really equivalent
Yes and yes, but I don't see a better solution. For example, in FreeBSD ports, CPPFLAGS is mostly used to pass additional include search paths (CPPFLAGS+=-I/usr/local/include
), while CFLAGS/CXXFLAGS contain systemwide compiler settings, e.g. -O2 -pipe -march=... -fstack-protector -fno-strict-aliasing
and may be appended by individual ports with stuff like -fPIC
and -std=...
. I guess appending CPPFLAGS to both CFLAGS and CXXFLAGS won't hurt.