summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCCompiler.cmake
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2002-11-19 20:55:19 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2002-11-19 20:55:19 (GMT)
commit7140c6f364c55084d5e581cc7e603032ec4087b9 (patch)
tree1399d66996e9d3dd2a99405cd3d223ce6dab7568 /Modules/CMakeDetermineCCompiler.cmake
parent76fca308d3e04bc33cb8d03a8d10737e875791be (diff)
downloadCMake-7140c6f364c55084d5e581cc7e603032ec4087b9.zip
CMake-7140c6f364c55084d5e581cc7e603032ec4087b9.tar.gz
CMake-7140c6f364c55084d5e581cc7e603032ec4087b9.tar.bz2
fixes to better honor env CC and CXX
Diffstat (limited to 'Modules/CMakeDetermineCCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake18
1 files changed, 13 insertions, 5 deletions
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index 151ed81..5d48546 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -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")