fix for generator picked compilers

This commit is contained in:
Bill Hoffman 2002-12-06 10:02:19 -05:00
parent 19aa18fd26
commit 35fb6f22ba
3 changed files with 29 additions and 7 deletions

View File

@ -6,6 +6,8 @@
# as a default compiler # as a default compiler
IF(NOT CMAKE_C_COMPILER) IF(NOT CMAKE_C_COMPILER)
SET(CMAKE_CXX_COMPILER_INIT NOTFOUND)
# if the user has specified CC via the environment, then use that without checking # if the user has specified CC via the environment, then use that without checking
IF($ENV{CC} MATCHES ".+") IF($ENV{CC} MATCHES ".+")
GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT) GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT)
@ -13,13 +15,21 @@ IF(NOT CMAKE_C_COMPILER)
ELSE(EXISTS ${CMAKE_C_COMPILER_INIT}) ELSE(EXISTS ${CMAKE_C_COMPILER_INIT})
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.") MESSAGE(SEND_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.")
ENDIF(EXISTS ${CMAKE_C_COMPILER_INIT}) ENDIF(EXISTS ${CMAKE_C_COMPILER_INIT})
ELSE($ENV{CC} MATCHES ".+") ENDIF($ENV{CC} MATCHES ".+")
IF(CMAKE_GENERATOR_CC)
IF(NOT CMAKE_CC_COMPILER_INIT)
SET(CMAKE_CC_COMPILER_INIT ${CMAKE_GENERATOR_CC})
ENDIF(NOT CMAKE_CC_COMPILER_INIT)
ENDIF(CMAKE_GENERATOR_CC)
IF(NOT CMAKE_CC_COMPILER_INIT)
# if not in the envionment then search for the compiler in the path # 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 ) SET(CMAKE_C_COMPILER_LIST gcc cc cl bcc )
FIND_PROGRAM(CMAKE_C_COMPILER_FULLPATH NAMES ${CMAKE_C_COMPILER_LIST} ) FIND_PROGRAM(CMAKE_C_COMPILER_FULLPATH NAMES ${CMAKE_C_COMPILER_LIST} )
GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT
${CMAKE_C_COMPILER_FULLPATH} NAME) ${CMAKE_C_COMPILER_FULLPATH} NAME)
ENDIF($ENV{CC} MATCHES ".+") ENDIF(NOT CMAKE_CC_COMPILER_INIT)
# set this to notfound right after so that it is searched for each time this # set this to notfound right after so that it is searched for each time this
# file is included # file is included
SET(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_INIT} CACHE STRING "C compiler") SET(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_INIT} CACHE STRING "C compiler")

View File

@ -6,20 +6,30 @@
# as a default compiler # as a default compiler
IF(NOT CMAKE_CXX_COMPILER) IF(NOT CMAKE_CXX_COMPILER)
SET(CMAKE_CXX_COMPILER_INIT NOTFOUND)
# if the user has specified CC via the environment, then use that without checking # if the user has specified CC via the environment, then use that without checking
IF($ENV{CXX} MATCHES ".+") IF($ENV{CXX} MATCHES ".+")
GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT) GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_CXX_COMPILER_INIT}) IF(EXISTS ${CMAKE_CXX_COMPILER_INIT})
ELSE(EXISTS ${CMAKE_CXX_COMPILER_INIT}) ELSE(EXISTS ${CMAKE_CXX_COMPILER_INIT})
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}.") MESSAGE(SEND_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}.\n${CMAKE_CXX_COMPILER_INIT}")
ENDIF(EXISTS ${CMAKE_CXX_COMPILER_INIT}) ENDIF(EXISTS ${CMAKE_CXX_COMPILER_INIT})
ELSE($ENV{CXX} MATCHES ".+") ENDIF($ENV{CXX} MATCHES ".+")
IF(CMAKE_GENERATOR_CXX)
IF(NOT CMAKE_CXX_COMPILER_INIT)
SET(CMAKE_CXX_COMPILER_INIT ${CMAKE_GENERATOR_CXX})
ENDIF(NOT CMAKE_CXX_COMPILER_INIT)
ENDIF(CMAKE_GENERATOR_CXX)
IF(NOT CMAKE_CXX_COMPILER_INIT)
# if not in the envionment then search for the compiler in the path # 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 ) SET(CMAKE_CXX_COMPILER_LIST c++ g++ CC aCC cl bcc )
FIND_PROGRAM(CMAKE_CXX_COMPILER_FULLPATH NAMES ${CMAKE_CXX_COMPILER_LIST}) FIND_PROGRAM(CMAKE_CXX_COMPILER_FULLPATH NAMES ${CMAKE_CXX_COMPILER_LIST})
GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT
${CMAKE_CXX_COMPILER_FULLPATH} NAME) ${CMAKE_CXX_COMPILER_FULLPATH} NAME)
ENDIF($ENV{CXX} MATCHES ".+") ENDIF(NOT CMAKE_CXX_COMPILER_INIT)
SET(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_INIT} SET(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_INIT}
CACHE STRING "C++ compiler") CACHE STRING "C++ compiler")
ENDIF(NOT CMAKE_CXX_COMPILER) ENDIF(NOT CMAKE_CXX_COMPILER)

View File

@ -27,6 +27,8 @@ cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator()
void cmGlobalVisualStudio6Generator::EnableLanguage(const char* lang, void cmGlobalVisualStudio6Generator::EnableLanguage(const char* lang,
cmMakefile *mf) cmMakefile *mf)
{ {
mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
this->cmGlobalGenerator::EnableLanguage(lang, mf); this->cmGlobalGenerator::EnableLanguage(lang, mf);
} }