diff options
Diffstat (limited to 'Modules/CMakeDetermineCXXCompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineCXXCompiler.cmake | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 79683f5..ed909ce 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -28,17 +28,18 @@ IF(NOT CMAKE_CXX_COMPILER) ENDIF(NOT CMAKE_CXX_COMPILER_INIT) ENDIF(CMAKE_GENERATOR_CXX) - # if no compiler has been found yet, then try to find one - IF(NOT CMAKE_CXX_COMPILER_INIT) - # if not in the envionment then search for the compiler in the path + # finally list compilers to try + IF(CMAKE_CXX_COMPILER_INIT) + SET(CMAKE_CXX_COMPILER_LIST ${CMAKE_CXX_COMPILER_INIT}) + ELSE(CMAKE_CXX_COMPILER_INIT) SET(CMAKE_CXX_COMPILER_LIST c++ g++ CC aCC cl bcc xlC) - 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_FULLPATH "${CMAKE_CXX_COMPILER_FULLPATH}" CACHE INTERNAL "full path to the compiler cmake found") - ENDIF(NOT CMAKE_CXX_COMPILER_INIT) - SET(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_INIT} - CACHE STRING "C++ compiler") + ENDIF(CMAKE_CXX_COMPILER_INIT) + + # Find the compiler. + FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES ${CMAKE_CXX_COMPILER_LIST} DOC "C++ compiler") + IF(CMAKE_CXX_COMPILER_INIT AND NOT CMAKE_CXX_COMPILER) + SET(CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER_INIT}" CACHE FILEPATH "C++ compiler" FORCE) + ENDIF(CMAKE_CXX_COMPILER_INIT AND NOT CMAKE_CXX_COMPILER) ENDIF(NOT CMAKE_CXX_COMPILER) MARK_AS_ADVANCED(CMAKE_CXX_COMPILER) |