fixes to better honor env CC and CXX

This commit is contained in:
Bill Hoffman 2002-11-19 15:55:19 -05:00
parent 76fca308d3
commit 7140c6f364
2 changed files with 26 additions and 15 deletions

View File

@ -6,13 +6,21 @@
# as a default compiler
IF(NOT CMAKE_C_COMPILER)
SET(CMAKE_C_COMPILER_LIST ${CMAKE_GENERATOR_CC} gcc cc cl bcc )
# if the user has specified CC via the environment, then use that without checking
IF($ENV{CC} MATCHES ".+")
SET(CMAKE_C_COMPILER_LIST $ENV{CXX})
SET(CMAKE_C_COMPILER_INIT $ENV{CC})
# make sure we can find it
FIND_PROGRAM(CMAKE_C_COMPILER_FULLPATH NAMES $ENV{CC})
IF(NOT CMAKE_C_COMPILER_FULLPATH)
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}, make sure CC does not have flags in it, use CFLAGS instead.")
ENDIF(NOT CMAKE_C_COMPILER_FULLPATH)
ELSE($ENV{CC} MATCHES ".+")
# if not in the envionment then search for the compiler in the path
SET(CMAKE_C_COMPILER_LIST ${CMAKE_GENERATOR_CC} gcc cc cl bcc )
FIND_PROGRAM(CMAKE_C_COMPILER_FULLPATH NAMES ${CMAKE_C_COMPILER_LIST} )
GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT
${CMAKE_C_COMPILER_FULLPATH} NAME)
ENDIF($ENV{CC} MATCHES ".+")
FIND_PROGRAM(CMAKE_C_COMPILER_FULLPATH NAMES ${CMAKE_C_COMPILER_LIST} )
GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT
${CMAKE_C_COMPILER_FULLPATH} NAME)
# set this to notfound right after so that it is searched for each time this
# file is included
SET(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_INIT} CACHE STRING "C compiler")

View File

@ -6,20 +6,23 @@
# as a default compiler
IF(NOT CMAKE_CXX_COMPILER)
SET(CMAKE_CXX_COMPILER_LIST ${CMAKE_GENERATOR_CXX} c++ g++ CC aCC cl bcc )
# if the user has specified CC via the environment, then use that without checking
IF($ENV{CXX} MATCHES ".+")
SET(CMAKE_CXX_COMPILER_LIST $ENV{CXX})
SET(CMAKE_CXX_COMPILER_INIT $ENV{CXX})
# make sure we can find it
FIND_PROGRAM(CMAKE_CXX_COMPILER_FULLPATH NAMES $ENV{CXX})
IF(NOT CMAKE_CXX_COMPILER_FULLPATH)
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}, make sure CXX does not have flags in it, use CXXFLAGS instead.")
ENDIF(NOT CMAKE_CXX_COMPILER_FULLPATH)
ELSE($ENV{CXX} MATCHES ".+")
# if not in the envionment then search for the compiler in the path
SET(CMAKE_CXX_COMPILER_LIST ${CMAKE_GENERATOR_CXX} c++ g++ CC aCC cl bcc )
FIND_PROGRAM(CMAKE_CXX_COMPILER_FULLPATH NAMES ${CMAKE_CXX_COMPILER_LIST})
GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT
${CMAKE_CXX_COMPILER_FULLPATH} NAME)
ENDIF($ENV{CXX} MATCHES ".+")
FIND_PROGRAM(CMAKE_CXX_COMPILER_FULLPATH NAMES ${CMAKE_CXX_COMPILER_LIST})
GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT
${CMAKE_CXX_COMPILER_FULLPATH} NAME)
SET(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_INIT}
CACHE STRING "C++ compiler")
IF($ENV{CXX} MATCHES ".+")
IF(NOT CMAKE_CXX_COMPILER)
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}, make sure CXX does not have flags in it, use CXXFLAGS instead.")
ENDIF(NOT CMAKE_CXX_COMPILER)
ENDIF($ENV{CXX} MATCHES ".+")
ENDIF(NOT CMAKE_CXX_COMPILER)
MARK_AS_ADVANCED(CMAKE_CXX_COMPILER)