summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCXXCompiler.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-08-02 15:08:55 (GMT)
committerBrad King <brad.king@kitware.com>2012-08-02 15:33:18 (GMT)
commit796e33734db09d80041872e4ce04e838146466df (patch)
treedb414641a3d38fa249240b561085b28861582190 /Modules/CMakeDetermineCXXCompiler.cmake
parentb708f1a2b9bc82ada6a22f6c63d9fb6ccedb2862 (diff)
downloadCMake-796e33734db09d80041872e4ce04e838146466df.zip
CMake-796e33734db09d80041872e4ce04e838146466df.tar.gz
CMake-796e33734db09d80041872e4ce04e838146466df.tar.bz2
Factor common code out of CMakeDetermine(ASM|C|CXX|Fortran)Compiler
The compiler candidate list selection and search code for C, C++, ASM, and Fortran languages was duplicated across four modules. To look for compilers adjacent to already-enabled languages the C and CXX modules each used _CMAKE_USER_(C|CXX)_COMPILER_PATH and the ASM module used _CMAKE_TOOLCHAIN_LOCATION. Since commit 4debb7ac (Bias Fortran compiler search with C/C++ compilers, 2009-09-09) CMake prefers Fortran compilers matching the vendor and directory of an enabled C or C++ compiler. Factor out the common functionality among the four languages into a new CMakeDetermineCompiler module. Generalize the Fortran implementation so that all languages may each use the vendor and directory of the other languages that have already been enabled. For now do not list any vendor-specific names for C, C++, or ASM so that only the directory preference is used for these languages (existing behavior).
Diffstat (limited to 'Modules/CMakeDetermineCXXCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCXXCompiler.cmake18
1 files changed, 5 insertions, 13 deletions
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake
index f78d7a7..43b44ac 100644
--- a/Modules/CMakeDetermineCXXCompiler.cmake
+++ b/Modules/CMakeDetermineCXXCompiler.cmake
@@ -30,6 +30,8 @@
# If not already set before, it also sets
# _CMAKE_TOOLCHAIN_PREFIX
+INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
+
IF(NOT CMAKE_CXX_COMPILER)
SET(CMAKE_CXX_COMPILER_INIT NOTFOUND)
@@ -52,21 +54,11 @@ IF(NOT CMAKE_CXX_COMPILER)
ENDIF(CMAKE_GENERATOR_CXX)
# finally list compilers to try
- IF(CMAKE_CXX_COMPILER_INIT)
- SET(CMAKE_CXX_COMPILER_LIST ${CMAKE_CXX_COMPILER_INIT})
- ELSE(CMAKE_CXX_COMPILER_INIT)
+ IF(NOT CMAKE_CXX_COMPILER_INIT)
SET(CMAKE_CXX_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ CC aCC cl bcc xlC clang++)
- ENDIF(CMAKE_CXX_COMPILER_INIT)
-
- # Find the compiler.
- IF (_CMAKE_USER_C_COMPILER_PATH)
- FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES ${CMAKE_CXX_COMPILER_LIST} PATHS ${_CMAKE_USER_C_COMPILER_PATH} DOC "C++ compiler" NO_DEFAULT_PATH)
- ENDIF (_CMAKE_USER_C_COMPILER_PATH)
- FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES ${CMAKE_CXX_COMPILER_LIST} DOC "C++ compiler")
+ ENDIF()
- 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)
+ _cmake_find_compiler(CXX)
ELSE(NOT CMAKE_CXX_COMPILER)
# we only get here if CMAKE_CXX_COMPILER was specified using -D or a pre-made CMakeCache.txt