usnistgov / SCTK

Other
208 stars 52 forks source link

Use correct C/C++ compiler and flags as needed #33

Closed ryandesign closed 2 years ago

ryandesign commented 2 years ago

Previously, in the asclite makefiles, CC was used to refer to the C++ compiler; CFLAGS and CXXFLAGS were both passed to this compiler; C files were being compiled with the C++ compiler, causing the message "clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated" to be printed; and "c++" was used as the linker, ignoring the user's requested C++ compiler and flags.

Now, CC refers to the C compiler; CXX refers to the C++ compiler; CFLAGS are passed to the C compiler; CXXFLAGS are passed to the C++ compiler; C files are compiled with the C compiler; C++ files are compiled with the C++ compiler; and CXX is used for linking.

In addition, the sclite makefile is cleaned up so that the executables are not compiled and linked as a single step; dependencies are obtained from the target declaration rather than being repeated in the link command; CPPFLAGS are specified after local -I flags so that any -I flags that might be in the user's CPPFLAGS do not cause incorrect headers to be found; and OFLAGS are added to the compilation step to match what's done in asclite's makefiles, though this is a nonstandard variable and it is not defined anywhere (presumably it was expected that a user might set it).

jfiscus commented 2 years ago

Thanks @arlofaria for reviewing the changes. Thanks @ryandesign for making the improvements and for contribution to SCTK! I completed the merge request.