CMakeDetermineRCCompiler.cmake 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #=============================================================================
  2. # Copyright 2004-2009 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distributed this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. # determine the compiler to use for C programs
  14. # NOTE, a generator may set CMAKE_C_COMPILER before
  15. # loading this file to force a compiler.
  16. # use environment variable CCC first if defined by user, next use
  17. # the cmake variable CMAKE_GENERATOR_CC which can be defined by a generator
  18. # as a default compiler
  19. IF(NOT CMAKE_RC_COMPILER)
  20. # prefer the environment variable CC
  21. IF($ENV{RC} MATCHES ".+")
  22. GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT)
  23. IF(CMAKE_RC_FLAGS_ENV_INIT)
  24. SET(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler")
  25. ENDIF(CMAKE_RC_FLAGS_ENV_INIT)
  26. IF(EXISTS ${CMAKE_RC_COMPILER_INIT})
  27. ELSE(EXISTS ${CMAKE_RC_COMPILER_INIT})
  28. MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable RC:\n$ENV{RC}.")
  29. ENDIF(EXISTS ${CMAKE_RC_COMPILER_INIT})
  30. ENDIF($ENV{RC} MATCHES ".+")
  31. # next try prefer the compiler specified by the generator
  32. IF(CMAKE_GENERATOR_RC)
  33. IF(NOT CMAKE_RC_COMPILER_INIT)
  34. SET(CMAKE_RC_COMPILER_INIT ${CMAKE_GENERATOR_RC})
  35. ENDIF(NOT CMAKE_RC_COMPILER_INIT)
  36. ENDIF(CMAKE_GENERATOR_RC)
  37. # finally list compilers to try
  38. IF(CMAKE_RC_COMPILER_INIT)
  39. SET(CMAKE_RC_COMPILER_LIST ${CMAKE_RC_COMPILER_INIT})
  40. ELSE(CMAKE_RC_COMPILER_INIT)
  41. SET(CMAKE_RC_COMPILER_LIST rc)
  42. ENDIF(CMAKE_RC_COMPILER_INIT)
  43. # Find the compiler.
  44. FIND_PROGRAM(CMAKE_RC_COMPILER NAMES ${CMAKE_RC_COMPILER_LIST} DOC "RC compiler")
  45. IF(CMAKE_RC_COMPILER_INIT AND NOT CMAKE_RC_COMPILER)
  46. SET(CMAKE_RC_COMPILER "${CMAKE_RC_COMPILER_INIT}" CACHE FILEPATH "RC compiler" FORCE)
  47. ENDIF(CMAKE_RC_COMPILER_INIT AND NOT CMAKE_RC_COMPILER)
  48. ENDIF(NOT CMAKE_RC_COMPILER)
  49. MARK_AS_ADVANCED(CMAKE_RC_COMPILER)
  50. # configure variables set in this file for fast reload later on
  51. CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in
  52. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeRCCompiler.cmake IMMEDIATE)
  53. SET(CMAKE_RC_COMPILER_ENV_VAR "RC")