2 # determine the compiler to use for C programs
3 # NOTE, a generator may set CMAKE_C_COMPILER before
4 # loading this file to force a compiler.
5 # use environment variable CCC first if defined by user, next use
6 # the cmake variable CMAKE_GENERATOR_CC which can be defined by a generator
7 # as a default compiler
8 IF(NOT CMAKE_RC_COMPILER)
9 # prefer the environment variable CC
10 IF($ENV{RC} MATCHES ".+")
11 GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT)
12 IF(CMAKE_RC_FLAGS_ENV_INIT)
13 SET(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler")
14 ENDIF(CMAKE_RC_FLAGS_ENV_INIT)
15 IF(EXISTS ${CMAKE_RC_COMPILER_INIT})
16 ELSE(EXISTS ${CMAKE_RC_COMPILER_INIT})
17 MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable RC:\n$ENV{RC}.")
18 ENDIF(EXISTS ${CMAKE_RC_COMPILER_INIT})
19 ENDIF($ENV{RC} MATCHES ".+")
21 # next try prefer the compiler specified by the generator
22 IF(CMAKE_GENERATOR_RC)
23 IF(NOT CMAKE_RC_COMPILER_INIT)
24 SET(CMAKE_RC_COMPILER_INIT ${CMAKE_GENERATOR_RC})
25 ENDIF(NOT CMAKE_RC_COMPILER_INIT)
26 ENDIF(CMAKE_GENERATOR_RC)
28 # finally list compilers to try
29 IF(CMAKE_RC_COMPILER_INIT)
30 SET(CMAKE_RC_COMPILER_LIST ${CMAKE_RC_COMPILER_INIT})
31 ELSE(CMAKE_RC_COMPILER_INIT)
32 SET(CMAKE_RC_COMPILER_LIST rc)
33 ENDIF(CMAKE_RC_COMPILER_INIT)
36 FIND_PROGRAM(CMAKE_RC_COMPILER NAMES ${CMAKE_RC_COMPILER_LIST} DOC "RC compiler")
37 IF(CMAKE_RC_COMPILER_INIT AND NOT CMAKE_RC_COMPILER)
38 SET(CMAKE_RC_COMPILER "${CMAKE_RC_COMPILER_INIT}" CACHE FILEPATH "RC compiler" FORCE)
39 ENDIF(CMAKE_RC_COMPILER_INIT AND NOT CMAKE_RC_COMPILER)
40 ENDIF(NOT CMAKE_RC_COMPILER)
42 MARK_AS_ADVANCED(CMAKE_RC_COMPILER)
45 # configure variables set in this file for fast reload later on
46 CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in
47 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeRCCompiler.cmake IMMEDIATE)
48 SET(CMAKE_RC_COMPILER_ENV_VAR "RC")