summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineASMCompiler.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/CMakeDetermineASMCompiler.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/CMakeDetermineASMCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineASMCompiler.cmake35
1 files changed, 11 insertions, 24 deletions
diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake
index 0a70d0a..a56020f 100644
--- a/Modules/CMakeDetermineASMCompiler.cmake
+++ b/Modules/CMakeDetermineASMCompiler.cmake
@@ -14,6 +14,8 @@
# determine the compiler to use for ASM programs
+INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
+
IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
# prefer the environment variable ASM
IF($ENV{ASM${ASM_DIALECT}} MATCHES ".+")
@@ -22,42 +24,27 @@ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
# finally list compilers to try
IF("ASM${ASM_DIALECT}" STREQUAL "ASM") # the generic assembler support
-
- IF(CMAKE_ASM_COMPILER_INIT)
- SET(CMAKE_ASM_COMPILER_LIST ${CMAKE_ASM_COMPILER_INIT})
- ELSE(CMAKE_ASM_COMPILER_INIT)
-
+ IF(NOT CMAKE_ASM_COMPILER_INIT)
IF(CMAKE_C_COMPILER)
SET(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "The ASM compiler")
SET(CMAKE_ASM_COMPILER_ID "${CMAKE_C_COMPILER_ID}")
ELSEIF(CMAKE_CXX_COMPILER)
SET(CMAKE_ASM_COMPILER "${CMAKE_CXX_COMPILER}" CACHE FILEPATH "The ASM compiler")
SET(CMAKE_ASM_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}")
- ELSE(CMAKE_CXX_COMPILER)
+ ELSE()
# List all default C and CXX compilers
SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc ${_CMAKE_TOOLCHAIN_PREFIX}cc cl bcc xlc
${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ CC aCC cl bcc xlC)
- ENDIF(CMAKE_C_COMPILER)
-
- ENDIF(CMAKE_ASM_COMPILER_INIT)
-
-
- ELSE("ASM${ASM_DIALECT}" STREQUAL "ASM") # some specific assembler "dialect"
-
- IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
- SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT})
- ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
+ ENDIF()
+ ENDIF()
+ ELSE() # some specific assembler "dialect"
+ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
MESSAGE(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT must be preset !")
- ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT)
-
- ENDIF("ASM${ASM_DIALECT}" STREQUAL "ASM")
-
+ ENDIF()
+ ENDIF()
# Find the compiler.
- IF (_CMAKE_USER_CXX_COMPILER_PATH OR _CMAKE_USER_C_COMPILER_PATH)
- FIND_PROGRAM(CMAKE_ASM${ASM_DIALECT}_COMPILER NAMES ${CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST} PATHS ${_CMAKE_USER_C_COMPILER_PATH} ${_CMAKE_USER_CXX_COMPILER_PATH} DOC "Assembler" NO_DEFAULT_PATH)
- ENDIF (_CMAKE_USER_CXX_COMPILER_PATH OR _CMAKE_USER_C_COMPILER_PATH)
- FIND_PROGRAM(CMAKE_ASM${ASM_DIALECT}_COMPILER NAMES ${CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST} PATHS ${_CMAKE_TOOLCHAIN_LOCATION} DOC "Assembler")
+ _cmake_find_compiler(ASM${ASM_DIALECT})
ELSE(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)