configure-cmake icon indicating copy to clipboard operation
configure-cmake copied to clipboard

Fix environment handling

Open AMDmi3 opened this issue 10 years ago • 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).

AMDmi3 avatar Jan 26 '16 14:01 AMDmi3

Also:

  • Another array is used in parse_var_decl
  • function foo() should be replaced with foo()

AMDmi3 avatar Jan 26 '16 14:01 AMDmi3

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…

nemequ avatar Jan 26 '16 17:01 nemequ

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

AMDmi3 avatar Jan 26 '16 17:01 AMDmi3

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…

nemequ avatar Jan 27 '16 02:01 nemequ

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.

AMDmi3 avatar Jan 27 '16 13:01 AMDmi3