CMakeDetermineRCCompiler.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 ".+")
  16. # next try prefer the compiler specified by the generator
  17. IF(CMAKE_GENERATOR_RC)
  18. IF(NOT CMAKE_RC_COMPILER_INIT)
  19. SET(CMAKE_RC_COMPILER_INIT ${CMAKE_GENERATOR_RC})
  20. ENDIF(NOT CMAKE_RC_COMPILER_INIT)
  21. ENDIF(CMAKE_GENERATOR_RC)
  22. # if no compiler has been specified yet, then look for one
  23. IF(NOT CMAKE_RC_COMPILER_INIT)
  24. SET(CMAKE_RC_COMPILER_LIST rc)
  25. FIND_PROGRAM(CMAKE_RC_COMPILER_FULLPATH NAMES ${CMAKE_RC_COMPILER_LIST} )
  26. GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT
  27. ${CMAKE_RC_COMPILER_FULLPATH} NAME)
  28. SET(CMAKE_RC_COMPILER_FULLPATH "${CMAKE_RC_COMPILER_FULLPATH}"
  29. CACHE INTERNAL "full path to the compiler cmake found")
  30. ENDIF(NOT CMAKE_RC_COMPILER_INIT)
  31. SET(CMAKE_RC_COMPILER ${CMAKE_RC_COMPILER_INIT} CACHE STRING "RC compiler")
  32. ENDIF(NOT CMAKE_RC_COMPILER)
  33. MARK_AS_ADVANCED(CMAKE_RC_COMPILER)
  34. # configure variables set in this file for fast reload later on
  35. CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in
  36. ${CMAKE_BINARY_DIR}/CMakeRCCompiler.cmake IMMEDIATE)
  37. SET(CMAKE_RC_COMPILER_ENV_VAR "RC")