1 # determine the compiler to use for C programs
2 # NOTE, a generator may set CMAKE_C_COMPILER before
3 # loading this file to force a compiler.
4 # use environment variable CCC first if defined by user, next use
5 # the cmake variable CMAKE_GENERATOR_CC which can be defined by a generator
6 # as a default compiler
7 IF(NOT CMAKE_RC_COMPILER)
8 # prefer the environment variable CC
9 IF($ENV{RC} MATCHES ".+")
10 GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT)
11 IF(EXISTS ${CMAKE_RC_COMPILER_INIT})
12 ELSE(EXISTS ${CMAKE_RC_COMPILER_INIT})
13 MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable RC:\n$ENV{RC}.")
14 ENDIF(EXISTS ${CMAKE_RC_COMPILER_INIT})
15 ENDIF($ENV{RC} MATCHES ".+")
17 # next try prefer the compiler specified by the generator
18 IF(CMAKE_GENERATOR_RC)
19 IF(NOT CMAKE_RC_COMPILER_INIT)
20 SET(CMAKE_RC_COMPILER_INIT ${CMAKE_GENERATOR_RC})
21 ENDIF(NOT CMAKE_RC_COMPILER_INIT)
22 ENDIF(CMAKE_GENERATOR_RC)
25 # if no compiler has been specified yet, then look for one
26 IF(NOT CMAKE_RC_COMPILER_INIT)
27 SET(CMAKE_RC_COMPILER_LIST rc)
28 FIND_PROGRAM(CMAKE_RC_COMPILER_FULLPATH NAMES ${CMAKE_RC_COMPILER_LIST} )
29 GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT
30 ${CMAKE_RC_COMPILER_FULLPATH} NAME)
31 SET(CMAKE_RC_COMPILER_FULLPATH "${CMAKE_RC_COMPILER_FULLPATH}"
32 CACHE INTERNAL "full path to the compiler cmake found")
33 ENDIF(NOT CMAKE_RC_COMPILER_INIT)
35 SET(CMAKE_RC_COMPILER ${CMAKE_RC_COMPILER_INIT} CACHE STRING "RC compiler")
36 ENDIF(NOT CMAKE_RC_COMPILER)
38 MARK_AS_ADVANCED(CMAKE_RC_COMPILER)
41 # configure variables set in this file for fast reload later on
42 CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in
43 ${CMAKE_BINARY_DIR}/CMakeRCCompiler.cmake IMMEDIATE)
44 SET(CMAKE_RC_COMPILER_ENV_VAR "RC")