Home
My Page
Projects
OpenVAS

[#1232] CC environment variable is not respected by make / cmake

Date:
2010-01-05 03:03
Priority:
3
State:
Closed
Submitted by:
Ryan Schmidt (ryandesign)
Assigned to:
Nobody (None)
Architecture:
None
Product:
OpenVAS
Operating System:
None
Component:
openvas-libraries
Version:
3.0.0
Severity:
trivial
Resolution:
Fixed
Hardware:
None
URL:
 
Summary:
CC environment variable is not respected by make / cmake

Detailed description
I'm in the maintainer of OpenVAS in MacPorts and am in the process of updating the ports to version 3. I noticed this issue:



MacPorts passes the environment variable "CC=/usr/bin/gcc-4.2" to the configure script, which correctly says:



checking for gcc... /usr/bin/gcc-4.2



But when I run "make", it runs cmake, which tries on its own to find gcc again and finds a different one:



-- The C compiler identification is unknown

-- Check for working C compiler: /Users/rschmidt/macports/ryandesign/no_default_gcc/gcc

-- Check for working C compiler: /Users/rschmidt/macports/ryandesign/no_default_gcc/gcc -- broken

CMake Error at /opt/local/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:50 (MESSAGE):

The C compiler "/Users/rschmidt/macports/ryandesign/no_default_gcc/gcc" is

not able to compile a simple test program.



/Users/rschmidt/macports/ryandesign/no_default_gcc is in my MacPorts PATH first and /Users/rschmidt/macports/ryandesign/no_default_gcc/gcc is a script I wrote which exits with an error code no matter what, to detect software that does not respect my compiler choice.



http://trac.macports.org/wiki/UsingTheRightCompiler



I can work around this for openvas-libraries by passing "CC=/usr/bin/gcc-4.2" in the environment when I run "make" as well, but I shouldn't have to do that.

Followup

Message
Date: 2017-01-13 10:34
Sender: Michael Wiegand

Seems to have been fixed in the meantime, CMake is now properly using
environment variables such a CC and CFLAGS.
Date: 2010-01-28 09:46
Sender: Felix Wolfsteller

Hi Ryan and thanks for reporting.

The flags should be passed in openvas-libraries/Makefile (in target "all").

Adding something like
-DCMAKE_C_FLAGS=$(CFLAGS) -DCMAKE_C_LINK_FLAGS=$(LD_FLAGS) to the cmake calls there might help.
Date: 2010-01-05 03:31
Sender: Ryan Schmidt

My CFLAGS and LDFLAGS are being ignored too. I'm using CFLAGS="-O2 -arch x86_64 -arch i386" and LDFLAGS="-L/opt/local/lib -arch x86_64 -arch i386" but the arch flags aren't there when cmake is building its objects and they end up x86_64-only.

$ cd openvas-libraries-3.0.0/
$ find . -name *.o | xargs lipo -info
Non-fat file: ./base/CMakeFiles/openvas_base_shared.dir/certificate.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_shared.dir/hash_table_util.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_shared.dir/nvti.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_shared.dir/nvticache.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_shared.dir/openvas_certificate_file.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_shared.dir/openvas_string.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_shared.dir/pidfile.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_shared.dir/settings.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_shared.dir/severity_filter.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_static.dir/certificate.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_static.dir/hash_table_util.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_static.dir/nvti.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_static.dir/nvticache.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_static.dir/openvas_certificate_file.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_static.dir/openvas_string.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_static.dir/pidfile.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_static.dir/settings.c.o is architecture: x86_64
Non-fat file: ./base/CMakeFiles/openvas_base_static.dir/severity_filter.c.o is architecture: x86_64
$

Attached Files:

Changes:

Field Old Value Date By
status_idOpen2017-01-13 10:34mwiegand
close_dateNone2017-01-13 10:34mwiegand
ResolutionNone2017-01-13 10:34mwiegand

This site is hosted by Intevation GmbH